Shaders: reject a dxbc part inside the header or part table #1944

Open
github-bot wants to merge 1 commit from github-bot/gh-1944 into main AGit
Owner

@⁠imjustprism on GitHub · 2026-11-25 01:32 UTC · original
imjustprism:fix/dxbc-part-inside-table → main · +18 −0 · 1 files · 1 commits · open

a part offset that points into the container header or the offset table was accepted: offset 0 came back as a part with the container magic as its fourcc. parts follow the table, so an offset before its end is now refused as malformed. #343 refuses parts that overlap each other, which does not catch this.

the reporter had the same check on a fork and could not open a pull request; this one is written against current main, with a test for the header case and the table case. both fail without the check.

fixes #777

**@⁠imjustprism** on GitHub · 2026-11-25 01:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/1944) `imjustprism:fix/dxbc-part-inside-table` → `main` · +18 −0 · 1 files · 1 commits · open a part offset that points into the container header or the offset table was accepted: offset 0 came back as a part with the container magic as its fourcc. parts follow the table, so an offset before its end is now refused as malformed. #343 refuses parts that overlap each other, which does not catch this. the reporter had the same check on a fork and could not open a pull request; this one is written against current main, with a test for the header case and the table case. both fail without the check. fixes #777
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:49:36 +00:00
Author
Owner

@⁠Headache3318 on GitHub · 2026-11-25 01:35 UTC · original

Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head cba87ae applied cleanly onto current main ccfb029.

  • cargo test -p victory-shader --locked: 145 passed, 0 failed, 2 ignored. All tests pass.
  • cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings: 4 errors in test code (unused imports, unused variable, dead field rovs), but these are pre-existing on main — they fail identically on ccfb029 without this PR. The PR introduces no new clippy warnings.

Not tested: Windows MSVC build, the title itself. AI-assisted.

**@⁠Headache3318** on GitHub · 2026-11-25 01:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/1944#issuecomment-7149722417) Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head `cba87ae` applied cleanly onto current `main` `ccfb029`. - `cargo test -p victory-shader --locked`: 145 passed, 0 failed, 2 ignored. All tests pass. - `cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings`: 4 errors in test code (unused imports, unused variable, dead field `rovs`), but these are **pre-existing on main** — they fail identically on `ccfb029` without this PR. The PR introduces no new clippy warnings. Not tested: Windows MSVC build, the title itself. AI-assisted.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 08:20 UTC · original

Automated triage for the maintainers.

Merge candidate.

Container::parse in crates/victory-shader/src/dxbc.rs now refuses a part whose offset lies before the end of the offset table (HEADER_SIZE + 4 * count). This fixes #777, which is labelled confirmed.

On main, offset 0 is accepted as a part tagged DXBC. The new test covers both the header case and the table case and checks the exact error. It uses the existing build helper. The table itself is already bounds-checked by u32_at on the slice cut to the container's size, so this is the remaining gap from #777.

CI: check passes.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 08:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/1944#issuecomment-7156905434) <!-- victory-triage v1 head=afc4f79123a7c0adecdabb004db084ce4ae9c79a verdict=merge-candidate at=2026-11-25T08:20:21Z --> Automated triage for the maintainers. **Merge candidate.** `Container::parse` in `crates/victory-shader/src/dxbc.rs` now refuses a part whose offset lies before the end of the offset table (`HEADER_SIZE + 4 * count`). This fixes #777, which is labelled confirmed. On `main`, offset 0 is accepted as a part tagged `DXBC`. The new test covers both the header case and the table case and checks the exact error. It uses the existing `build` helper. The table itself is already bounds-checked by `u32_at` on the slice cut to the container's size, so this is the remaining gap from #777. CI: `check` passes. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-25 11:16 UTC · original

Offline measurement on a retail dump

Result: no count change against main.

I merged head afc4f791 onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

**@⁠sinan-cmyk** on GitHub · 2026-11-25 11:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/1944#issuecomment-7160827756) ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head afc4f791 onto `main` 940d32f (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 23,918 on `main`, 23,918 with this PR. No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 01:02 UTC · original

Code review and Windows 11 verification at head afc4f79123a7 merged cleanly onto main (63bcca43c6a0):

  • Code review (crates/victory-shader/src/dxbc.rs:88-95):
    • Validates count <= MAX_PARTS (256) before computing table_end = HEADER_SIZE + 4 * count (bounded <= 1056, overflow-free), lets u32_at reject truncated tables, and rejects any part with offset < table_end ("part inside the header or table"). Subsequent data.get(...) bounds checking remains intact.
  • Verified (Windows 11, Rust 1.98.1):
    • cargo xtask policy: 191 files ok; cargo clippy --locked -p victory-shader --tests -- -D warnings: 0 warnings
    • victory-shader --lib -- dxbc::: 3/3 passed (including rejects_a_part_inside_the_header_or_the_part_table).

LGTM.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 01:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/1944#issuecomment-7179378560) Code review and Windows 11 verification at head `afc4f79123a7` merged cleanly onto `main` (`63bcca43c6a0`): - **Code review (`crates/victory-shader/src/dxbc.rs:88-95`)**: - Validates `count <= MAX_PARTS` (`256`) before computing `table_end = HEADER_SIZE + 4 * count` (bounded `<= 1056`, overflow-free), lets `u32_at` reject truncated tables, and rejects any part with `offset < table_end` (`"part inside the header or table"`). Subsequent `data.get(...)` bounds checking remains intact. - **Verified (Windows 11, Rust 1.98.1)**: - `cargo xtask policy`: `191 files ok`; `cargo clippy --locked -p victory-shader --tests -- -D warnings`: 0 warnings - `victory-shader --lib -- dxbc::`: **3/3 passed** (including `rejects_a_part_inside_the_header_or_the_part_table`). LGTM.
github-bot changed title from reject a dxbc part inside the header or part table to Shaders: reject a dxbc part inside the header or part table 2026-11-26 09:03:12 +00:00
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 03:05 UTC · original · approved these changes

Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, cargo test -p victory-shader --locked.

145 passed / 0 failed / 2 ignored. DXBC parts inside the header/part table rejected (+1 test) — container-validation hardening against malformed shaders.

**@⁠catminou4** on GitHub · 2026-11-25 03:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/1944#pullrequestreview-6051251848) · **approved these changes** Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, `cargo test -p victory-shader --locked`. 145 passed / 0 failed / 2 ignored. DXBC parts inside the header/part table rejected (+1 test) — container-validation hardening against malformed shaders.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 13:24 UTC · original · approved these changes

Reviewed and verified afc4f79123a7 and merged onto origin/main (63bcca43; clean git merge-tree):

  • The lower-bound check in crates/victory-shader/src/dxbc.rs:86-95 is right: with count <= MAX_PARTS (256), table_end = HEADER_SIZE + 4 * count cannot overflow, and rejecting offset < table_end prevents parts from aliasing the DXBC header or offset table while keeping count == 0, offset == table_end, and zero-length part bodies valid. The new regression test covers both header and table offsets. (Existing offset + 4 / offset + 8 + size arithmetic could move to checked addition in a follow-up if 32-bit overflow-checked builds are targeted.)

Local verification: rustfmt --edition 2024 --check crates/victory-shader/src/dxbc.rs, xtask policy (182 files ok), cargo clippy -p victory-shader --all-targets (default and --all-features), dxbc:: tests (3 passed), and the merged non-GPU victory-shader unit suite (162 passed, 0 failed, 2 ignored) all pass.

LGTM.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 13:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/1944#pullrequestreview-6074902292) · **approved these changes** Reviewed and verified `afc4f79123a7` and merged onto `origin/main` (`63bcca43`; clean `git merge-tree`): - The lower-bound check in `crates/victory-shader/src/dxbc.rs:86-95` is right: with `count <= MAX_PARTS` (`256`), `table_end = HEADER_SIZE + 4 * count` cannot overflow, and rejecting `offset < table_end` prevents parts from aliasing the DXBC header or offset table while keeping `count == 0`, `offset == table_end`, and zero-length part bodies valid. The new regression test covers both header and table offsets. (Existing `offset + 4` / `offset + 8 + size` arithmetic could move to checked addition in a follow-up if 32-bit overflow-checked builds are targeted.) Local verification: `rustfmt --edition 2024 --check crates/victory-shader/src/dxbc.rs`, `xtask policy` (`182 files ok`), `cargo clippy -p victory-shader --all-targets` (`default` and `--all-features`), `dxbc::` tests (`3 passed`), and the merged non-GPU `victory-shader` unit suite (`162 passed, 0 failed, 2 ignored`) all pass. LGTM.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1944/head:github-bot/gh-1944'
git switch 'github-bot/gh-1944'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1944'
git switch 'github-bot/gh-1944'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1944'
git switch 'github-bot/gh-1944'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1944'
git switch 'main'
git merge --squash 'github-bot/gh-1944'
git switch 'main'
git merge --ff-only 'github-bot/gh-1944'
git switch 'main'
git merge 'github-bot/gh-1944'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1944
No description provided.