Sanitize file upload data#1432
Conversation
|
Hi @martin-g ,
|
Thanks for fixing this |
|
@reiern70 , Can you merge the PR |
* Security Vulnerabilty - Path Traversal Fix * Code review comments implemented (cherry picked from commit 7247098)
|
🙇 |
|
@martin-g Can I request a CVE for this ? |
|
You can! But I won't do it myself for two reasons:
|
|
CVE creation is much easier this days :) |
|
Cherry pick this to 10.x branch? |
Ok. I see it was already done. |
I think we are possibly one of the few users of this functionality,and we use anther version of IUploadsFileManager, thus I doubt this has impact for many users. But letting them know via email might be good. |
Path Traversal via Unsanitized Filename and Upload ID in FolderUploadsFileManager
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:NSummary
FolderUploadsFileManagerin Apache Wicket does not validate or sanitize theuploadFieldIdparameter or theclientFileNamebefore constructing file paths, allowing an unauthenticated attacker to write arbitrary files outside the intended upload directory or read files from arbitrary locations on the server.Description
uploadIdquery parameter flows intosave()asuploadFieldId(line 66). TheclientFileNameingetFile()comes from client-controlled JSON in the AJAX callback (UploadInfo.fromJson()).FolderUploadsFileManager.save()at line 66–70:FolderUploadsFileManager.getFile()at line 81:getFile()method also permits reading arbitrary files when the attacker manipulates theclientFileNamein the AJAX response JSON.Attack Vectors
uploadIdHTTP query parameter is passed directly tonew File(getFolder(), uploadFieldId)without validation. An attacker sends?uploadId=../../webapps/ROOTto write files into the web root.clientFileNamefield in the AJAXfilesInfoJSON is deserialized byUploadInfo.fromJson()and passed togetFile()without sanitization, allowing path traversal reads.FileUpload.getClientFileName()strips/and\path separators, theFolderUploadsFileManagerclass has no defense-in-depth. Any caller or subclass providing an unsanitized filename bypasses the intended protection.Affected
org.apache.wicket:wicket-corewicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FolderUploadsFileManager.javaFolderUploadsFileManagerwas addedFor POC, check here: https://gist.github.com/hayageek/3dda5923bbda483954dd84cfb5651534