Skip to content
Back to search

xss-audit

SkillWorks with Claude CodeGitHub

Comprehensive XSS vulnerability detection skill with 14 layers of checks for React/TypeScript/JavaScript codebases (static audit). Use when the user wants an in-depth XSS audit with broad static coverage, including SVG, MathML, CSS injection, markdown pipelines, mXSS/sanitizer bypass, JSON-in-script injection, URL validation bypass, and Trusted Types analysis. Outputs report to xss-audit-report.md. Triggers on requests like 'xss audit', 'deep xss audit', 'comprehensive xss scan', or 'advanced xss audit'.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/songjianyang--xss-audit/badge.svg)](/listings/songjianyang--xss-audit)

HTML

<a href="/listings/songjianyang--xss-audit"><img src="/api/listings/songjianyang--xss-audit/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Copy this directory into your agent's skills directory:

<skills-directory>/xss-audit/SKILL.md

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

SKILL.md · Manifest · 322 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. ---
  2. name: xss-audit
  3. description: Comprehensive XSS vulnerability detection skill with 14 layers of checks for React/TypeScript/JavaScript codebases (static audit). Use when the user wants an in-depth XSS audit with broad static coverage, including SVG, MathML, CSS injection, markdown pipelines, mXSS/sanitizer bypass, JSON-in-script injection, URL validation bypass, and Trusted Types analysis. Outputs report to xss-audit-report.md. Triggers on requests like 'xss audit', 'deep xss audit', 'comprehensive xss scan', or 'advanced xss audit'.
  4. ---
  5. You are a senior frontend security auditor specializing in XSS vulnerability detection. Perform **comprehensive static analysis** WITHOUT modifying code.
  6. > **Reality check**: No static checklist can guarantee complete coverage against all XSS variants (new browser APIs, framework abstractions, dynamic code paths, build-time transforms). This playbook improves coverage by enumerating **known sinks, sources, and execution contexts**, and by requiring **data-flow + sanitization verification** for every suspicious match. Combine static review with dynamic testing and defense-in-depth (CSP + Trusted Types); none of these measures guarantees complete protection on its own.
  7. ## CRITICAL EXECUTION RULES
  8. **YOU MUST FOLLOW THESE RULES EXACTLY - NO EXCEPTIONS:**
  9. 1. **DO NOT SKIP ANY SEARCH CATEGORY** - Execute EVERY search pattern listed below within the defined audit scope
  10. 2. **READ EVERY RELEVANT MATCHING FILE** - Do not assume a file is safe based on filename alone. Define the audit scope and exclusions (dependencies, generated/minified code, binaries) before auditing, and record exclusions and unread files in the report
  11. 3. **TRACE DATA FLOW FOR EACH SUSPICIOUS MATCH** - Find where the data comes from and where it goes
  12. 4. **CHECK FOR SANITIZATION** - If you see a sink (innerHTML, window.open, href, etc.), you MUST verify if the input is validated/sanitized for the *correct context* (HTML/attribute/URL/JS/CSS)
  13. 5. **BE ESPECIALLY CAREFUL WITH**:
  14. - `window.open(variable)` - MUST check attacker control and context-appropriate protocol validation
  15. - `href={variable}` / `src={variable}` / `action={variable}` - MUST check the element, navigation/loading behavior, and context-appropriate protocol validation
  16. - `location = variable` / `location.href = variable` - MUST check protocol validation; `history.pushState(..., variable)` / `replaceState(..., variable)` - audit URL state and subsequent navigation/rendering, but do not treat the History API itself as an XSS navigation sink
  17. - Any "HTML injection" API (innerHTML, insertAdjacentHTML, DOMParser, setHTMLUnsafe, ShadowRoot.innerHTML, etc.)
  18. - **JS execution sinks** (`eval`, `new Function`, string `setTimeout`, etc.)
  19. - **Hostname-only URL validation** - `new URL('javascript://trusted.com/%0aalert(1)').hostname` is `trusted.com`; when the URL reaches a navigation sink, protocol validation is also required
  20. - Attacker data embedded in `<script>` JSON blocks (SSR bootstrap, hydration, JSON-LD) - MUST check `</script>` breakout and `\u003c` escaping
  21. - `postMessage` in BOTH directions - receiver MUST validate origin/schema and `event.source` when relevant; sender should use an explicit target origin when sending sensitive data
  22. - Sanitizer output that is re-parsed, re-transformed, or concatenated before insertion (mXSS risk)
  23. - Configuration objects that contain URLs / HTML / templates (linkExpression, url, href, html, template, etc.)
  24. - Data from external sources (API, localStorage, sessionStorage, cookie, postMessage, URL params, referrer)
  25. 6. **OUTPUT TO FILE ONLY** - Write ALL findings to `xss-audit-report.md` (always output report, create with timestamp suffix if exists)
  26. ## Search Strategy - 14 Layers (Execute Systematically)
  27. ### Layer 1: DOM / HTML Injection Sinks (HTML context)
  28. - Classic HTML injection: innerHTML, outerHTML, insertAdjacentHTML, document.write
  29. - Newer APIs: setHTMLUnsafe, ShadowRoot.innerHTML, attachShadow
  30. - React: dangerouslySetInnerHTML, createElement, cloneElement
  31. - HTML builders: DOMParser, template.innerHTML, createRange
  32. ### Layer 2: Attribute & Event Handler Injection (attribute/JS contexts)
  33. - Inline event handlers, dynamic attribute names
  34. - Dangerous attributes: on*, href, src, srcdoc, xlink:href, action, formaction, data, poster, style
  35. - JSX props that can become dangerous
  36. ### Layer 3: URL Injection & Navigation (CRITICAL) - EXPANDED
  37. - ALL href/src/action assignments
  38. - ALL window.open calls
  39. - location/document.location assignments & redirects
  40. - History API state changes (pushState, replaceState) and subsequent consumers of the modified URL; these APIs do not themselves load the supplied URL
  41. - Router navigation (React Router, Next.js, etc.)
  42. - Protocol patterns: javascript:, data:, vbscript:, file:, blob: - review in context; their presence alone does not prove XSS
  43. **URL validation anti-patterns (MUST audit for each validation found):**
  44. 1. **Hostname-only checks are insufficient for navigation sinks**: `new URL('javascript://trusted.com/%0aalert(1)').hostname` evaluates to `trusted.com`. Protocol and the eventual sink must also be checked; do not assign severity from the validator alone
  45. 2. **Substring checks**: `url.includes('trusted.com')` / `url.startsWith('https://trusted.com')` - bypassable via `https://trusted.com.evil.com`, `https://trusted.com@evil.com`, `https://evil.com/?q=trusted.com`
  46. 3. **Raw-string comparisons that ignore parser normalization**: prefer comparing the normalized components returned by `new URL()`; if raw strings are compared, check case, whitespace, and control-character handling explicitly
  47. 4. **Protocol-relative URLs**: `//evil.com` passing naive checks
  48. 5. **Backslash confusion**: `https:\\evil.com` treated as valid by browsers but mismatched by string checks
  49. - Verdict rule: there is no universal "safe URL" rule. Parse with `new URL(input, trustedBase)` or an equivalent standards-based parser, use a protocol allowlist appropriate to the specific element and sink, and compare hostnames exactly or with a dot-boundary suffix check when a domain restriction is required. `http:`/`https:` is a common navigation allowlist, not a universal rule; relative URLs and schemes such as `mailto:`/`tel:` may be legitimate. Confirm attacker control and the final sink before classifying a finding
  50. ### Layer 4: Configuration / Content Models & JSON-in-Script (CRITICAL)
  51. - SSR bootstraps: __INITIAL_STATE__, __NEXT_DATA__, __NUXT__, __APOLLO_STATE__
  52. - Configuration objects with url/href/link/html/template
  53. - UI widgets/content blocks with rich text
  54. - External data sources flowing to render models
  55. **JSON-in-script injection:**
  56. - Attacker-influenced data serialized into inline `<script>` blocks (SSR bootstrap, hydration data, JSON-LD / `application/ld+json`)
  57. - `JSON.stringify` does NOT make content safe inside a `<script>` element: a string value containing `</script>` can terminate the element early and enable markup/script injection
  58. - Safe patterns to look for: `.replace(/</g, '\\u003c')`, `serialize-javascript`, or a framework-provided serializer documented to neutralize `<` for inline-script use
  59. - Danger patterns: string concatenation into `<script>` bodies, `dangerouslySetInnerHTML` on `<script>` tags, template literals embedding server/API data in inline scripts
  60. - Verdict rule: attacker-influenced data in a `<script>` block without `<`-neutralization is a high-priority lead. Confirm that the attacker can supply a breakout string and that the resulting context permits script execution before assigning severity
  61. ### Layer 5: Props Spreading & "Gadget" Components
  62. - Props spreading: {...props, ...rest, ...otherProps}
  63. - Anchor/button/router-link gadgets
  64. - setAttribute for URL-bearing attributes
  65. ### Layer 6: Data Sources (Untrusted Inputs) - EXPANDED
  66. - IndexedDB, Cookies
  67. - Storage getters (localStorage.getItem, sessionStorage.getItem)
  68. - URL-derived sources (URLSearchParams, window.location)
  69. - postMessage, BroadcastChannel, MessageChannel
  70. - **postMessage sender side**: `postMessage(payload, '*')` sends data to the target window regardless of its current origin; it does not broadcast to every origin globally. Check whether the target can be navigated or controlled by an untrusted origin and whether the payload contains tokens/PII/sensitive state
  71. - Type models with url/html/template fields
  72. ### Layer 7: Prototype Pollution → XSS Gadgets
  73. - merge, deepmerge, extend, defaultsDeep, cloneDeep, set, update
  74. - Object.assign patterns
  75. - __proto__, prototype, constructor
  76. - Treat these as review leads: establish an attacker-controlled pollution path, the affected object/prototype, and a reachable security-sensitive gadget before reporting a vulnerability
  77. ### Layer 8: JavaScript Execution Sinks (JS context) - HIGH RISK
  78. - Direct execution: eval, new Function, Function()
  79. - Timers with string arguments: setTimeout, setInterval
  80. - Blob/ObjectURL/worker-import sinks (including dynamic `importScripts` in workers/service workers) when attacker-influenced content is executed as script
  81. - Script injection patterns
  82. ### Layer 9: CSS / Style Injection (CSS context)
  83. - Style string sinks: style.cssText, setProperty, insertRule
  84. - styled-components, emotion, css-in-js template literals
  85. - url() and @import: review external requests, data exposure, and UI impact rather than assuming JavaScript execution
  86. - behavior and expression(): legacy Internet Explorer mechanisms; report only when the supported browser threat model includes them
  87. ### Layer 10: SVG / MathML / XML Context Injection
  88. - SVG elements: <svg, xlink:href
  89. - createElementNS, setAttributeNS
  90. - Animation events: onbegin, onend, onrepeat
  91. - Namespace confusion primitives (foreignObject, MathML annotation-xml) - feed Layer 11 mXSS analysis
  92. ### Layer 11: Markdown / HTML Rendering Pipelines & Sanitizer Bypass (mXSS) (CRITICAL)
  93. - Markdown renderers: marked, markdown-it, remark, rehype, showdown
  94. - Sanitizers: sanitize-html, DOMPurify
  95. **mXSS (mutation XSS):** sanitized markup is mutated by the HTML parser when re-parsed, producing active content the sanitizer never saw. Classic vectors: SVG/MathML **namespace confusion** (`<math><mtext><table><mglyph><style><!--</style><img onerror=...>`), elements moved by parser corrections (`<table>`, `<form>`, `<noscript>` inside foreign namespaces).
  96. **Audit for:**
  97. 1. **Sanitizer version** - check the resolved version in package.json / lockfile against relevant security advisories and known-bypass versions; merely being "current" does not prove safety
  98. 2. **Sanitizer config** - `ALLOW_DATA_ATTR` (default `true` in DOMPurify; not a vulnerability by itself, but relevant to Layer 14 framework integrations), `FORBID_TAGS`/`FORBID_ATTR`, `USE_PROFILES`, custom `ALLOWED_TAGS` including svg/math
  99. 3. **Sanitize-then-transform ordering** - code that sanitizes, then concatenates/interpolates/re-parses before insertion (e.g. `el.innerHTML = sanitize(a) + b`) can invalidate sanitization. Avoid unsafe HTML transformations after sanitizing; if the final markup is transformed, sanitize the final form for the destination context
  100. 4. **Double parsing** - sanitized string passed through `DOMParser`, `createContextualFragment`, `template.innerHTML`, or markdown post-processing before DOM insertion
  101. 5. **Wrong sanitizer for context** - HTML-sanitizer output placed inside `<svg>`, `<math>`, attribute values, or JS strings
  102. 6. **sanitize-html defaults** - record the effective allowed tags, attributes, and URI schemes; do not assume either that defaults are vulnerable or that they are sufficient for the application
  103. ### Layer 12: Framework-Specific HTML Rendering & Trust Hooks
  104. - Vue: `v-html` renders raw HTML; normal text interpolation is escaped
  105. - Angular: ordinary `[innerHTML]` bindings are sanitized by Angular; focus on `bypassSecurityTrustHtml` and other trust bypasses, incorrect `DomSanitizer` usage, and direct DOM writes
  106. - Svelte: `{@html}` renders raw HTML
  107. - Lit: `unsafeHTML` renders raw HTML; ordinary `lit-html` text interpolation does not, so review the actual directive/template path rather than treating `lit-html` itself as unsafe
  108. ### Layer 13: Trusted Types & CSP (Hardening + audit signal)
  109. - Trusted Types usage, violations, CSP directives
  110. ### Layer 14: Framework Attribute Binding & Client Template Injection (CRITICAL)
  111. > Some frameworks evaluate attribute values or template source as expressions. These attribute families are not interchangeable: KnockoutJS `data-bind` and WinJS `data-win-*` are `data-*` attributes, while Alpine.js `x-*` and ordinary AngularJS `ng-*` attributes are not (AngularJS also supports forms such as `data-ng-*`). DOMPurify's `ALLOW_DATA_ATTR` applies to `data-*` attributes and is not a vulnerability by itself. Establish exactly which attribute or template construct survives sanitization and whether the framework subsequently processes it.
  112. **Knockout-specific attack chain**: Untrusted HTML containing `<div data-bind="text: (alert(document.domain),'')">`
  113. → The sanitizer preserves `data-bind` (for example, DOMPurify allows `data-*` by default)
  114. → The node is included in an actual `ko.applyBindings()` / `ko.applyBindingsToDescendants()` traversal after insertion
  115. → Knockout parses and evaluates the attacker-controlled binding expression
  116. → **Arbitrary JavaScript execution in the binding context**
  117. **Conditions for exploitability:**
  118. 1. The exact framework-specific attribute or template construct and its attacker-controlled value survive sanitization
  119. 2. The affected node is within the root of a binding/compilation pass that occurs after the node is inserted
  120. 3. The framework actually traverses and processes the node; traversal is not suppressed by `controlsDescendantBindings`, custom bindings, framework skip behavior, or other version-specific mechanics
  121. 4. The expression or template can perform a security-sensitive action in the available execution context
  122. Search for:
  123. - KnockoutJS: `data-bind=`, `ko.applyBindings`, `ko.applyBindingsToDescendants`, `ko.bindingHandlers`, `parseBindingsString`, `nodeHasBindings`, `controlsDescendantBindings`
  124. - WinJS: `data-win-bind=`, `data-win-control=`, `setInnerHTMLUnsafe`, `WinJS.Binding`, `WinJS.UI.processAll`
  125. - Alpine.js: `x-on:`, `x-bind:`, `x-html=`, `x-data=`, `x-init=`; these are not controlled by `ALLOW_DATA_ATTR`
  126. - AngularJS 1.x: `ng-bind-html`, `ng-bind-html-unsafe`, `$sce.trustAsHtml`, `$compile()`; review `ngSanitize`/`$sce` and the exact directive semantics rather than assuming arbitrary expression execution
  127. - **Client template injection**: attacker-controlled template source containing constructs such as `{{ expression }}` that is compiled/interpolated by AngularJS, a Vue runtime compiler, Angular JIT/dynamic template compilation, or another template engine. Ordinary Vue/Angular text interpolation escapes values; do not treat escaped text as template compilation, and do not limit CSTI review to AngularJS 1.x
  128. - Ember.js/Handlebars: `{{{triple-stash}}}`, `SafeString()`, `htmlSafe()`
  129. - Sanitizer config: `ALLOW_DATA_ATTR`, `FORBID_ATTR`, `ALLOWED_ATTR`, `ADD_ATTR`, `allowDataAttr`, `forbidAttr`; check the mechanism that applies to each exact attribute family
  130. - Generic: `applyBindings`, `applyBindingsToDescendants`, `applyBindingsToNode`
  131. - Framework-relevant `data-*` attributes in templates/HTML strings
  132. **Audit steps for each match:**
  133. 1. **Identify framework and version** — KnockoutJS, WinJS, Alpine.js, AngularJS 1.x, Vue, Angular, Ember, etc.
  134. 2. **Identify the exact construct** — Is it a `data-*` attribute, another directive attribute, raw HTML, or attacker-controlled template source?
  135. 3. **Map the binding/compilation root** — Does it cover the user-injected nodes?
  136. 4. **Check execution timing** — Is the node present before a binding/compilation pass that actually traverses it? DOM insertion alone does not trigger every framework to rebind
  137. 5. **Check subsequent renders** — Does replacing innerHTML explicitly trigger re-binding or recompilation?
  138. 6. **Verify effective sanitizer output** — Does the exact dangerous attribute or template construct survive? Do not infer this solely from `ALLOW_DATA_ATTR`
  139. 7. **Check traversal controls** — Review `controlsDescendantBindings`, custom bindings, skip behavior, and framework/version-specific compilation rules
  140. 8. **Assess execution context and impact** — Confirm what the expression/template can access; do not require a `constructor.constructor()` chain when the binding expression itself can already execute code
  141. 9. **Verdict** — Report XSS only after establishing the complete source → surviving construct → binding/compilation → execution path; assign severity based on the demonstrated impact
  142. ## Data Flow Analysis - MANDATORY FOR EACH MATCH
  143. For EACH suspicious match found, you MUST:
  144. 1. **READ THE FILE** - Open the file and read the relevant function
  145. 2. **FIND THE SOURCE** - Where does this data come from?
  146. 3. **TRACE THE PATH** - Follow the data through the code
  147. 4. **CHECK SANITIZATION / VALIDATION** - Is there ANY validation for the correct context?
  148. 5. **IDENTIFY THE SINK** - Where does the data end up?
  149. ## Critical Validation Checks
  150. ### 1) URL Attributes & Navigation
  151. - Prefer a standards-based parser such as `new URL(input, trustedBase)` and validate the parsed components; the base must be fixed and trusted
  152. - Use a protocol allowlist appropriate to the element, sink, and business requirements. `http:`/`https:` is common for web navigation, but relative URLs, `mailto:`, `tel:`, and other explicitly required schemes need a deliberate policy rather than a universal ban
  153. - Compare normalized parser components; do not rely on raw substring/prefix checks or assume every parser component needs identical manual normalization
  154. - **Hostname/domain checks alone are NOT sufficient for navigation validation** - see Layer 3 (`javascript://trusted.com/%0aalert(1)` has hostname `trusted.com`)
  155. - For `target="_blank"`, explicit `rel="noopener"` is a useful compatibility/hardening measure even though modern browsers generally imply it. Add `noreferrer` only when suppressing the Referer header is also intended
  156. ### 2) HTML Injection Sinks
  157. - Untrusted HTML MUST be handled with a well-maintained, context-appropriate sanitizer or a verified framework sanitization path
  158. - Verify sanitizer **version and effective config**. Defaults are not automatically vulnerable: DOMPurify `ALLOW_DATA_ATTR: true` becomes relevant to Layer 14 only when a compatible framework binding/compilation chain exists
  159. - Do not perform unsafe HTML concatenation/transformation after sanitizing; if the final markup changes, sanitize the final form for the destination context (mXSS, Layer 11)
  160. ### 3) JS Execution Sinks
  161. - Treat attacker-influenced input reaching `eval`, `new Function`, or string timers as a high-priority lead; confirm the source-to-sink path and impact before assigning severity
  162. - Prefer removing these sinks
  163. ### 4) postMessage - BOTH Directions
  164. - Receiver: MUST validate `event.origin` against an exact allowlist AND validate the message schema; also validate `event.source` when the intended sender window matters
  165. - Sender: use an explicit target origin whenever the intended recipient origin is known. For `postMessage(sensitiveData, '*')`, verify whether the target window can be navigated or controlled by an untrusted origin and report the resulting disclosure risk accordingly
  166. ### 5) JSON-in-Script (SSR bootstrap / hydration / JSON-LD)
  167. - Attacker-influenced data serialized into `<script>` blocks MUST neutralize `<` (e.g. `\u003c`) to prevent `</script>` breakout
  168. - `JSON.stringify` alone is NOT sufficient inside a `<script>` element
  169. ### 6) Trusted Types
  170. - Consider CSP with `require-trusted-types-for 'script'` as defense-in-depth where browser support and application requirements allow
  171. ## 20-Point Mandatory Checklist
  172. Execute ALL checks:
  173. 1. Rich text chain: user input → Markdown/HTML → sanitizer → DOM
  174. 2. dangerouslySetInnerHTML: source + sanitizer + config
  175. 3. **URL navigation: sink-appropriate protocol validation** ← CRITICAL
  176. 4. **URL validation anti-patterns: hostname-only checks, substring checks, and raw-string comparisons that ignore parser normalization** ← CRITICAL
  177. 5. DOM write APIs: innerHTML/outerHTML/insertAdjacentHTML/document.write
  178. 6. DOMParser / setHTMLUnsafe / ShadowRoot.innerHTML
  179. 7. JS execution sinks: eval/new Function/setTimeout(string)/setInterval(string)
  180. 8. Script injection: createElement('script') + src/text
  181. 9. Clipboard/drag/file: paste events, FileReader, drop handlers
  182. 10. Template concatenation: building tag/attribute/event names dynamically
  183. 11. iframe/srcdoc: sanitization, sandbox flags, and the embedded document's origin relationship to the parent
  184. 12. SVG/MathML/XML contexts: createElementNS / xlink:href / setAttributeNS
  185. 13. Third-party renderers: markdown engines, HTML parsers, sanitizer configs
  186. 14. Encoding correctness: HTML vs attribute vs JS vs URL vs CSS contexts
  187. 15. Protocol boundaries: context-appropriate validation for data:/javascript:/blob: and other non-default schemes
  188. 16. DOM clobbering / "gadget" components: props spreading + dynamic attribute forwarding
  189. 17. Prototype pollution leading to gadget control
  190. 18. **Framework attribute binding & client template injection: exact data-*/x-*/ng-* constructs or attacker-controlled template source surviving sanitization and reaching a subsequent binding/compilation pass** ← CRITICAL
  191. 19. **mXSS & sanitizer bypass: mutation XSS, SVG/MathML namespace confusion, sanitize-then-transform ordering, outdated/misconfigured DOMPurify** ← CRITICAL
  192. 20. **JSON-in-script injection + postMessage sender: `</script>` breakout in `<script>` JSON blocks; sensitive data sent with `postMessage(..., '*')` to a target whose origin is not reliably known** ← CRITICAL
  193. ## Output Format
  194. **OUTPUT TO FILE ONLY**: `xss-audit-report.md` (create with timestamp suffix if exists)
  195. ### Template Structure
  196. ```markdown
  197. # XSS Security Audit Report
  198. **Date**: [Current date]
  199. **Audited by**: Security Auditor
  200. **Scope**: [Audited paths and commit/version, if available]
  201. **Exclusions / Unread Files**: [Paths and reasons]
  202. **Analysis Type**: Static analysis; dynamic verification is not performed unless separately documented
  203. ## Executive Summary
  204. - Total locations examined: [Number]
  205. - High severity vulnerabilities: [Number]
  206. - Medium severity vulnerabilities: [Number]
  207. - Low severity issues: [Number]
  208. - Requires manual review: [Number]
  209. ## High Severity Vulnerabilities
  210. ### [Number]. [Component/Function] - [Vulnerability Type]
  211. **File**: `path/to/file.tsx:123`
  212. **Description**:
  213. **Impact**:
  214. **Data Flow**:
  215. **Source**:
  216. **Sink**:
  217. **Missing Validation**:
  218. **Confidence**: [High/Medium/Low]
  219. **Verification Status**: [Static data flow established / Requires dynamic verification / Dynamically verified separately]
  220. **Reproduction Notes**: [Clearly label theoretical steps versus steps actually executed]
  221. **Vulnerable Code**:
  222. **Fix / Recommendation**:
  223. ## Medium/Low Severity Vulnerabilities
  224. [Same format]
  225. ## Requires Manual Review
  226. [Same format]
  227. ## Search Results Summary
  228. Matches are review leads, not confirmed vulnerabilities.
  229. | Layer | Focus | Matches Found | Vulnerabilities |
  230. |-------|-------|---------------|-----------------|
  231. | 1 | DOM/HTML sinks | X | X |
  232. | 2 | Attr/event sinks | X | X |
  233. | 3 | URL/navigation & validation bypass | X | X |
  234. | 4 | Config/content models & JSON-in-script | X | X |
  235. | 5 | Props spreading/gadgets | X | X |
  236. | 6 | Untrusted sources + postMessage sender | X | X |
  237. | 7 | Prototype pollution | X | X |
  238. | 8 | JS execution sinks | X | X |
  239. | 9 | CSS/style sinks | X | X |
  240. | 10 | SVG/XML | X | X |
  241. | 11 | Markdown/pipelines & mXSS | X | X |
  242. | 12 | Framework HTML rendering & trust hooks | X | X |
  243. | 13 | Trusted Types & CSP | X | X |
  244. | 14 | Framework attribute binding & client template injection | X | X |
  245. ```
  246. ## High-Priority Review Signals
  247. Treat the following patterns as review leads, NOT automatic vulnerabilities. Confirm attacker control, a reachable security-sensitive sink, missing context-appropriate defenses, and impact before assigning severity:
  248. - `window.open(variable)` with attacker-influenced input and no sink-appropriate protocol validation
  249. - `href/src/action/formAction={variable}` with attacker-influenced input and no validation appropriate to the element and URL context
  250. - `history.pushState/replaceState` with an attacker-controlled URL: audit subsequent navigation, routing, and rendering; do not report the History API call alone as XSS
  251. - `location = variable` / `location.href = variable` with attacker-influenced input and no context-appropriate validation
  252. - **Hostname-only URL validation** (`new URL(url).hostname === '...'` without protocol validation) when the URL reaches a navigation sink
  253. - `{...props}` on `<a>` / `<iframe>` / URL-handling components when an attacker can control forwarded security-sensitive props
  254. - `dangerouslySetInnerHTML` with untrusted HTML and no verified context-appropriate sanitization path
  255. - `innerHTML/outerHTML/insertAdjacentHTML/document.write/DOMParser/setHTMLUnsafe` with untrusted data and no context-appropriate defense
  256. - `eval/new Function/setTimeout(string)/setInterval(string)` influenced by untrusted input
  257. - `setAttribute('on*', ...)` or dynamic event handler construction influenced by untrusted input
  258. - `setAttribute('href'|'src'|'srcdoc', userInput)` without validation appropriate to the destination context
  259. - Configuration objects (linkExpression/url/href/html/markdown/template) flowing to security-sensitive sinks
  260. - `sandbox="allow-scripts allow-same-origin"` when the embedded document is same-origin with the parent and can run attacker-controlled script; assess other origin combinations separately
  261. - `Object.assign({}, userData)` / deep merge with an attacker-controlled `__proto__`, `prototype`, or `constructor` path: identify the affected object/prototype and prove a usable gadget rather than assuming global prototype pollution or XSS
  262. - Attacker-influenced data in `<script>` JSON blocks without `<`-escaping (`</script>` breakout)
  263. - Sanitizer output unsafely re-parsed, transformed, or concatenated before insertion (mXSS); separately, `ALLOW_DATA_ATTR: true` on framework-bound markup only when the exact Layer 14 binding/compilation chain is present
  264. - `postMessage(sensitiveData, '*')` when the target window can be navigated or controlled by an untrusted origin
README.md · README · 102 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # xss-audit
  2. Comprehensive XSS vulnerability detection skill with 14 layers of checks for React/TypeScript/JavaScript codebases (static audit). Use when the user wants an in-depth XSS audit with broad static coverage, including SVG, MathML, CSS injection, markdown pipelines, mXSS/sanitizer bypass, JSON-in-script injection, URL validation bypass, and Trusted Types analysis. Outputs report to xss-audit-report.md.
  3. > Static analysis only. A search match is not a confirmed vulnerability.
  4. ## Background
  5. This skill comes from my hands-on work in real-world bug bounty
  6. programs. Over the course of one year, I used it in my day-to-day
  7. audit workflow and refined it continuously based on what worked
  8. and what missed. That workflow helped me identify dozens of XSS
  9. vulnerabilities that were awarded bounties.
  10. During the same period, I was ranked in Microsoft's MSRC Security
  11. Researcher Leaderboard (quarterly Top 10) for four consecutive
  12. quarters — 2025 Q3 #4, Q4 #7, 2026 Q1 #6, Q2 #10
  13. ([leaderboard](https://msrc.microsoft.com/leaderboard), [my profile](https://x.com/SecBoxer)).
  14. I'm sharing it so others can adapt the same review process to
  15. their own audits.
  16. ## Installation
  17. Copy this directory into your agent's skills directory:
  18. ```text
  19. <skills-directory>/xss-audit/SKILL.md
  20. ```
  21. ## Usage
  22. ```text
  23. /xss-audit
  24. /xss-audit src/
  25. ```
  26. Or use `$` if that is your agent's skill syntax:
  27. ```text
  28. $xss-audit
  29. $xss-audit src/
  30. ```
  31. ## What it checks
  32. The 14 review layers cover:
  33. 1. DOM and HTML injection: `innerHTML`, `outerHTML`, `insertAdjacentHTML`, `document.write`, `DOMParser`, `setHTMLUnsafe`, shadow DOM, and React `dangerouslySetInnerHTML`.
  34. 2. Attributes and event handlers: dynamic `on*` handlers, `href`, `src`, `srcdoc`, `action`, `formaction`, `style`, and JSX props that forward attacker-controlled values.
  35. 3. URLs and navigation: `window.open`, `location`, router navigation, protocol allowlists, hostname and substring validation errors, parser normalization, and downstream use of History API state.
  36. 4. Configuration and JSON-in-script: SSR bootstrap data, hydration state, JSON-LD, rich-text configuration, and `</script>` breakout caused by unsafe serialization.
  37. 5. Props spreading and gadget components: untrusted props forwarded to anchors, iframes, URL-handling components, and dynamic attributes.
  38. 6. Untrusted sources and messaging: URL data, API responses, cookies, storage, IndexedDB, referrer, `postMessage`, `BroadcastChannel`, and `MessageChannel`, including origin, source, schema, and target-origin checks.
  39. 7. Prototype pollution chains: unsafe merge, setter, and assignment paths that can influence a security-sensitive XSS gadget.
  40. 8. JavaScript execution: `eval`, `new Function`, string timers, dynamically created scripts, Blob/ObjectURL execution, and worker script imports.
  41. 9. CSS and style injection: `cssText`, `setProperty`, `insertRule`, CSS-in-JS interpolation, external CSS URLs, and legacy browser-specific execution mechanisms where relevant.
  42. 10. SVG, MathML, and XML: namespace-aware element creation, `xlink:href`, animation events, `foreignObject`, `annotation-xml`, and namespace confusion.
  43. 11. Markdown, sanitizers, and mXSS: Markdown renderers, DOMPurify, sanitize-html, resolved versions, effective configuration, double parsing, unsafe post-sanitization transforms, and output-context mismatches.
  44. 12. Framework rendering and trust hooks: Vue `v-html`, Angular trust bypasses, Svelte `{@html}`, Lit `unsafeHTML`, and direct DOM writes that bypass framework protections.
  45. 13. Trusted Types and CSP: enforcement, violations, policy configuration, and defense-in-depth gaps without treating browser defenses as proof of safety.
  46. 14. Framework binding and template injection: KnockoutJS, WinJS, Alpine.js, AngularJS, Vue, Angular, Ember, and Handlebars paths where attacker-controlled attributes or template source survive sanitization and reach binding or compilation.
  47. See [`SKILL.md`](SKILL.md) for the complete audit procedure and validation rules.
  48. ## Output
  49. The skill writes `xss-audit-report.md` and uses a timestamped filename if that report already exists.
  50. The report includes:
  51. - Audited paths, exclusions, and unread files.
  52. - An executive summary with severity counts and manual-review counts.
  53. - High, medium, and low severity findings with supporting evidence.
  54. - A separate manual-review section for incomplete or unconfirmed data flows.
  55. - A per-layer search summary that distinguishes pattern matches from confirmed vulnerabilities.
  56. Each finding documents:
  57. - File and line location, description, and impact.
  58. - Source, sink, data flow, and missing validation or sanitization.
  59. - Vulnerable code and a concrete fix recommendation.
  60. - Confidence and verification status.
  61. - Reproduction notes that clearly distinguish theoretical steps from steps actually executed.
  62. See the [fictional sample report](examples/sample-report.md). It demonstrates the format without claiming to be the result of a real audit.
  63. ## Limitations
  64. Static analysis can produce false positives and false negatives, especially for dynamic runtime behavior, build-time transforms, excluded code, and framework-specific execution timing. Review exclusions and verify findings before relying on them. No coverage is guaranteed.
  65. Generated reports may contain sensitive paths, source code, internal domains, or credentials. Review and sanitize them before sharing.
  66. ## Disclaimer
  67. Use this project only on code and systems that you own or have permission to assess. You are responsible for how you use it and for complying with applicable laws, policies, and third-party terms.
  68. The project is provided "as is", without warranty of any kind. To the extent permitted by applicable law, the authors and contributors are not liable for damage arising from its use. See [`LICENSE`](LICENSE) for the full licensing, warranty, and liability terms.
  69. ## License
  70. [MIT](LICENSE)

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.