Implements an XSS context analyzer (xss_context) that integrates with nuclei’s existing fuzzing pipeline, following the same pattern as the time_delay analyzer.
[XSS_CANARY] with a unique canary string appended with XSS-critical characters (<>"'/) to detect reflection and character survivalgolang.org/x/net/html tokenizer to classify where the canary is reflected into one of 8 context types:
HTMLText — between HTML tagsAttribute — inside a quoted attribute valueAttributeUnquoted — inside an unquoted attribute valueScript — inside a <script> block (not in a string)ScriptString — inside a JavaScript string literalStyle — inside a <style> blockHTMLComment — inside an HTML commentNone — no actionable context<, >, ", ', /) survive server-side encodingNew files:
pkg/fuzz/analyzers/xss/types.go — context types, character set, event handler mappkg/fuzz/analyzers/xss/context.go — HTML tokenizer-based context detectionpkg/fuzz/analyzers/xss/analyzer.go — main analyzer with canary injection, replay, and verificationpkg/fuzz/analyzers/xss/context_test.go — 30+ test cases and 2 benchmarksModified files:
pkg/fuzz/analyzers/analyzers.go — added ResponseBody, ResponseHeaders, ResponseStatusCode to Options; made random thread-safepkg/protocols/http/http.go — blank import to register the xss analyzerpkg/protocols/http/request.go — pass HTTP response data to analyzerpkg/protocols/http/request_fuzz.go — initialize nil Parameters map for canary storagefuzzing:
- part: query
type: replace
fuzz:
- "[XSS_CANARY]"
analyzer:
name: xss_context
/claim #5838
🤖 Generated with Claude Code
New Features
Tests
Refactor
dejan1007
@dejan1007
ProjectDiscovery
@projectdiscovery