Skip to content

fix(cli): secure ZIP extraction against Path Traversal (Zip Slip)#6750

Open
RinZ27 wants to merge 1 commit intolangchain-ai:mainfrom
RinZ27:security/fix-zip-slip-vulnerability
Open

fix(cli): secure ZIP extraction against Path Traversal (Zip Slip)#6750
RinZ27 wants to merge 1 commit intolangchain-ai:mainfrom
RinZ27:security/fix-zip-slip-vulnerability

Conversation

@RinZ27
Copy link

@RinZ27 RinZ27 commented Feb 5, 2026

Description

The current implementation of _download_repo_with_requests uses zip_file.extractall(path), which is vulnerable to Path Traversal (Zip Slip) attacks. If a malicious template or a compromised repository is used, an attacker could potentially overwrite arbitrary files outside the target directory.

I've replaced the unsafe extraction with a secure loop that validates each member's path using os.path.commonpath (via prefix checking) to ensure all extracted files remain within the intended destination.

Dependencies

None.

Twitter handle

@RinZ27 (if applicable)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant