Repository navigation
loader: keep mapped DLLs inside the title directory - #2672
Rickeal-Boss wants to merge 2 commits into
Conversation
|
Reviewed: two-layer check is right — |
|
Independent verification of #2672 (loader: keep mapped DLLs inside the title directory) PR head Environment: Windows 11 Pro 10.0.26200 (symlink creation is permitted for this user), rustc 1.98.1, CPU only, Tests/clippy vs baseline. Bug in the test (not in the fix). The test links Negative control (scratch, not committed). With the Diff review. The lexical check (a single Limits: no game files; junctions ( AI-assisted: independent verification by Claude Code / Claude Sonnet 5.5, run on behalf of oni-swr. Claims for #1633. |
|
Independent Windows 11 verification and code review of Verification (
|
|
Automated triage for the maintainers. The guard in Generated by Claude Code |
ff4c92a to
ac4181e
Compare
Summary
Scope. This guards static PE import names. The runtime path ProblemIn let name = name.to_ascii_lowercase();
let path = dirs.0.join(&name);
if !seen.insert(name.clone()) || !wanted(&name) || !path.is_file() {
return Ok(());
}
Reachability. The import table comes from the title's own PE files - the Change
Behaviour change worth calling out: a DLL deliberately symlinked or Known limitation: the path is canonicalised for the check but loaded through the original path, so there is a small check/use window. Closing it would mean loading from the canonicalised path; that is deliberately left out of this focused PR. Junctions ( TestsSynthetic import names only, no game data, no binaries:
A negative control with the guard removed fails VerificationTo run on the pinned toolchain (MSVC build tools, Windows):
Independent Windows 11 verification (rustc 1.98.1 MSVC) is reported in the WhatReject static PE import DLL names that would escape the title directory, and TestedThe symlink-fixture fix is pushed to the branch; CI on the new head is the Claim: #1633 |
|
Thanks for the triage, and thanks to @kotekompotek @oni-swr @Marvisak and @fuzeofficlal for the independent Windows verification. All three of you
The description now states the scope explicitly: this guards static PE CI on the new head is the authoritative result - it is green, could Prepared with AI assistance (Chinese Model); reviewed and conducted by Rickeal-Boss. |
Summary
map_dlltakes the DLL name straight from the PE import descriptor and joinsit onto the title directory. A crafted import name can leave that directory or
supply an absolute path, so the loader would read and prepare an image from
outside the folder the user supplied. This PR rejects such names at the entry
point. One file, no runtime behaviour change for valid imports.
Problem
In
crates/victory-loader/src/windows.rs:142-159(unchanged on currentmain,13f91cae):nameis only lowercased...\..\evil.dllresolves outsidedirs.0, andC:\Windows\System32\version.dllis absolute —Path::joindiscards the basefor an absolute path.
wantedis applied to the unsanitised name, so the hostpolicy cannot distinguish either case. Callers in
apps/victory/src/run.rspass
dirs.0as the title directory. The documented contract is that everymapped DLL sits beside the title executable.
Reachability. The import table comes from the title's own PE files - the
files the user supplies. A damaged or hostile dump reaches this code with no
special privilege; this is a boundary check on user-supplied input, not a
synthetic overflow case.
Change
ParentDir,RootDirorPrefixcomponent, and anyname whose
Path::file_name()is not the whole name. Keep the existingASCII-lowercase normalisation so
wanted,seenand theloadedkey seeexactly the same string as before for valid imports.
starts_with(canonicalise(title_dir))before reading it. This also coversjunctions and symlinks that a lexical check would miss.
seen,wantedand theloadedentry, so arejected name cannot poison the dedup set.
!path.is_file()path); it does not abort the load.
Tests
Synthetic import names only, no game data:
..\..\evil.dll,..\\evil.dll,sub/evil.dll,C:\Windows\System32\version.dlland a UNC/verbatim prefix are refused.
kernel32.dlland a mixed-case equivalent still resolve to the same key.canonicalise check (Windows test; skipped elsewhere).
Verification
To run on the pinned toolchain (MSVC build tools, Windows):
cargo test -p victory-loader --lockedcargo clippy --workspace --all-targets --all-features --locked -- -D warningscargo xtask policy— all files okNot run here: no Rust toolchain / Windows-only project in this environment;
CI should cover the above.
windows.rsis untouched by any open PR in the300-PR corpus checked at 17:00 UTC (max #2616), so this should be
conflict-free. #2595 edits
victory-pe/src/image.rs, a different crate.What
Reject import DLL names that would escape the title directory, and verify the
resolved path before reading it. See
## Problemand## Changeabove for theexact entry point and the checks.
Tested
Not run here: no Rust toolchain / Windows-only project in this environment.
See
## Verificationfor the commands; synthetic names only, no title files.Claim: #1633
NEW-<id>.Synthetic names only, no game data, no binaries (per
docs/asset-policy.md).Prepared with AI assistance (Chinese Model); reviewed and conducted by Rickeal-Boss.