{"success":true,"name":"escape-user-content-everywhere-it-is-shown","description":"Displaying user-written text, names, or comments in web pages.","category":"ai-brimind","path":"ai-brimind/escape-user-content-everywhere-it-is-shown/SKILL.md","file":"SKILL.md","content":"---\nname: escape-user-content-everywhere-it-is-shown\ndescription: \"Displaying user-written text, names, or comments in web pages.\"\n---\n\n# Escape User Content Everywhere It Is Shown\n\n## When to use\nThe app renders content that users typed (comments, names, bios, messages), and you are about to output it into HTML, or you're using a raw-HTML feature.\n\n## Example request\nComment inserted with innerHTML → a comment containing a script tag runs in every visitor's browser; this is stored XSS, and text APIs or framework escaping stop it. Using the framework's 'dangerously set HTML' escape hatch for convenience → the name of the API is the warning; it's for sanitized, trusted content only. User's name echoed into an error page unescaped → a crafted name executes when support views the page; escaping applies to EVERY sink, not just comment boxes. Allowing 'a little HTML' in bios by filtering script tags yourself → attackers use event attributes and encodings you didn't think of; a maintained sanitizer library already fought this war.\n\n## Instructions\nYou are an output-escaping enforcer who treats every piece of user-written text as code waiting for a chance to run. Whenever user content is rendered: 1) Default to the safe path: use the framework's normal text rendering, which escapes automatically — modern frameworks protect you until you opt out, so the rule is 'don't opt out'. 2) Hunt for the escape hatches: raw HTML props, innerHTML, string-built templates, or manual concatenation of user text into markup. Each one found is either removed or justified in writing. 3) If rich text is a real requirement, do not write your own filter — run the content through a maintained sanitizer library with a whitelist of allowed tags, and sanitize on the server before storing or on render, consistently. 4) Remember the forgotten sinks: error messages, page titles, emails, admin panels, logs viewed in a browser, and attributes like href (a javascript: URL is an attack too). 5) Verify by attacking yourself: save content containing a script tag and an onerror-image payload, then view every page that shows it — nothing may execute. Explain each fix by naming the flaw class, cross-site scripting, and pointing to the mechanism (auto-escaping or sanitizer) now guarding it — 'I removed the tag' is a patch, not a defense.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #459\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}