"---\nid: CROSS_SITE_SCRIPTING\nversion: 1\nseverity: high\n---\n\n# Cross-Site Scripting\n\nFind reflected, stored, and client-side paths where lower-trust data becomes\nexecutable browser content across a trust boundary. Cover app-owned HTML pages,\nserver templates, embedded app views, customer-facing pages, and operator UIs,\nnot only theme extensions. Prove the source, rendering context, victim, and\nreachable execution path; an HTML-looking string or raw-rendering API alone is\nnot a finding.\n\n## What to look for\n\n1. **Map producers and consumers.** Identify the actual web frameworks, template\n engines, versions, escaping defaults, and rendering helpers. Trace URL/query\n and form/JSON input, stored customer/merchant content, product/metafield data,\n imports, webhook fields, and third-party API responses to their renderers.\n For client-side flows, include location fragments, storage, DOM attributes,\n and `postMessage` data after examining sender/origin validation. A database\n read, authenticated route, or Shopify API response does not by itself make\n the contained user-authored data trusted.\n\n2. **Inspect server-rendered escape hatches.** Follow response builders, layouts,\n partials, and component wrappers into final HTML, including:\n - Express/React Router HTML responses assembled with strings, and custom\n server-side rendering or hydration/bootstrap data.\n - Rails `raw`, `html_safe`, and HTML/inline rendering; EJS `<%- ... %>`,\n unescaped Handlebars output, Django/Jinja `safe` or disabled autoescaping,\n and Blade/Twig raw output.\n - Markdown/rich-text renderers with raw HTML or unsafe link handling.\n Read the real helper and framework behavior. A bypass API is only a lead;\n constant HTML and correctly escaped dynamic text are not findings.\n\n3. **Follow browser-side rendering and execution.** Inspect DOM HTML writes,\n React `dangerouslySetInnerHTML`, Vue `v-html`, Svelte `{@html}`, Lit\n `unsafeHTML`, Angular trust-bypass APIs, and wrappers around these sinks.\n Also inspect dynamic script URLs, event handlers, `srcdoc`, and strings\n passed to browser `eval`, `Function`, or timers. Follow stored content from\n its original write to later preview, support, or admin views; do not stop\n at a safe first renderer. Coordinate these paths with the existing checks\n listed below instead of creating duplicate findings.\n\n4. **Evaluate the exact output context.** Determine whether input lands in HTML\n text, a quoted/unquoted attribute, a URL, JavaScript data/code, CSS, or a nested\n context. HTML text escaping is not sufficient for an event handler or a\n script/URL context. URL encoding a parameter is not scheme validation for an\n entire `href` or `src`. For JSON embedded inside an HTML `<script>` element,\n including non-executable JSON data blocks, verify that serialization prevents\n an HTML `</script>` breakout; `JSON.stringify` alone does not do this. Do not\n invent the same breakout for JSON served as an inert `application/json`\n response. Trace any later consumer that reparses it as HTML or code.\n\n5. **Verify defenses at the final sink.** Follow escaping, HTML sanitization,\n URL allowlists, framework autoescaping, Trusted Types policies, and any\n decoding or mutations after sanitization. Check actual configuration and\n context, not just a sanitizer's name. A custom sanitizer is not automatically\n vulnerable, and a library call is not automatically safe in every context.\n To report a bypass, explain the concrete construct that survives the defense\n and can execute in that renderer. Account for enforced CSP and sandboxing;\n do not assume a bypass. Missing CSP alone is not XSS, and HttpOnly cookies\n do not prevent script from acting with the victim's browser authority.\n\n6. **Establish a victim and authority boundary.** Identify who can supply the\n input, how another principal encounters it, the document's actual origin,\n and the actions or data script could reach there. An embedded app iframe\n does not inherit the Shopify Admin parent's origin or authority. Content\n executing in an isolated or sandboxed origin must not be described as\n executing in the parent without evidence. Intentional author-controlled\n HTML, self-XSS requiring the victim to paste code, and a merchant editing\n their own permitted storefront code are not automatically privilege\n escalation. Show a lower-trust writer reaching a more privileged reader,\n another user/tenant, or a surface where executable content is not authorized.\n\n## Coordinate with existing checks\n\nFollow the complete path even when it crosses surfaces, but report the same\nsource-to-sink vulnerability only once, under the most specific owning check:\n\n- `UNSAFE_INNERHTML`: DOM HTML writes and browser code-evaluation sinks.\n- `THEME_EXTENSION_XSS` / `LIQUID_UNSAFE_RENDER`: theme-extension Liquid output.\n- `TEXT_SETTING_HTML_SMUGGLING`: merchant text settings becoming active content.\n- `APP_PROXY_LIQUID_INJECTION`: values from verified app-proxy requests reaching\n active responses.\n- `SCRIPT_TAG_URL_INJECTION`: Shopify ScriptTag source URLs.\n- `ACTIVE_UPLOADS_AND_PRIVILEGED_PREVIEWS`: uploaded/imported active files and\n their privileged previews.\n\nDelegate only when the specialized check covers the complete source-to-sink\npath, not merely the response surface, and use that check's own provenance.\nUse `CROSS_SITE_SCRIPTING` for remaining paths, such as reflected server HTML,\nstored customer content in an operator template, unsafe hydration data, or\nactive URL/attribute output outside those specialized paths. Stored buyer\nreviews rendered in app-proxy HTML/Liquid responses remain here when the\ncontent comes from a separate submission endpoint rather than the verified\nproxy request. Do not suppress a distinct vulnerable sink just because the\nsame input is used elsewhere.\n\n## What to report\n\nUse the finding and execution schemas in agent checks, including this check's\nID and version. Each finding must include:\n\n- The controlling principal, entry point, victim interaction, and required access.\n- File/line evidence for input or persistence, transformations, render call,\n and final sink/template, including any ineffective defense.\n- The exact parser context and a minimal inert marker/example showing how data\n becomes executable content. Explain the execution mechanism; do not assume\n a `<script>` inserted via `innerHTML` executes like a parser-inserted script.\n- The affected origin and concrete authority exposed, without assuming access\n to parent frames, HttpOnly cookies, or unrelated tenants.\n- A context-appropriate fix: preserve autoescaping, render as text, serialize\n safely for HTML embedding, validate active URLs, or sanitize permitted HTML.\n\nDo not probe live stores, exfiltrate data, or persist active payloads in real\nmerchant content. Code-level evidence can establish the path. Do not report\nordinary autoescaped interpolation, text-node writes in non-executable elements,\nconstant markup, or adequately sanitized content. HTML injection without an\nexecutable path, server-side template execution, and unsafe redirects are not\nby themselves proof of XSS. Email/PDF output is not browser script execution\nwithout evidence of an affected active renderer.\n\nIf a missing producer, renderer, sanitizer implementation, or execution context\nprevents a conclusion, record an unresolved check with a reason code and\nmessage. Do not turn incomplete tracing into either a finding or a pass.\n\n## Optional reference\n\n[OWASP Cross Site Scripting Prevention Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html)\n\nWhen available, consult this reference for defensive techniques and remediation\nexamples. It supplements the evidence and reporting requirements above; a\ndeviation from its recommendations is not by itself a finding. If the reference\nis unavailable, continue using this prompt and repository evidence.\n",
0 commit comments