fix(file-ops): implement whitelist validation for file operations (CW… - #273
Open
markuszaki wants to merge 1 commit into
Open
markuszaki wants to merge 1 commit into
markuszaki wants to merge 1 commit into
Conversation
…E-22/434/601)
Security fixes for 9 challenges across 3 vulnerability types:
File Inclusion (CWE-22):
- Added whitelist of allowed files (index.php, about.php, contact.php, help.php)
- Used basename() to strip directory traversal attempts
- Blocked protocol wrappers (://, php://, file://, data://, etc.)
- Default to index.php for invalid requests
File Upload (CWE-434):
- Implemented extension whitelist (jpg, jpeg, png, gif)
- Added MIME type validation using finfo
- Random filename generation using random_bytes() to prevent prediction
- File size validation (100KB limit)
- getimagesize() validation for high security level
Open Redirect (CWE-601):
- Whitelist of allowed redirect targets
- Protocol wrapper detection and blocking
- basename() to prevent path traversal
- Proper error responses (400) for invalid targets
Files modified:
- vulnerabilities/fi/source/{low,medium,high}.php
- vulnerabilities/upload/source/{low,medium,high}.php
- vulnerabilities/open_redirect/source/{low,medium,high}.php
🏆 DVWA — CTF Patch Score2 / 55 challenges patched
Commit: 🎉 Your result is on the leaderboard — see where you rank! 🏆 |
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.
…E-22/434/601)
Security fixes for 9 challenges across 3 vulnerability types:
File Inclusion (CWE-22):
File Upload (CWE-434):
Open Redirect (CWE-601):
Files modified: