fix(resourceinfo): reject manifest paths escaping the destination#23
Open
Rakdos8 wants to merge 1 commit into
Open
fix(resourceinfo): reject manifest paths escaping the destination#23Rakdos8 wants to merge 1 commit into
Rakdos8 wants to merge 1 commit into
Conversation
m_relativePath comes straight from the manifest and was joined onto basePath and written with no containment check, so an entry like '../../x' (zip-slip) wrote files anywhere on disk. Add a containment check (weakly_canonical + lexically_relative, lexical fallback) and refuse any Put* whose target escapes basePath.
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
Closes a zip-slip / path-traversal arbitrary file write in the resource
unpack path.
Problem
m_relativePathcomes straight from the manifest and was joined ontobasePathand written (5Put*sites) with no containment check. Amanifest entry such as
../../xor an absolute path wrote files anywhereon disk.
Fix
Add a file-local
IsPathWithinBasehelper (weakly_canonical+lexically_relative, with a lexical-normalise fallback) and guard everywrite site, returning the existing
MALFORMED_RESOURCE_INPUTresult whenthe target escapes
basePath.Type
Security — path traversal / arbitrary file write (Critical).
Testing
Manual review; legitimate relative paths resolve within base and are
unaffected;
../absolute escapes are now refused.