This repository was archived by the owner on Apr 22, 2026. It is now read-only.
🔒 Fix path traversal vulnerability in FileStore (#1310)#1345
Open
paipeline wants to merge 1 commit into
Open
Conversation
This commit addresses a critical security vulnerability in the FileStore class where user-controlled file paths were not properly validated, allowing for arbitrary file write attacks and path traversal. Security improvements: - Add path validation in _validate_path() method to block dangerous patterns - Prevent absolute paths and common system directory references - Ensure resolved paths stay within the working directory boundaries - Add optional file extension allowlist for additional security - Add comprehensive logging for security events Backward compatibility: - Default behavior unchanged - all extensions allowed unless restricted - Existing functionality preserved while adding security layers - Error handling improved with descriptive messages Tests: - Added comprehensive security test suite in test_file_store_security.py - Tests cover path traversal, absolute paths, system directories, extension filtering, and edge cases - All tests pass confirming security fixes work correctly This fix prevents malicious LLM outputs from writing to sensitive system files or escaping the intended sandbox directory.
There was a problem hiding this comment.
Important
Looks good to me! 👍
Reviewed everything up to a8902c4 in 15 seconds. Click for details.
- Reviewed
309lines of code in2files - Skipped
0files when reviewing. - Skipped posting
0draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
Workflow ID: wflow_SwXt6XZGnbxVePGt
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
This PR fixes a critical path traversal security vulnerability in the
FileStore.push()method that allows arbitrary file writes outside the intended directory.Issue
As reported in #1310, the current implementation lacks security validation for file paths, enabling:
../../../etc/passwdpatterns/etc/passwdRoot Cause
In
FileStore.push(), user-controlled file names fromfiles.items()were directly passed to:This allows attackers to use path traversal sequences to escape the working directory.
Solution
Security Enhancements
_validate_path()method performs comprehensive security checks../, absolute paths, system directories)working_dirKey Security Checks
../,..\\,~/,/etc/,/usr/,/var/,/root/,C:\\patternsBackward Compatibility
Testing
Added comprehensive security test suite (
test_file_store_security.py) covering:../../../etc/passwd)/etc/passwd)~/,/usr/,/var/, etc.)All tests pass ✅
Before/After
Before (Vulnerable):
After (Secure):
Impact
This is a HIGH SEVERITY security fix that:
References
Important
Fixes path traversal vulnerability in
FileStore.push()by adding path validation and security checks._validate_path()inFileStoreto validate and sanitize file paths.../,..\\,~/, etc.) and absolute paths.working_dir.test_file_store_security.pywith tests for path traversal prevention, absolute path blocking, system directory protection, and file extension allowlist.working_dirand handle complex traversal attempts.This description was created by
for a8902c4. You can customize this summary. It will automatically update as commits are pushed.