Repository navigation
fix(hang): refuse malformed H.264 codec fields (backport #6847) - #9256
Merged
Merged
Conversation
A non-ASCII byte in an avc1/avc3 profile field sliced the codec string inside a UTF-8 character and panicked the catalog parser. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated
marked this pull request as ready for review
November 21, 2026 00:40
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Approach: sound — rejects non-hex profile fields before the byte-offset slicing, so a non-ASCII character can no longer split a UTF-8 boundary and panic.
Reviewed changes
Reviewed the single commit against release.
- Hex validation in
H264::from_str— the field must now be exactly six bytes and all ASCII hex digits, which makes the[0..2],[2..4]and[4..6]slices safe. Malformed input returnsError::InvalidCodec. - Regression test —
malformed_hex_fields_are_invalidcoversavc1andavc3with non-ASCII characters at each field boundary, a leading+and non-hex letters.
claude-sonnet-5-5 | 𝕏
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
hang'sH264::from_stronreleasechecks the profile field's length in bytes and then slices it at byte offsets 2 and 4. A non-ASCII character in a remote catalog'savc1/avc3codec string (e.g.avc1.4Ψ01e) splits a UTF-8 character and panicsCatalog::from_slice/from_strin any consumer that parses it (GHSA-gj9x-g66f-6j3p). The fix landed onmainin moq-dev/moq#6847 but never reached a release: publishedhang0.21.24 still panics.Approach
Port moq-dev/moq#6847 unchanged: the field must be six ASCII hex digits. moq-dev/moq#7035's later rework changes the catalog API, so it stays on
main.The other catalog codec parsers on
releasedon't slice at unchecked byte offsets: H.265 slices at[1..]only after an ASCII first byte.Impact
avc1/avc3codec string is nowError::InvalidCodecinstead of a panic; ships as ahangpatch with the next release.Validation
malformed_hex_fields_are_invalidtest panics ath264.rs:55:46without the check, the reporter's location, and passes with it.Catalog::<()>::from_slice, run as a temporary test: nowErr(Json("invalid codec at line 1 column 54")).cargo test -p hang(120 pass) andnix develop -c just check origin/releasepass.Caused by
Alternatives
part.is_ascii(), the reporter's patch. Portingmain's stricter hex check keepsreleaseandmainthe same.Follow-ups
None.
Models
Size: XS
Implementer: Claude Code, claude-opus-5-5, unknown effort
(Written by Claude Opus 5.5)
🤖 Generated with Claude Code
Review
Rewritten by
quest reviewafter each round.Head: a2bf49b
Base: origin/release at 381b802
Risk: medium,
the base has no RISK.md to name what is always high or customer-facing, so every change is mediumClassified: medium by default
Reviewer: Codex, gpt-6.1-sol, medium effort
Session:
01a1fb8b-77eb-75b3-9003-ce3da27df9a9, round 1Score: 10/10,
Source review found that ASCII hexadecimal validation prevents UTF-8 slicing panics while preserving valid H.264 codec strings, with regression coverage for both prefixes and every field boundary; tests were not run as instructed.Rounds: 2; first round 2 (medium 2); findings 0: fixed 0, refuted 0, open 0
Findings: none