-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(Authoring): Check real mime type when author uploads a file #187
fix(Authoring): Check real mime type when author uploads a file #187
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionality works as described, but I had some questions about the code. See inline comments.
return allowedTypes.contains(getRealMimeType(file)); | ||
} | ||
|
||
public String getRealMimeType(MultipartFile file) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public String getRealMimeType(MultipartFile file) { | |
private String getRealMimeType(MultipartFile file) { |
try { | ||
Metadata metadata = new Metadata(); | ||
TikaInputStream stream = TikaInputStream.get(file.getInputStream()); | ||
org.apache.tika.mime.MediaType mediaType = detector.detect(stream, metadata); | ||
return mediaType.toString(); | ||
} catch (IOException e) { | ||
return MimeTypes.OCTET_STREAM; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we add OCTET_STREAM to allowedTypes in application.properties, could this allow someone to potentially upload a file that we do not support?
To handle this case, should this method throw the IOException instead of returning a default OCTET_STREAM, and catch the exception in isUserAllowedToUpload() method and return false there?
🎉 This PR is included in version 1.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Changes
Check a file's real MIME type when an author uploads a file to the File Manager.
Test
Download the Burp Suite Community Edition (no need to enter email, just click "Go straight to downloads")
https://portswigger.net/burp/communitydownload
Install Burp Suite Community Edition
Launch Burp Suite Community Edition
Leave "Temporary project" selected
Use Burp defaults
Configure the proxy
Launch the browser
Upload a file that should not be allowed
Closes #186