Repository navigation
git-nonutf8-paths: fix SEC-10 - #40
Merged
Merged
Conversation
kridaydave
force-pushed
the
fix/pr-23-git-nonutf8-paths
branch
from
November 8, 2026 18:10
3da8508 to
00688ee
Compare
kridaydave
force-pushed
the
fix/pr-23-git-nonutf8-paths
branch
from
November 8, 2026 18:53
00688ee to
2c33a4f
Compare
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.
Bugs
extract_snapshotdecodes ls-tree paths withString::from_utf8_lossy, so distinct non-UTF-8 paths can collide into one snapshot key and files get silently merged.What was wrong
src/adapter/git.rs:extract_snapshotdecoded each NUL-framedgit ls-tree -r -zentry withString::from_utf8_lossyand split the lossy string on\t. The lossy path became thevalidate_tree_pathinput and theSnapshot.fileskey. Git stores paths as raw bytes; distinct non-UTF-8 paths can decode to the same lossy string, so a later entry overwrote an earlier one and the overwritten file was never diffed, visibility-checked, or exported.Fix
Parse ls-tree records on raw bytes: split on the tab byte, keep metadata as lossy text (ASCII), and decode the path with
std::str::from_utf8. If the path is not valid UTF-8, return an error that names the lossy path and states it was rejected to avoid path collisions.Snapshot.filesremainsHashMap<String, Vec<u8>>, so rejecting is the smallest change that makes the collision impossible.Added
test_git_adapter_rejects_non_utf8_pathintests/git_adapter_test.rs(unix). It commits a file whose name contains an invalid UTF-8 byte and assertsextract_snapshotreturns an error mentioning "non-UTF-8 path".Verification
CI green (fmt, clippy, tests, release build, adjudication) + the regression test you added