T09 · Insecure Skill Coding Practices
- Location
platform/src/app/post/[slug]/page.tsx:5- Finding
Stored Cross-Site Scripting Through Incomplete Content Sanitization
- Content
View full analysis
)<[^<]*)*<\/script>/gi, "") .replace(/on\w+\s*=\s*"[^"]*"/gi, "") .replace(/on\w+\s*=\s*'[^']*'/gi, "") .replace(/javascript\s*:/gi, "") .replace(/data\s*:\s*text\/html/gi, ""); } ``` ```tsx // platform/src/app/post/[slug]/page.tsx async function renderMarkdown(md: string): Promise { let html = md .replace(/^### (.+)$/gm, "$1
") .replace(/^## (.+)$/gm, "$1
") .replace(/^# (.+)$/gm, "$1
") .replace(/\*\*(.+?)\*\*/g, "$1") .replace(/\*(.+?)\*/g, "$1") .replace(/`(.+?)`/g, "$1") .replace(/^\- (.+)$/gm, "- $1
") .replace(/^\* (.+)$/gm, "- $1
") .replace(/(- .*<\/li>\n?)+/g, (m) => `
- ${m}
$1
") .replace(/<\/p>/g, ""); return html; } // ...
``` ### Technical Analysis The application claims to sanitize all content before storage, but its sanitizer is implemented with regular expressions. It only removes event-handler attributes when their values are enclosed in single or double quotes. Unquoted handlers, malformed HTML, namespace-based payloads, and many browser parser edge cases remain possible. For example, the following HTML is not removed: ```html``` The custom Markdown renderer also preserves raw ...[truncated 1719 chars]
- Remediation
View remediation
