Skip to content

Fix four fuzzer-found over-reads and a leak in the filter, URL, and IDNA parsers - #499

Merged
xroche merged 1 commit into
masterfrom
fix-parser-fuzz-bugs
Jul 7, 2026
Merged

Fix four fuzzer-found over-reads and a leak in the filter, URL, and IDNA parsers#499
xroche merged 1 commit into
masterfrom
fix-parser-fuzz-bugs

Conversation

@xroche

@xroche xroche commented Jul 7, 2026

Copy link
Copy Markdown
Owner

libFuzzer harnesses over the pure hostile-input parsers turned up four pre-existing bugs, all reachable from crawled content: strjoker read a byte past an empty subject on a *(...) pattern; ident_url_absolute read past a bare file:// URL and copied an over-long path into the fixed fil[] (aborting through the htssafe guard); and the IDNA encoder leaked a segment buffer on malformed UTF-8. Each is a small bounds or cleanup fix to an internal parser, with no API or format change.

Tests: a new identurl self-test, empty-subject filter cases, and an IDNA malformed-encode check. The over-reads trap under ASan, the over-long URL aborts on any build, and the leak is caught by the fuzz PR's LeakSanitizer job.

@xroche
xroche force-pushed the fix-parser-fuzz-bugs branch 3 times, most recently from 559c88f to c675050 Compare July 7, 2026 13:15
…rsers

libFuzzer harnesses over the pure hostile-input parsers surfaced four
pre-existing defects, each reachable from crawled content:

- strjoker (htsfilters.c): a unique-match pattern like *(( forces max=1 even
  when the subject is empty, so the matcher recurses one byte past the subject's
  NUL. Clamp max to the subject length.
- ident_url_absolute (htslib.c): a bare file:// URL leaves the path pointer on
  the terminating NUL, and p[1] then reads past it. Short-circuit on *p == 0.
- ident_url_absolute (htslib.c): the length guard bounds only the host, so a
  short-host/long-path URL overruns fil[HTS_URLMAXSIZE*2] and trips the htssafe
  abort (a would-be overflow). Reject an over-long URL up front.
- hts_convertStringUTF8ToIDNA (htscharset.c): a malformed UTF-8 sequence in a
  multi-label host aborts the per-segment encode without freeing the segment
  integer buffer. Free it on the error path.

Tests: new identurl self-test drives ident_url_absolute (file:// and an
internally-built over-long URL, since the CLI caps arguments); filter gains
empty-subject cases; idna gains a malformed-encode probe. The two over-reads
and the abort are negative-controlled (they trap under ASan / abort on the
unpatched engine); the IDNA leak's deterministic control is the LeakSanitizer
fuzz job in the follow-up fuzzing PR.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
@xroche
xroche force-pushed the fix-parser-fuzz-bugs branch from c675050 to 9a63b4a Compare July 7, 2026 16:05
@xroche
xroche merged commit 15021cd into master Jul 7, 2026
15 checks passed
@xroche
xroche deleted the fix-parser-fuzz-bugs branch July 7, 2026 16:14
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