🛡️ Sentinel: [HIGH] Fix ZIP extraction bypass by using sanitized filename#320
Conversation
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR hardens the /api/upload-project ZIP upload path by unifying ZIP member filename validation with the existing normalize_uploaded_filename() utility, aiming to prevent ZIP slip/path traversal bypasses and keep upload sanitization consistent across multipart and ZIP uploads.
Changes:
- Use
safe_filename = normalize_uploaded_filename(member.filename)for ZIP members before joining/realpath containment checks. - Remove the inline “sensitive hidden names” blocklist from the ZIP loop in favor of the centralized normalizer.
- Add a new security-learning entry to
.jules/sentinel.mddocumenting the vulnerability and prevention guidance.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| app/routers/upload.py | Switch ZIP member extraction to use the sanitized filename from normalize_uploaded_filename() for path building and validation. |
| .jules/sentinel.md | Document the ZIP extraction validation issue and the intended prevention strategy. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| try: | ||
| safe_filename = normalize_uploaded_filename(member.filename) |
| ## 2025-05-11 - Zip Extraction Path Traversal and Sensitive File Bypass | ||
| **Vulnerability:** The ZIP extraction logic in `app/routers/upload.py` implemented custom, inline path traversal and sensitive file checks that differed from the application's standard file upload validation. This could potentially allow bypasses if edge cases were missed. Additionally, the standard normalizer (`normalize_uploaded_filename`) can be misleading if its return value is ignored. | ||
| **Learning:** Security validation logic must be unified across all upload paths. Implementing separate inline checks for ZIP members creates an inconsistent security boundary. Furthermore, when using a normalizer, it is critical to use its *return value* as the finalized path. Calling a normalizer but continuing to use the raw unsanitized input path completely bypasses the intended security sanitizations. | ||
| **Prevention:** Unify validation logic by always calling the core `normalize_uploaded_filename()` utility on extracted ZIP members, and explicitly using its return value (`safe_filename = normalize_uploaded_filename(...)`) for all subsequent path operations to enforce a single, robust security boundary. |
Severity: HIGH | Vulnerability: Unvalidated ZIP members | Impact: Path traversal bypass | Fix: Used return value of normalize_uploaded_filename | Verification: pytest tests/test_upload_security.py
PR created automatically by Jules for task 4218338266362141345 started by @madara88645