用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/aibot88/sec_skill_store --skill markdown-sanitization-chain命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Guides the creation of agile user stories and Gherkin feature files. Use when the user wants to create a user story, write acceptance criteria, define Gherkin scenarios, or author BDD feature files. This should trigger for requests such as Create a user story; Write a user story; I need to write a user story. Part of cursor-rules-java project
Guía técnica completa para integrar 250+ servicios externos con agentes IA usando Composio. Cubre instalación, autenticación OAuth, gestión de herramientas, triggers y flujos multi-servicio.
Facilitates conversational discovery to create Architectural Decision Records (ADRs) for non-functional requirements using the ISO/IEC 25010:2023 quality model. Use when the user wants to document quality attributes, NFR decisions, security/performance/scalability architecture, or design systems with measurable quality criteria. This should trigger for requests such as Create ADR for Non-functional requirements; Document Non-functional requirements; Capture Non-functional requirements; Generate Non-functional requirements in an ADR. Part of cursor-rules-java project
基于 SOC 职业分类
正在显示 SKILL.md
| type | skill |
| lifecycle | stable |
| inheritance | inheritable |
| name | markdown-sanitization-chain |
| description | Markdown sanitization order matters — marked.js then DOMPurify then Mermaid to prevent XSS |
| tier | standard |
| applyTo | **/*markdown*,**/*sanitization*,**/*chain* |
| currency | 2026-04-30T00:00:00.000Z |
| lastReviewed | 2026-04-30T00:00:00.000Z |
Category: Security Time Saved: 2-4 hours debugging XSS vulnerabilities Battle-tested: Yes — production incident
You're rendering user-supplied markdown with a diagram library. The app works great until someone submits markdown containing malicious scripts that bypass your rendering.
Markdown renderers (marked.js, markdown-it) convert markdown to HTML but don't sanitize it. Diagram renderers (Mermaid, PlantUML) execute after sanitizers run, potentially introducing new attack vectors. The order of operations matters critically.
Always: marked.js → DOMPurify → Mermaid (post-render)
1. Parse markdown to HTML (marked.js)
2. Sanitize HTML (DOMPurify)
3. Render diagrams on sanitized DOM (Mermaid.run())
Never skip the sanitizer even if content is "trusted."
import { marked } from 'marked';
import DOMPurify from 'dompurify';
import mermaid from 'mermaid';
async function renderMarkdown(content, container) {
// Step 1: Parse markdown to HTML
const rawHtml = marked.parse(content);
// Step 2: Sanitize (BEFORE inserting into DOM)
const cleanHtml = DOMPurify.sanitize(rawHtml, {
ADD_TAGS: ['mermaid'], // Allow mermaid tags through
});
// Step 3: Insert sanitized HTML
container.innerHTML = cleanHtml;
// Step 4: Render diagrams on sanitized DOM
await mermaid.run({ : container.() });
}
| Mistake | Consequence |
|---|---|
| Skip DOMPurify ("it's internal content") | XSS from any content source |
| Sanitize after Mermaid renders | Mermaid-injected scripts execute |
| Use innerHTML without sanitization | Classic XSS |
| Trust localStorage/URL params | User-controlled XSS payloads |
const config = {
ADD_TAGS: ['mermaid'], // Preserve diagram tags
ADD_ATTR: ['onclick'], // Only if absolutely needed
FORBID_TAGS: ['style', 'script'], // Explicit blocklist
FORBID_ATTR: ['onerror', 'onload'],
};
<img src=x onerror=alert(1)> payloadallowlist-over-blocklist — Validation patternsshell-injection-prevention — Command execution safety