Vuln Patterns Xss logo

Vuln Patterns Xss

Community
yhy0
vuln-patterns-xss

Use when auditing Python web applications involving HTML rendering, template engines (Jinja2, Mako, Django templates), Markdown parsing, DataFrame-to-HTML conversion, or frontend innerHTML assignments. Covers CWE-79. Keywords: XSS, cross-site scripting, HTML injection, mark_safe, |safe, autoescape, bleach, escape, innerHTML, decode_contents, self.write, to_html, format_html

Overview

Publisheryhy0
Repositoryghsa-skill-builder
Skill namevuln-patterns-xss
Stars
75
Forks
8
Bundled files
1
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by yhy0 on GitHub. Read the source before you install it.

Installation

Install the Vuln Patterns Xss AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/yhy0/ghsa-skill-builder/tree/main/vuln-skills/skills/vuln-patterns-xss
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/yhy0/ghsa-skill-builder.git /tmp/ghsa-skill-builder
mkdir -p .claude/skills
cp -r /tmp/ghsa-skill-builder/vuln-skills/skills/vuln-patterns-xss .claude/skills/vuln-patterns-xss
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Vuln Patterns Xss in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Vuln Patterns Xss on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Vuln Patterns Xss is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

XSS Vulnerability Patterns (CWE-79)

当审计 Python Web 应用中涉及 HTML 生成、模板渲染、用户内容展示时加载此 Skill。

Detection Strategy

Sources(用户可控数据):

  • HTTP 请求参数:request.args, request.form, URL 路径段(如 Tornado handler 中的路径参数)
  • 数据库查询结果:SQL 查询返回值通过 DataFrame/ORM 渲染到页面(如 pgAdmin 查询结果、MLflow 数据集)
  • 外部数据提交接口:Sentry DSN 事件提交、API endpoint 接收的 JSON body
  • 用户配置/表单字段:模型描述、任务名称、告警配置等通过 REST API 写入的文本字段
  • 邮件模板变量:用户提供的数据嵌入 MJML/HTML 邮件模板

Sinks(输出到 HTML 的位置):

  • Django 模板中的 {{ var|safe }} 和 mark_safe(var) 调用
  • Jinja2 模板中未使用 |e 过滤器的变量插值({{ VAR }},尤其是 autoescape=False 时)
  • Tornado/Flask handler 中的 self.write(user_input) 直接输出
  • Pandas DataFrame.style.to_html() 渲染未转义的单元格值
  • BeautifulSoup decode_contents() 反向解码 HTML 实体
  • 前端 JavaScript 中的 .innerHTML 赋值(Python 后端提供数据)
  • Django REST Framework 序列化器返回的未校验 HTML 字段

Sanitization(HTML 转义/过滤):

  • django.utils.html.escape() / html.escape() — 标准 HTML 实体转义
  • Django format_html() — mark_safe() 的安全替代,自动转义插值参数
  • Jinja2 |e 过滤器 / autoescape=True(默认开启但可被覆盖)
  • markupsafe.escape() — Flask/Jinja2 生态的转义函数
  • bleach.clean() — 白名单式 HTML 标签过滤
  • BeautifulSoup formatter="html" — 保持 HTML 实体编码
  • 前端 .textContent 代替 .innerHTML — 安全的 DOM 文本赋值
  • DRF 序列化器自定义 validate() 中的 XSS 检查

检测路径:

  1. 搜索 HTML 输出点:mark_safe(, |safe, Markup(, self.write(, .innerHTML, to_html(, decode_contents(
  2. 检查输出数据是否包含用户输入(回溯 Source)
  3. 验证 Source 到 Sink 路径上是否有 HTML 转义或内容过滤
  4. 检查是否有 CSP、Content-Type、HttpOnly Cookie 等防御层
  5. 特别关注条件分支/异常路径中的 fallback 逻辑(主路径安全但 fallback 跳过转义)

Detection Checklist

  • Django mark_safe() / |safe 审计:Grep mark_safe\( 和 \|safe,检查参数是否可能包含用户输入。特别关注 fallback/异常路径中的 mark_safe
  • Jinja2 模板变量转义:搜索 {{ VAR }} 中未使用 |e 的变量,检查 autoescape 配置。注意 add_html() 等自定义方法可能绕过 autoescape
  • Tornado/Flask 直接写响应:Grep self.write( / make_response(,检查是否直接输出含用户数据的字符串
  • Pandas DataFrame 渲染:搜索 .style.to_html( / render_table(,检查是否在 to_html() 前对单元格值做了 html.escape()
  • BeautifulSoup 内容提取:Grep decode_contents(,检查 formatter 参数。formatter=None 会反向解码 HTML 实体
  • DRF 序列化器字段:检查 CharField/TextField 类型字段的 validate() 方法中是否有 HTML 字符检查
  • 前端 innerHTML 赋值:搜索 .innerHTML =,检查赋值数据是否来自后端未转义的用户输入
  • 邮件模板渲染:检查 MJML/HTML 邮件模板中用户数据是否经过转义
  • Mako 模板引擎:搜索 Mako Template( / render_unicode(,检查 default_filters 是否配置了 h(HTML 转义)

False Positive Exclusion Guide

以下情况通常不构成 XSS 漏洞:

  1. mark_safe() 用于静态 HTML 片段:如 mark_safe('<br>') 或 mark_safe('<span class="icon">...</span>'),不包含任何变量
  2. Jinja2 autoescape 已开启且未使用 |safe:Django/Flask 默认 autoescape=True,{{ var }} 会自动转义
  3. self.write() 输出 JSON + Content-Type: application/json:JSON 响应不会被浏览器渲染为 HTML(但需确认设置了 X-Content-Type-Options: nosniff 以防止浏览器 MIME 嗅探)
  4. 数据已通过白名单验证:如只允许字母数字的字段(枚举值、UUID 等)
  5. 内部管理页面 + 强认证:仅管理员可访问且无 CSRF 风险的页面(但仍建议修复)
  6. innerHTML 赋值内容来自可信源:如从 Python 常量生成的 HTML,不包含用户数据
  7. raise web.HTTPError() 替代 self.write():Tornado 的 HTTPError 默认会转义错误消息中的 HTML

Real-World Cases

详见 references/cases.md

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Vuln Patterns Xss AI skill do?

Use when auditing Python web applications involving HTML rendering, template engines (Jinja2, Mako, Django templates), Markdown parsing, DataFrame-to-HTML conversion, or frontend innerHTML assignments. Covers CWE-79. Keywords: XSS, cross-site scripting, HTML injection, mark_safe, |safe, autoescape, bleach, escape, innerHTML, decode_contents, self.write, to_html, format_html

Why use Vuln Patterns Xss on TypingMind?

Because you install it once and use it with any model. Vuln Patterns Xss is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Vuln Patterns Xss in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/yhy0/ghsa-skill-builder/tree/main/vuln-skills/skills/vuln-patterns-xss. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Vuln Patterns Xss?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Vuln Patterns Xss?

As many as you like. As long as a model supports skills, you can use Vuln Patterns Xss with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Vuln Patterns Xss AI skill free?

Yes. It is published on GitHub by yhy0 under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇