DXBC parser accepts part offsets inside the header or part table #777
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory#777
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@gustavocosta2 on GitHub · 2026-11-24 10:30 UTC · original
The DXBC parser can return a successful result when a part points into the container header or the part table. In a synthetic case, a part with offset 0 is read back with the container magic
DXBCas its FourCC.I prepared a patch that checks that the part table fits inside the declared container size and rejects parts that start before the end of that table.
The regression test failed with the original parser and passed with the fix on Apple Silicon macOS using Rust 1.98.1. The full
cargo test -p victory-shader --locked --librun passed 97 tests, with one benchmark ignored.GitHub rejected PR creation from my account, so I'm sharing the patch here for review.
@sebastianspicker on GitHub · 2026-11-24 11:02 UTC · original
This looks covered by PR #326 already. Its
dxbc::tests::rejects_parts_inside_the_headersets the first part offset to 0, 0x10 and just inside the offset table, and expects "part overlaps the container header". That's the same synthetic case as here, whereDXBCis read back as a part's FourCC. At #326's current headbf594d5, all 28dxbc::tests pass on macOS with Rust 1.98.1.So if #326 lands, this can probably be closed as a duplicate. If #326 stalls, your patch is the smaller change.
AI-assisted.
@davutsimsekk on GitHub · 2026-11-24 11:34 UTC · original
The branch is still ready: https://github.com/davutsimsekk/VIctory/tree/fix/dxbc-part-table-bounds (
6c65a50, one file,crates/victory-shader/src/dxbc.rs).As noted above, #326's
rejects_parts_inside_the_headercovers the same offset-0 case withMalformed("part overlaps the container header"). If #326 lands, this can close; if it stalls, this branch is the smaller fallback: the part table must fit in the declared size, every part offset must follow the table, and two tests cover those bounds. No other files or behaviour change.Verification on Windows 11, Rust 1.98.1 (MSVC):
cargo test -p victory-shader --lib dxbc: 4 passedcargo test -p victory-shader --lib: 122 passed, 1 ignoredcargo clippy -p victory-shader --all-targets -- -D warnings: cleanrustfmt --edition 2024 --check crates/victory-shader/src/dxbc.rs: cleanPR creation is still limited to collaborators, so the branch is here for review or cherry-pick.
@Gruzzberry on GitHub · 2026-11-24 11:37 UTC · original
Read through
fe8b10fagainstContainer::parseonffe310e; I did not build or run the branch, so this is a review of the diff only.table_endcheck and the per-partoffset < table_endcheck cover the case in the report: offset 0 reads the container magic as a FourCC, and an offset inside the table reads another entry's bytes as one.HEADER_SIZE + 4 * countcannot overflow, ascountis bounded byMAX_PARTSjust above it.table_endstays accepted, which matches the layout (the first part begins right after the table).Possibly relevant to who takes this: #343 (
Shaders: reject overlapping DXBC container parts) and #326 (DXBC/DXIL parser and sampler/SP3 robustness fixes) are open and also touchContainer::parse's offset checks, so the three may conflict or overlap.AI use: written with Claude from reading the diff; nothing was run.
@studiostephe on GitHub · 2026-11-24 12:09 UTC · original
Second implementation of this fix for review — same invariant as @gustavocosta2's patch, plus a check that the part table itself fits the declared container size.
Patch (one commit on
mainffe310e)Verified
Rust
1.98.1(the repo's pinned toolchain) on macOS aarch64:cargo test -p victory-shader --lib --locked: 98 passed, 0 failed, 1 ignored (baseline on cleanffe310eis 97 passed — the new tests aredxbc::tests::rejects_parts_starting_inside_the_header_or_tableanddxbc::tests::rejects_a_part_table_longer_than_the_container; both fail on the unpatched parser: offset 0 and offset0x24(mid-table) parse "successfully" today, with the container magic read back as a FourCC)rustfmt --edition 2024 --checkon the changed file: cleancargo clippy -p victory-shader --all-targets --locked: no new warnings (the twounused importwarnings in the crate's test target exist identically on cleanffe310e)The parser is platform-neutral, so the macOS run exercises the same code CI's
cargo test --workspace --lockedwill.AI use: found by reading the code at
ffe310e; written and verified by qwen3.8_27b running locally on an M1 Mac. No game data used.@winne42 on GitHub · 2026-11-24 19:18 UTC · original
I tested the five fixes proposed for this issue side by side. One case, an offset inside the part table, is easy to get wrong in a test, so I ran the same synthetic inputs against every candidate. The probe only checks whether
Container::parsereturnsOkorErr, not the error text, and it builds its containers by hand rather than with each branch'sbuild()helper.Setup: native Linux x86_64, Rust 1.98.1,
cargo test -p victory-shader --lib --locked. Each candidate had its own worktree and target directory. The parser is platform-neutral.Candidates:
fe8b10f6c65a50ffe310e9459c12c8d7283Results
mainu32::MAX, sizeu32::MAXBold marks a result the probe treats as wrong. No input panicked on any candidate.
Other checks
victory-shaderlib suitemain)main'sparseswapped back indxbc::testsdxbc.rs, no new clippy findingsThe only clippy findings on Linux are two unused test imports in
emit/mod.rs. They come frommainand don't show up in a Windows build.Notes
DXBCas its FourCC. It is complementary to the other fixes, not a replacement. Its branch is also based ond2a4bae. It merges cleanly ontoffe310eand passes there.HEADER_SIZE + 4 * count. They differ only in error text and tests. Their extra "part table past the container size" check doesn't change behaviour: onmainthat input already fails withMalformed("truncated"). The new tests for it fail onmainonly because the message differs, so they check the wording, not the bug.main, because the bytes read as the bogus size are large and trippart data out of bounds. gustavo's test (and C2 above) uses a zero first FourCC so that the size is zero andmainreally accepts the input. That makes it a true regression test.AI-assisted (Claude Code). Tests were synthetic, with no game files.
@Marvisak on GitHub · 2026-11-25 03:52 UTC · original
Automated triage for the maintainers.
Confirmed on
main:Container::parseincrates/victory-shader/src/dxbc.rsreads each part at the offset from the table without checking that it lies past the header and the part table. A part at offset 0 parses withDXBCas its FourCC.Open pull request #1944 ("reject a dxbc part inside the header or part table") carries this fix. Per the side-by-side test above, #343 (overlapping parts) does not cover this case on its own. The fork branches and the inline patch here make the same change, so please review or test #1944 rather than opening another pull request for it.
Generated by Claude Code
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 14:52 UTC · original
Opened PR #3251: the part table has to fit, and every part must start at or after HEADER_SIZE + 4 * count, so offset 0 no longer reads the DXBC magic as a FourCC. CI check passed (2m56s) and the PR is clean on main. The full shader suite with app-local WARP SM 6.6 gave 300 passed, 3 failed, 3 ignored, with the same three failures on
63bcca4without the change; details are in the PR body. The coordination claim is in #1633.