fix(fs): validate paths on all read-side MountableFs APIs#1556
Merged
Conversation
read_file, stat, read_dir, exists, and read_link previously delegated to the underlying backend without calling validate_path() first, so mounted backends could receive control-character / depth-limit / length-limit violating paths through any read API. Add the same validation guard already applied to write_file, mkdir, remove, rename, copy, symlink, chmod, and set_modified_time. Closes #1548
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 4b92405 | Commit Preview URL Branch Preview URL |
May 06 2026, 09:27 AM |
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
MountableFsalready callsvalidate_path()before delegating writes (write_file,append_file,mkdir,remove,rename/copysource,symlinklink,chmod,set_modified_time), but the read-side methods (read_file,stat,read_dir,exists,read_link) delegated without validation. With mountedRealFsor third-partyFileSystemimplementations, this lets a script reach the backend with control-character / depth-limit / length-limit violating paths through any read API — weakening the path-policy boundary and making it a DoS / diagnostic-leak surface.Why
Closes #1548 (TM-DOS-046 read-side gaps).
How
Add the existing
validate_path()guard at the top of every path-taking publicFileSystemmethod onMountableFs.rename/copyalready validated both source and destination, so cross-mount semantics stay correct.Tests
New regression tests in
tests/security_audit_pocs.rscovering invalid paths through:read_filestatread_direxistsread_linkrename(destination side)copy(destination side)All 2258 lib tests + the new POC tests pass; existing mount/unmount/access tests unaffected.
cargo fmt --checkandcargo clippy --all-targets --features http_client -- -D warningsare green.Generated by Claude Code