fix: add file upload validation to prevent arbitrary file upload vulnerability#204
Open
lexburner wants to merge 1 commit intohigress-group:mainfrom
Open
fix: add file upload validation to prevent arbitrary file upload vulnerability#204lexburner wants to merge 1 commit intohigress-group:mainfrom
lexburner wants to merge 1 commit intohigress-group:mainfrom
Conversation
…erability Add FileUploadValidator with extension whitelist, MIME type consistency check, and filename sanitization to the attachment upload endpoint. 🤖 Generated with [Qoder][https://qoder.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.
📝 Description
FileUploadValidatorutility class with extension whitelist (27 allowed formats: images, documents, audio, video, zip), MIME type consistency validation, and filename sanitizationChatAttachmentServiceImpl.uploadAttachment()to reject disallowed file types before storageThis fixes the arbitrary file upload vulnerability on
POST /attachmentswhere attackers could upload malicious scripts (e.g., .jsp, .asp, .php, .aspx) without any server-side file type restriction.🔗 Related Issues
N/A
✅ Type of Change
🧪 Testing
mvn test)mvn clean package -DskipTests)mvn spotless:apply)INVALID_REQUESTerrorINVALID_REQUESTerror../../etc/passwd) are sanitized before storage📋 Checklist
mvn spotless:applyfor backend)