Reject Windows drive-lettered and colon-bearing Gitlink paths#95
Merged
Merged
Conversation
_normalize_repo_path's absolute-path guard (audit finding B1) checks
PurePosixPath.is_absolute(), which doesn't recognize a Windows drive
letter as absolute (no leading '/'). So a drive-lettered path slipped
past it - not a real escape (_safe_local_target's resolve()+containment
check still catches a genuine cross-drive path), but silent aliasing:
Windows pathlib treats a same-drive "C:" path segment as a no-op
drive-relative reference rather than a literal folder, so an
LLM-proposed "C:/config/app.txt" resolved to the exact same target as
the plain "config/app.txt" - not rejected as "absolute-looking input"
the way this guard's own contract says it should be.
Reject any ':' in a path segment loudly instead of letting it collapse
silently - covers same-drive and cross-drive letters, the
slash-less drive-relative form ("C:app.txt"), and an NTFS Alternate
Data Stream marker as a bonus (ADS addressing doesn't actually work
through this path-join code path, but rejecting it is free and
consistent with the rest of this guard's defensive stance).
Updated the one existing test that had pinned the old "silently
contained" behavior to instead assert rejection, and added coverage for
every variant found above. Full suite 1710 passed.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
_normalize_repo_path's absolute-path guard (audit finding B1) checksPurePosixPath.is_absolute(), which doesn't recognize a Windows drive letter as absolute (no leading/). So a drive-lettered path slipped past it — not a real escape (_safe_local_target'sresolve()+containment check still catches a genuine cross-drive path), but silent aliasing: Windowspathlibtreats a same-drive"C:"path segment as a no-op drive-relative reference rather than a literal folder, so an LLM-proposed"C:/config/app.txt"resolved to the exact same target as the plain"config/app.txt"— not rejected as "absolute-looking input" the way this guard's own contract says it should be.Fix
Reject any
':'in a path segment loudly instead of letting it collapse silently — covers same-drive and cross-drive letters, the slash-less drive-relative form ("C:app.txt"), and an NTFS Alternate Data Stream marker as a bonus (ADS addressing doesn't actually work through this path-join code path, but rejecting it is free and consistent with the rest of this guard's defensive stance).Test plan
Fifth and final fix from the recent adversarial bug-scan (after #91, #92, #93, #94) — worklist complete.