fix(OfficeUtils): strengthen ZipSlip path traversal protection in ZIP extraction#117
Open
maxm11 wants to merge 1 commit into
Open
fix(OfficeUtils): strengthen ZipSlip path traversal protection in ZIP extraction#117maxm11 wants to merge 1 commit into
maxm11 wants to merge 1 commit into
Conversation
… extraction Replace the weak check that only rejected paths starting with '../' with proper prefix-based containment validation. The new logic: - Rejects empty normalized archive entry paths - Rejects absolute paths in archive entries (Unix / and Windows C:\, \UNC) - Normalizes both output path and extraction directory via ShortenPath() to resolve all ../ and ./ components - Verifies the resolved output path starts with the extraction directory prefix, rejecting any entry that escapes the target directory Fixes Euro-Office#115 Agentic Model: Qwen3.6-35B-A3B (local) Signed-off-by: Max Murphy <maxmrphy@gmail.com>
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
Addresses Euro-Office/core#115 — Path Traversal in ZIP Extraction (ZipSlip).
Problem
The existing ZipSlip check in
do_extract_currentfile()only rejected archive entries whose normalized path started with../. This left several bypass vectors:../../../etc/passwdfoo/../../etc/passwd../../etc/passwdbut the check only looked at the filename, not the full output path/etc/passwd(Unix)Fix
Replaced the weak check with proper prefix-based containment validation:
./or../etc/passwd→ rejected immediatelyC:\Windows\...or\\server\share\...→ rejected immediatelyShortenPath()to resolve all../and./componentsnormalized_output_pathstarts withnormalized_extract_dir/UNZ_INTERNALERRORAttack vectors now blocked
../../../etc/passwdfoo/../../etc/passwd/etc/passwd(Unix)\\server\share\...(Windows)Files changed
OfficeUtils/src/ZipUtilsCP.cpp— replaced weak check with prefix-based containment validation indo_extract_currentfile()