Skip to main content

prevent-cross-site-scripting

Prevent reflected, stored, and DOM cross-site scripting through contextual output handling and safe APIs. Use when untrusted data can reach HTML, script, URL, style, or document execution contexts.

来源信息

仓库
protosphinx/sphinxstack
最近来源活动
2026年7月29日 13:55
检测到的 SKILL.md 语言
英语
星标
3
Forks
0

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

文件资源管理器
2 个文件

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
prevent-cross-site-scripting
category
web
description
Prevent reflected, stored, and DOM cross-site scripting through contextual output handling and safe APIs. Use when untrusted data can reach HTML, script, URL, style, or document execution contexts.
# prevent-cross-site-scripting Trace untrusted data to every rendering sink and apply the control required by that exact context. ## Procedure 1. Inventory server templates, client renderers, rich-text features, URLs, messages, previews, and third-party widgets. 2. Trace untrusted sources to HTML, attribute, JavaScript, CSS, URL, SVG, and DOM sinks. 3. Use framework-native text binding and contextual escaping by default. 4. Replace unsafe APIs such as string-built markup or dynamic evaluation with typed, non-executing alternatives. 5. Sanitize intentionally allowed rich HTML with a maintained parser and a restrictive policy. 6. Validate allowed URL schemes and keep untrusted data out of executable script and style contexts. 7. Add a strict Content Security Policy as containment and detection, not as the primary fix. 8. Test stored, reflected, DOM, mutation, encoding, and framework-escape bypass cases. 9. Review dependency and browser assumptions whenever rendering libraries change. 10. Record removed sinks, sanitizer policy, tests, and remaining exceptions. ## Guardrails - Never use a regular expression as an HTML sanitizer. - Encoding for one context is unsafe when reused in another. - Do not mark arbitrary content as trusted to silence a framework warning. ## Done - A source-to-sink inventory and approved rendering patterns are documented - Representative payloads are tested in every reachable context - Unsafe sinks and sanitizer exceptions are recorded and reviewed
在 GitHub 查看