Skip to content

ig_detect_xss with a script URL check (TASKS 1.2) - #19

Merged
hightemp merged 3 commits into
mainfrom
core/detect-xss
Oct 22, 2026
Merged

hightemp merged 3 commits into
mainfrom
core/detect-xss

Conversation

@hightemp

Copy link
Copy Markdown
Owner

Summary

  • ig_detect_xss(s, len, res): same contract as ig_detect_sqli. The fingerprint says what fired: html (libinjection_xss) or url (our check).
  • Our check (libinjection misses a bare javascript:alert(1)): the whole value is a script URL — leading C0 controls/spaces skipped, tab/LF/CR inside the scheme ignored (WHATWG), case-insensitive; javascript:/vbscript: only with a code character (, ` or = after it (so "JavaScript: The Good Parts" stays clean); data: with text/html, image/svg+xml, application/xhtml+xml.
  • A scheme match beats a libinjection ERROR; otherwise ERROR stays an error.
  • PRD (both languages): decision to keep libinjection (risks table, FR-2.2) with review against corpus metrics in 1.8; note 1.2.
  • Fuzz target fuzz_detect_xss with seeds.

Verified locally: unit (gcc, clang + ASan/UBSan, CentOS 7 gcc 4.8.5), clang-tidy, cppcheck, clang-format, phpt 7.0/8.5 ZTS, 20 s fuzzing per target (1.0M / 0.5M executions).

TDD

  • red c282691: tests/unit/test_detect_xss.c — 10 HTML attacks, 17 script-URL attacks, 19 benign values, NUL, NULL arguments, partial prefixes.
  • green: implementation (one test payload fixed: data:image/svg+xml,<svg/> is correctly caught as html first, replaced by a base64 form).

🤖 Generated with Claude Code

hightemp and others added 3 commits October 22, 2026 17:23
…TASKS 1.2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
libinjection_xss covers injection into HTML; a value that is a script URL
(javascript:, vbscript:, HTML/SVG data:) is checked by us. The fingerprint
says which one fired.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hightemp
hightemp merged commit a700128 into main Oct 22, 2026
38 checks passed
@hightemp
hightemp deleted the core/detect-xss branch October 22, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant