security(upload): block path traversal in multipart file upload paths#2218
Draft
cursor[bot] wants to merge 1 commit into
Draft
security(upload): block path traversal in multipart file upload paths#2218cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
…oads Block path-traversal in local paths passed to MultipartFile.fromPath when paths may come from partially trusted bindings (e.g. API JSON in FileUploadAction). Add unit tests for the path guard. Co-authored-by: Sharjeel Yunus <sharjeelyunus@users.noreply.github.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
Fixes a medium severity path-traversal risk in
UploadUtils.uploadFileswhen uploads useMultipartFile.fromPathwith apathvalue that may come from partially trusted data (for example API JSON evaluated intoFileUploadActionfile descriptors, including background Workmanager uploads).Related Issue
Scheduled application security review (no tracked issue).
Type of Change
Vulnerability summary
pathfield on uploadFileobjects consumed byFileUploadAction/UploadUtils.uploadFiles(e.g. a compromised or malicious API response bound into the action, or other app logic that forwards untrusted paths)...path segments (after normalising\to/).upload_files_action.dartevaluatesfilesviaDataContext.eval, buildsFileinstances (includingpathfrom maps), and callsUploadUtils.uploadFiles. Background uploads deserialize the same structure inensemble_app.dartand callUploadUtils.uploadFiles...segments before the final read used for multipart construction.pathwhose segments include..beforeMultipartFile.fromPath.What Has Changed
uploadPathContainsParentSegmentinmodules/ensemble/lib/util/upload_utils.dartand enforced it in the upload loop.modules/ensemble/test/upload_path_security_test.dart.How to Test
cd modules/ensemble && flutter test test/upload_path_security_test.dartFileUploadActionwhosefilesresolves to a map withpathcontaining../; confirm upload fails withFormatExceptionand no multipart read occurs for that path.Screenshots / Videos
N/A
Checklist
flutter analyzeand addressed any new warningsflutter testand all tests passNote: CI Flutter SDK was not available in the automation sandbox; please run
flutter test/flutter analyzelocally for the checklist items.