From vuln-skills
Audits Python web apps for XSS (CWE-79) via sources like requests/DB results to sinks in Django/Jinja2/Mako templates, Flask/Tornado writes, Pandas to_html, BeautifulSoup decode_contents, and JS innerHTML.
npx claudepluginhub yhy0/ghsa-skill-builder --plugin vuln-skillsThis skill uses the workspace's default tool permissions.
当审计 Python Web 应用中涉及 HTML 生成、模板渲染、用户内容展示时加载此 Skill。
Detects and exploits SSTI vulnerabilities in Jinja2, Twig, Freemarker, and other template engines to achieve RCE during authorized web penetration testing.
Guides web app penetration testing for XSS vulnerabilities including stored, reflected, DOM-based attacks, payloads, filter bypasses, CSP evasion, and detection checklists.
Scans React, Vue, Angular, and vanilla JavaScript code for XSS vulnerabilities like unsafe HTML manipulation, URL issues, and event handlers.
Share bugs, ideas, or general feedback.
当审计 Python Web 应用中涉及 HTML 生成、模板渲染、用户内容展示时加载此 Skill。
Sources(用户可控数据):
request.args, request.form, URL 路径段(如 Tornado handler 中的路径参数)Sinks(输出到 HTML 的位置):
{{ var|safe }} 和 mark_safe(var) 调用|e 过滤器的变量插值({{ VAR }},尤其是 autoescape=False 时)self.write(user_input) 直接输出DataFrame.style.to_html() 渲染未转义的单元格值decode_contents() 反向解码 HTML 实体.innerHTML 赋值(Python 后端提供数据)Sanitization(HTML 转义/过滤):
django.utils.html.escape() / html.escape() — 标准 HTML 实体转义format_html() — mark_safe() 的安全替代,自动转义插值参数|e 过滤器 / autoescape=True(默认开启但可被覆盖)markupsafe.escape() — Flask/Jinja2 生态的转义函数bleach.clean() — 白名单式 HTML 标签过滤formatter="html" — 保持 HTML 实体编码.textContent 代替 .innerHTML — 安全的 DOM 文本赋值validate() 中的 XSS 检查检测路径:
mark_safe(, |safe, Markup(, self.write(, .innerHTML, to_html(, decode_contents(mark_safe() / |safe 审计:Grep mark_safe\( 和 \|safe,检查参数是否可能包含用户输入。特别关注 fallback/异常路径中的 mark_safe{{ VAR }} 中未使用 |e 的变量,检查 autoescape 配置。注意 add_html() 等自定义方法可能绕过 autoescapeself.write( / make_response(,检查是否直接输出含用户数据的字符串.style.to_html( / render_table(,检查是否在 to_html() 前对单元格值做了 html.escape()decode_contents(,检查 formatter 参数。formatter=None 会反向解码 HTML 实体CharField/TextField 类型字段的 validate() 方法中是否有 HTML 字符检查.innerHTML =,检查赋值数据是否来自后端未转义的用户输入Template( / render_unicode(,检查 default_filters 是否配置了 h(HTML 转义)以下情况通常不构成 XSS 漏洞:
mark_safe() 用于静态 HTML 片段:如 mark_safe('<br>') 或 mark_safe('<span class="icon">...</span>'),不包含任何变量|safe:Django/Flask 默认 autoescape=True,{{ var }} 会自动转义self.write() 输出 JSON + Content-Type: application/json:JSON 响应不会被浏览器渲染为 HTML(但需确认设置了 X-Content-Type-Options: nosniff 以防止浏览器 MIME 嗅探)innerHTML 赋值内容来自可信源:如从 Python 常量生成的 HTML,不包含用户数据raise web.HTTPError() 替代 self.write():Tornado 的 HTTPError 默认会转义错误消息中的 HTML