fix: sanitize dzuuid to prevent path traversal in /uploadCase (#254)#434
Draft
Cypher-CP0 wants to merge 1 commit intoEAPD-DRB:mainfrom
Draft
fix: sanitize dzuuid to prevent path traversal in /uploadCase (#254)#434Cypher-CP0 wants to merge 1 commit intoEAPD-DRB:mainfrom
Cypher-CP0 wants to merge 1 commit intoEAPD-DRB:mainfrom
Conversation
9 tasks
Collaborator
|
Thanks for this. We're prioritizing other work right now, so converting this to draft for the time being. We'll revisit when we're ready to pick these up. |
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.
Linked issue
Existing related work reviewed
Overlap assessment
sanitize_uuid() helper function and the ValueError catch in the except block were not
present in the current main branch code, leaving the path traversal vector still open.
This PR completes the fix with explicit input validation before any path construction occurs.
Why this PR should proceed
dzuuid value like
../../../../etcpasses through to Path("_chunks", dz_uuid) andsubsequently to shutil.rmtree() without rejection
UUIDs (e.g.
a1b2c3d4-e5f6-...) match the allowed pattern[a-zA-Z0-9_\-]{1,64}Summary
sanitize_uuid()helper inAPI/Routes/Upload/UploadRoute.pythatvalidates dzuuid against a strict
[a-zA-Z0-9_\-]{1,64}regex before it is used toconstruct any filesystem path. Moved the sanitization call to run immediately after
retrieving dzuuid from the request form, before
Path("_chunks", dz_uuid)is constructed.Updated the except block to catch
ValueErroralongsidePermissionErrorand return HTTP400 with a safe generic error message.