Repository navigation
fix(local-fs): Encode object keys to prevent path traversal - #750
Merged
Merged
Conversation
Changelog PreviewThis PR lands in these workspaces:
📋 Changelog PreviewThis is how your changes will appear in the changelog. Bug Fixes
🤖 This preview updates automatically when you update the PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #750 +/- ##
==========================================
+ Coverage 91.80% 91.87% +0.06%
==========================================
Files 118 119 +1
Lines 22469 22978 +509
==========================================
+ Hits 20628 21110 +482
- Misses 1841 1868 +27
☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jan-auer
force-pushed
the
worktree-fs-226-local-fs-path-traversal
branch
from
November 3, 2026 15:55
beaa639 to
c18e49d
Compare
lcian
reviewed
Nov 5, 2026
lcian
reviewed
Nov 5, 2026
lcian
approved these changes
Nov 5, 2026
Windows strips trailing spaces from names, so a key like `x.obj /y` created a directory that collided with the object file of key `x`. Escape a trailing space like a trailing dot. Also use `percent_encode_byte` for escaping instead of formatting by hand.
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.
The local filesystem backend joined the object key directly onto the storage root. Keys were never validated, so a key like
../../xcould read, write or delete files outside the root. Because each key segment was a plain folder, objectsaanda/balso could not both exist.The backend now builds its own object paths, at
{usecase}/{scopes}/objects/{key}.obj. Each/-separated key segment is still one folder level, but it is percent-encoded first:%, ASCII control characters and the characters Windows reserves (\ < > : " | ? *) are escaped..is escaped, so no segment can be.or....of a trailing.objis escaped, so a folder can never have the same name as an object file.%.All other characters, including non-ASCII, are kept as they are, so paths stay readable. Resumable uploads move from
uploads/to.uploads/. A usecase name cannot contain., so this folder can no longer clash with a usecase calleduploads. The module docs now describe the layout, the encoding rules and the remaining limits.This changes the on-disk layout and there is no migration. Objects stored with the old layout can no longer be read. This is acceptable because there are no self-hosted deployments yet.
Fixes FS-226
Fixes FS-511
Changelog Entry
aanda/bcan both exist.