fix(resourceinfo): reject manifest paths escaping the destination#23
fix(resourceinfo): reject manifest paths escaping the destination#23Rakdos8 wants to merge 1 commit into
Conversation
|
Hi @Rakdos8 Thank you for the PR and apologies for the late response. We are still in the process of sorting out some details around contribution guidelines and PR templates. It would be great if you could add a test case for this problem to the test suite. |
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.
39d576e to
ee3ded3
Compare
No worries about the delay, and thanks for taking a look! I've added a test case for this: It exercises the real-world vector end-to-end through the public API:
Without the containment check the unpack would write One note: I couldn't run the suite locally (the CMake presets target Windows/macOS and I'm on Linux). Happy to adjust the test placement or style to match your conventions once the contribution guidelines are finalized. |
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.