Skip to content

fix: sanitize dzuuid to prevent path traversal in /uploadCase (#254)#434

Draft
Cypher-CP0 wants to merge 1 commit intoEAPD-DRB:mainfrom
Cypher-CP0:fix/path-traversal-dzuuid
Draft

fix: sanitize dzuuid to prevent path traversal in /uploadCase (#254)#434
Cypher-CP0 wants to merge 1 commit intoEAPD-DRB:mainfrom
Cypher-CP0:fix/path-traversal-dzuuid

Conversation

@Cypher-CP0
Copy link
Copy Markdown

Linked issue

Existing related work reviewed

Overlap assessment

Why this PR should proceed

  • The vulnerability (CWE-22) is still reproducible on the current main branch — a crafted
    dzuuid value like ../../../../etc passes through to Path("_chunks", dz_uuid) and
    subsequently to shutil.rmtree() without rejection
  • The fix is minimal, non-breaking, and backward-compatible — all valid Dropzone-generated
    UUIDs (e.g. a1b2c3d4-e5f6-...) match the allowed pattern [a-zA-Z0-9_\-]{1,64}
  • Returns a clean HTTP 400 for invalid input rather than leaking internal error details

Summary

  • What changed: Added sanitize_uuid() helper in API/Routes/Upload/UploadRoute.py that
    validates dzuuid against a strict [a-zA-Z0-9_\-]{1,64} regex before it is used to
    construct 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 ValueError alongside PermissionError and return HTTP
    400 with a safe generic error message.

@SeaCelo
Copy link
Copy Markdown
Collaborator

SeaCelo commented May 6, 2026

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.

@SeaCelo SeaCelo marked this pull request as draft May 6, 2026 00:56
@SeaCelo SeaCelo added Deferred Not prioritized for now; revisit later Security Security hardening or vulnerability fix labels May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Deferred Not prioritized for now; revisit later Security Security hardening or vulnerability fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Path traversal vulnerability in /uploadCase due to unsanitized dzuuid

2 participants