HTML error page does not escape template filename/URI
还没有人认领这个 Issue。
评估
调研方向
先定位 html_error_template(),以及在错误页面中呈现模板文件名或 URI 的代码。追踪该值如何进入 HTML 输出,然后添加一个使用包含 HTML 字符的 URI 的回归测试。生成的错误页面中的 URI 已转义即表示完成;运行相关的错误模板测试。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
html_error_template() renders the template filename/URI without HTML escaping. If a template URI contains untrusted HTML, it is included verbatim in the generated error page rather than escaped.
To Reproduce
from mako.lookup import TemplateLookup
uri = "<img src=x onerror=alert(1)>"
lookup = TemplateLookup(format_exceptions=True)
lookup.put_string(uri, "${1/0}")
page = lookup.get_template(uri).render_unicode()
print(page)
Error
The generated error page contains:
<div class="location"><img src=x onerror=alert(1)>, line 1:</div>
I would expect the URI to be escaped.
Versions
- OS: Linux
- Python: 3.12
- Mako: 1.4.3 and current
main(14889bc)
Additional context
I reported this privately first. The security team reviewed it as a defense-in-depth issue and suggested opening a public issue or PR.
Happy to submit a fix and regression test.
- 主要语言
- Python
- 星标
- 461
- 派生
- 104
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
sqlalchemy/mako 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 38/100
sqlalchemy/mako#432 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
sqlalchemy/mako#417 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 30/100
sqlalchemy/mako#392 · 2 条评论 ·
-
难度 5/5 一周以上 新手友好度 15/100
sqlalchemy/mako#382 · 2 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 48/100
sqlalchemy/mako#376 · 9 条评论 ·
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
-
bug
难度 2/5 1-3 小时 新手友好度 77/100
AstrBotDevs/AstrBot#10720 ·
维护者通常 1 天内回复
-
cause/upstream comp/cli P2 provider/other tool/file type/bug
难度 2/5 1-3 小时 新手友好度 78/100
NousResearch/hermes-agent#143900 ·
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 85/100
WLAN-Pi/wlanpi-profiler#341 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复