fix(crash): a report takes a folder's name out of a percent-encoded file:// URL too #3207
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3207
Loading…
Reference in a new issue
No description provided.
Delete branch "cuecuemoar/Longshot:fix/crash-redact-file-url"
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?
Summary
Crash reports, bug reports and the game's log as the builder copies it can keep the player's folder name when a line
holds a path as a
file://URL. There the name is percent-encoded (John%20Doe,jos%C3%A9orjos%c3%a9,Jane%23Doe), and the redaction rule matched only the name as it is on disk. A user name that begins the home folder'sown name (user
John, folderJohn Doe) also left the rest behind:<user>%20Doein a URL,<user> Doein a plainpath on another drive. The bug report is made for public issues, so the name leaked. On main:
Who { home: C:\Users\John Doe, user: John, folder: John Doe }turnsfile:///C:/Users/John%20Doe/xintofile:///C:/Users/<user>%20Doe/x.crash::redactnow reads a%XXescape (hex in either case) as the byte it stands for, both where it matches a nameand where it decides a name has ended, so
jos%C3%A9isn't taken for a user namedjos. A byte as written is triedfirst, so a name with a
%of its own (a%41b) still matches itself, and when that leads nowhere its escape is tried,so the same name in a URL (
a%2541b) comes out too. An escaped separator (%2F,%5C) counts as aseparator, so a path written whole into a URL's query comes out too. The user's name, the home folder's own name and
its 8.3 short name (
JOHNDO~1, which a URL holdingTEMPcan carry) are matched in one pass, the longest first. Crash reports, bug reports and the copied game log all gothrough
Who::redact/redact_bytes, so all three are covered.Read first:
builder/crates/crash/src/redact.rs:byte_at,match_at,name_ends,sep_before,names_out.Fixes #3199. It continues PedroRossi's #3184 (closed) and covers
BeanBot's L1–L3 there. PedroRossi is co-author for the test's starting point. See #1093.
Testing
Tested: Windows 10, RTX 4090, NVIDIA 617.42, runtime
rt-wt-3199-winbuilt from the headbbb839b1f(v3.2.0-333-gbbb839b1f), so the game ranwith this branch's builder (rebuilt with the review fix). Four headless runs through the control bridge, profile
test, about 60 s each (the same runs on df25a485b gave the same results before the review fix):HOS_INPUT_SAVEis inert withoutHOS_INPUT_RECORDand is printed in the game'svk: switches setline. Set to the real home folder, encoded as
file:%2F%2F%2FC:%2FUsers%2F<name>%2Fx, the copied log saysHOS_INPUT_SAVE=file:%2F%2F%2FC:%2FUsers%2F<user>%2Fx. Encoded asC%3A%5CUsers%5C<name>%5Cx, it saysHOS_INPUT_SAVE=%USERPROFILE%%5Cx. Main's rule leaves the name in both (checked on the same inputs). With everybyte of the name escaped (
%2F<%XX of each byte>%2Fx, the first letter escaped too), it saysfile:%2F%2F%2FC:%2FUsers%2F<user>%2Fx.%USERPROFILE%\AppData\Local\NVIDIA\GLCache,%USERPROFILE%\lsdev\builder-cache\...).HOS_CRASH_TEST=startwrote a crash record (diagnostics\bug-reports\pending\crash-*.txt) holding no paths.build.log).On this PC the user name and the home folder's name are the same plain ASCII name. So a literal
file:///C:/Users/<name>/is already redacted on main, and the longest-first half can't show here. Nor can a namewith a
%of its own (BeanBot's L1,%25). The unit test covers both.Checks:
cargo test -p crash: Linux (WSL) and Windows (MSVC, through the job queue), 36 passed each on the headbbb839b1f(and on df25a485b before). The new test fails on main
f8b543384in 17 of its 23 cases (its rows run against main'srule). The other 6 are controls that main already gets right: a name with a
%of its own, a name insidea longer one, and a plain path. Each part of the fix, undone in turn, fails its own cases: decoding, the decoded end
of a name, longest first, literal bytes first, the escape tried when the literal byte leads nowhere (
%25), theearly turn-down that lets an escape through (
%61na), the short name, the escaped separator before a name (and only anescaped one), and an escape matching a separator.
A cold review by a second agent (diff and test only) found that decoding every escape broke a name with a
%of itsown, which main redacted. That's fixed (literal first), and the review's other cases were added as rows.
BeanBot's L1: literal first never fell back to
%25, soa%2541bstayed. Fixed inbbb839b1f(the match goes back andtries the escape), with three rows in
65f57f102that fail onbedd5046f.cargo clippy -p crash --all-targets -D warnings(Linux and Windows) andcargo fmt --check: clean onbbb839b1f.cargo test --workspace --exclude modtool --locked(Linux, 12676b693 against base46ae5b43d; since then onlyredact.rschanged): 3481 passed. The 4 failuresare the same on main:
tools::tests::the_repository_s_lock_and_the_table_agree,one_copyinstalled_versions_reuse_their_own_builds_with_one_profile,a64 matches_llvm_mc(no llvm-mc here),build-compilea_windows_link_of_the_same_inputs_makes_the_same_bytes.cargo clippy -p crash --all-targets -D warningsandcargo fmt --check: clean.mise run test(tests/run_all.py --strict, Linux, head against base): 844 passed, 13 skipped on both df25a485b and base46ae5b43d. Thesame 52 files fail on both sides, and no file fails only here.
The 52 files that fail on main too, in this WSL setup
tests/f2i_immediate,tests/global_load_16,tests/native_suatom,tests/test_cloth_kernels.py,tests/test_cloth_loops.py,tests/test_cloth_step8.py,tests/test_coop_spirv.py,tests/test_curve_pass.py,tests/test_dead_targets_sweep.py,tests/test_default_point_size.py,tests/test_depth_sample_types.py,tests/test_dev_update.py,tests/test_dlssg.py,tests/test_draw_parameters.py,tests/test_drawn_page_map.py,tests/test_fsr4_tune.py,tests/test_image_arrays.py,tests/test_image_view_retry.py,tests/test_lens_eye_pass.py,tests/test_lifter.py,tests/test_lower_depbar.py,tests/test_lower_lds_after_sts.py,tests/test_lower_register_markers.py,tests/test_menu_hooks.py,tests/test_mesh_fallback_capacity.py,tests/test_mesh_fallback_layout.py,tests/test_mesh_first_types.py,tests/test_mesh_unreachable_outputs.py,tests/test_native_suatom.py,tests/test_no_game_title.py,tests/test_nonuniform_image_arrays.py,tests/test_present_acquire_ahead.py,tests/test_present_geometry_trace.py,tests/test_present_held_image.py,tests/test_present_image_free.py,tests/test_prof_clock.py,tests/test_program_answer_domains.py,tests/test_reshade_fx.py,tests/test_sim_turf_pools.py,tests/test_spirv_struct_identity.py,tests/test_sync_watch_event.py,tests/test_target_pool_cap.py,tests/test_target_retention.py,tests/test_tex_desc_memo.py,tests/test_texture_phi_dominance.py,tests/test_thinlto_tls.py,tests/test_turf_budget.py,tests/test_ui_renderer.py,tests/test_unsigned_image_types.py,tests/test_vk_draw_overhead_lean.py,tests/test_vk_tex_btree_get_fast.py,tests/test_wmma16_spirv_val.pyThe game runs above are on df25a485b, on main
46ae5b43d. The branch was then rebased onto mainf8b543384(headbedd5046f):git range-diffshows both commits unchanged, and main's 4 new commits touch nothing the crash crateuses (only
build-assetsinbuilder/).cargo test -p crashpasses again onbedd5046f. The review fix (65f57f102,bbb839b1f) changes onlymatch_at's search and the test's rows; the game runs above were repeated on it. Main's 3 commits sincef8b543384touch neither the crash crate norCargo.lock.Still to test:
JohnwithC:\Users\John Doe) would show thesecond half in a real report. The unit test models it, and no test PC needs it.
Measurements
Verdict: no cost: 1.4 ms less per 100,000 lines than main (a place where no name can begin is turned down before
the search). The rule runs on every line of the
game's log as the builder copies it.
Setup: WSL (Linux), i9-13900K;
a_hundred_thousand_lines_a_second_are_cheapin a release build (100,000 lines, onein ten with a path under the home), three runs each, interleaved.
f8b543384bbb839b1fEarlier, before the review fix: 27.0 ms on main
46ae5b43d, 27.9 ms on df25a485b (median of 6).Nothing else to measure: the game itself doesn't change, only the builder's line filter.
Measured on the PR's base
f8b543384. Main's 3 newer commits don't touch the crash crate or anything this test runs.Risks
A line of the game's log that holds the user's name or home folder percent-encoded now comes out redacted, where before
it stayed as it was. Text that only looks like an escape (
%USERPROFILE%,%d) isn't touched unless it decodes to thename. A revert is enough to undo it. Players notice nothing after updating.
Not covered, as before:
+for a space in a query string, a double-encoded name (%2520), and a non-ASCII name inanother letter case on Windows (
JOSÉforjosé).file://URLs write a space as%20and encode once.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
https://claude.ai/code/session_01VxeaZjFD5sZgue2tRx5H5v
Tested in game: Windows 10, RTX 4090, NVIDIA 617.42: a runtime built from this branch (df25a485b, so the game ran with its builder), three headless runs through the control bridge. The real home folder, percent-encoded in a switch the game prints in its 'vk: switches set' line, came out as file:%2F%2F%2FC:%2FUsers%2F%2Fx and as %USERPROFILE%%5Cx in the copied log; the usual lines still read %USERPROFILE%\AppData...; HOS_CRASH_TEST=start wrote its crash record. The real user name appears 0 times in the three logs, the crash record and build.log.
Measurements: why the numbers from main
46ae5b43dstill hold onf8b543384(patches unchanged by the rebase, crash crate untouched by main since).WIP: fix(crash): a report takes a folder's name out of a percent-encoded file:// URL tooto fix(crash): a report takes a folder's name out of a percent-encoded file:// URL too@review
Recommendation: Request changes. The fix leaves percent-encoded names exposed when the name itself contains a percent sign. Those names can still appear in copied logs and reports intended for public issues.
The change redacts percent-encoded home and user names, including escaped separators and longer profile-folder names. Its literal-first matching misses URL-encoded percent signs within a name.
Blocking (1): must change before merging.
builder/crates/crash/src/redact.rs:47: Literal-first matching consumes the percent sign of an encoded percent escape without trying the decoded interpretation when the remaining bytes do not match. (more on the line) Do: Allow matching to fall back to decoding%25when the literal path does not match the rest of the name, and add cases for both a literal percent-containing path and its encoded URL.@fixcan do L1.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes for the cases tested: the author reports 13 of 19 new cases fail on main and pass with the change. The reported median cost is 27.9 ms versus 27.0 ms per 100,000 lines over six interleaved runs on WSL; encoded percent signs within names remain unhandled.
Other systems: The same rule is used by copied game logs, build logs, crash records and bug reports on Windows and Linux. The author reports Windows game runs and Linux and Windows unit tests; the matching defect affects both platforms.
Switches: None.
Reviewed:
bedd5046fcagainstf8b543384d: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the pull request template, the full changed redact.rs and its existing case table, the commits, diff, and relevant log and report callers. Skimmed the recorded runs and CI results. docs/review-checklist.md and the adjacent Tooling checkout were absent.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no commands from the project, builds, or tests were run. The supplied CI checks were still running.
Overlaps and merge order: No overlapping open pull requests were supplied; the description identifies #3184 as closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -27,0 +44,4 @@if what.is_empty() {return None;}let mut i = at;L1 (blocking): Literal-first matching consumes the percent sign of an encoded percent escape without trying the decoded interpretation when the remaining bytes do not match.
When: For a user and home-folder name
a%41b, a file URL encodes the name asa%2541b. The matcher consumes%literally, then expects4but sees2; both the home and folder matches fail, leaving the encoded name in the copied log or report.Do: Allow matching to fall back to decoding
%25when the literal path does not match the rest of the name, and add cases for both a literal percent-containing path and its encoded URL.BeanBot's L1 is right, and it's fixed in
65f57f102(test) +bbb839b1f(fix).%of its own (a%41b), a URL writesa%2541b.match_attook the%as written, failed at the2and never tried%25as an escape.match_atnow goes back and tries the escape when the byte as written leads nowhere, the end of the name included (thename_endscheck moved into it). The two ways meet only where the name has a%and the line%25. A place where no name can begin is turned down before the search.file:///C:/Users/a%2541b/x,file:///D:/x/a%2541b/yandopen?path=C%3A%5CUsers%5Ca%2541b%5Cx(all three fail onbedd5046f), next to the existing literala%41brows. Alsofile:///home/%61na/x, which catches an early turn-down that would let no escape through.bbb839b1f:cargo test -p crash36/36 on Linux (WSL) and Windows (MSVC); clippy-D warningsand fmt clean. Against mainf8b543384, the test fails in 17 of its 23 rows.The game runs in Testing were on df25a485b and weren't repeated for this matcher change; the description says so.
Tested in game again on the head
bbb839b1f(the BeanBot L1 fix): Windows 10, RTX 4090, NVIDIA 617.42, runtimert-wt-3199-winrebuilt frombbb839b1f(v3.2.0-333-gbbb839b1f, its builder too). Four headless runs, profiletest:HOS_INPUT_SAVE= the home asfile:%2F%2F%2FC:%2FUsers%2F<name>%2Fx→ the copied log saysfile:%2F%2F%2FC:%2FUsers%2F<user>%2Fx.C%3A%5CUsers%5C<name>%5Cx→%USERPROFILE%%5Cx.file:%2F%2F%2FC:%2FUsers%2F<user>%2Fx. This goes through the new turn-down's%path.HOS_CRASH_TEST=startwrote a crash record holding no paths.%USERPROFILE%\AppData\Local\....This PC's name has no
%, so L1's%25case itself can't show in a real run; the unit test's three rows cover it. The description's Testing now namesbbb839b1f.