Contain filesystem store paths to the configured base path - #58
Open
damilolaedwards wants to merge 1 commit into
Open
Contain filesystem store paths to the configured base path#58damilolaedwards wants to merge 1 commit into
damilolaedwards wants to merge 1 commit into
Conversation
FSStore built disk paths by joining the base path with a caller supplied location, with nothing stopping that location from containing ".." segments and resolving outside the base path entirely. Since a location is accepted from callers without any format validation upstream, this meant a crafted location could read, write, or delete arbitrary files on the host, reachable through the same download and retention code paths that handle ordinary records. Every method that turns a location into a filesystem path now routes through a single resolve helper that rejects anything which would land outside the base path, returning the existing ErrInvalid sentinel. Legitimate nested locations are unaffected.
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
FSStore built disk paths by joining the configured base path with a caller-supplied location, with nothing stopping that location from containing ".." segments and resolving outside the base path entirely. Locations are accepted from callers without any format validation upstream, so a crafted location could read, write, or delete arbitrary files on the host, reachable through the same download and retention code paths that handle ordinary records.
Every method that turns a location into a filesystem path now routes through a single
resolvehelper that rejects anything which would land outside the base path, returning the existingErrInvalidsentinel. Legitimate nested locations are unaffected.This is fixed at the store layer rather than only at the gRPC ingestion point, so every current and future caller of
FSStoregets the containment guarantee automatically, regardless of what validation happens upstream.Changes
pkg/store/fs.go: addedresolve(), used byExists, all six data types'Save*/Get*/Delete*, the storage handshake token methods, andCopy(both source and destination)pkg/store/fs_test.go: new test covering several traversal payloads rejected acrossExists/Get/Delete/Save/Copy, plus a check that ordinary nested locations still work exactly as beforeTest plan
go build ./...andgo vet ./...passTestFSStoreOperationssuite (17 subtests) still passes unchangeddownload.goandretention.goto confirm they already handle a store error safely (no changes needed there)