/vuln-skills:vuln-patterns-xssfrom vuln-skills
Audits Python web applications for XSS (CWE-79) across Django, Jinja2, Flask, Tornado, Pandas, BeautifulSoup, and DRF. Covers template rendering, innerHTML assignments, and HTML sanitization.
Ships in vuln-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
当审计 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 默认会转义错误消息中的 HTMLWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
xss, cross-site-scripting, html-injection, security-audit, cwe-79
26 skills in this plugin
/go-vuln-auth-bypassUse when auditing Go code involving authentication flows, RBAC policies, Kubernetes admission webhooks, JWT/OAuth token validation, or privilege escalation in cloud-native infrastructure. Covers CWE-287/863/269/284/285/862. Keywords: authentication bypass, authorization bypass, RBAC, admission webhook, JWT, OAuth, privilege escalation, Rancher, Kyverno, impersonation, namespace isolation, middleware auth/go-vuln-crypto-tlsUse when auditing Go code involving TLS configuration, certificate validation, JWT token parsing, SAML assertion verification, webhook signature checking, or cryptographic operations. Covers CWE-295/347/345. Keywords: InsecureSkipVerify, TLS, mTLS, certificate validation, JWT algorithm, SAML signature, cosign, sigstore, hmac.Equal, X.509, webhook HMAC/go-vuln-npx claudepluginhub yhy0/ghsa-skill-builder --plugin vuln-skillsOther plugins' skills for the same job