Fixes four bugs in DetectReflections (pkg/fuzz/analyzers/xss/context.go) identified in #7086.
javascript: URIs misclassified as ContextAttributeRoot cause: The attribute-scanning loop only upgraded the context to ContextScript for event-handler attributes (onclick, onerror, .). URL-type attributes (href, src, action, formaction, data, poster, ping) whose value begins with javascript: were left as ContextAttribute.
Impact: The analyser selected HTML attribute break-out payloads instead of JavaScript payloads, causing false negatives on javascript:-URI XSS.
Fix: Added isURLAttribute() and hasJavaScriptScheme() helpers. hasJavaScriptScheme strips leading whitespace/control chars (matching browser normalisation) and performs a case-insensitive prefix check.
<script type="application/json"> treated as executable JavaScriptRoot cause: The case "script": branch set inScript = true unconditionally, before reading the tag’s attributes.
Impact: Marker reflections inside non-executable script blocks (application/json, application/ld+json, text/template, .) were reported as ContextScript, producing false positives and wrong payloads.
Fix: Added isExecutableScriptTag(rawToken) which parses the type= attribute from the raw token string. Only standard executable MIME types (text/javascript, application/javascript, module, and their variants) set inScript = true.
Root cause: if !strings.Contains(body, marker) used the original-case marker for the early-exit guard, while every subsequent check used markerLower.
Impact: Servers that transform the canary (e.g. all-uppercase) triggered the early return, silently missing the vulnerability.
Fix: Changed the guard to strings.Contains(strings.ToLower(body), markerLower).
srcdoc attribute classified as ContextAttributeRoot cause: No special handling for srcdoc.
Impact: srcdoc attribute values are parsed by browsers as complete HTML documents; injection is HTML injection, not attribute injection. Wrong context ? wrong payload selection.
Fix: srcdoc reflections are now classified as ContextHTMLText.
40+ unit tests added to context_test.go covering:
JAVASCRIPT:, leading-whitespace javascript: URIs, JAVASCRIPT: in action/formactionsrcdoc context classificationBestReflection priority, detectScriptStringContext quote tracking/claim #7086
Andrew Boehner
@Boehner
Bishnu Prasad Sahu
@mebishnusahu0595