fix: Manual source upload API allows unauthenticated path traversal write outside#35
Open
jonathanchang31 wants to merge 1 commit into
Open
Conversation
Author
|
@aglover1221 Could you plz review my PR? |
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.
Summary
Fixes #34 by closing a server-side path traversal in the manual source upload flow.
Before this change,
/api/pipeline/sources/uploadaccepted attacker-controlleddocTypevalues and the backend derived the stored filename from that value. Because the write path used the derived filename without a strict basename/boundary check, a crafted multipart request could write a PDF outsidePRODUCT_MCP_DATA_DIR.This change makes stored filenames server-controlled, rejects unsupported
docTypevalues at the API boundary, and enforces a resolved-path containment check before any source file write.Related Issue
Fixed: #34
Change Type
Real Behavior Proof
1. Test suite passes
2. Production build passes
Observed result:
3. Original exploit is now blocked
Replayed the original traversal payload against a fresh isolated runtime:
Observed result:
{"error":"unsupported docType: ../../../../../../uploaded_escape"}HTTP status:
Filesystem result:
PRODUCT_MCP_DATA_DIRsources.yaml4. Valid upload flow still works
Replayed a normal upload:
Observed result:
{"ok":true,"productSlug":"r770","localPath":"server/dell/poweredge/r770/source/technical-guide.pdf", ...}Filesystem result:
server/dell/poweredge/r770/source/technical-guide.pdfsources.yamlupdatedSecurity Impact
This fix removes an unauthenticated arbitrary file write primitive from the manual upload endpoint.
Before the patch, a malicious client could escape the intended product source directory and write uploaded files outside
PRODUCT_MCP_DATA_DIR. After the patch, only supported document types are accepted and all final write targets are constrained to the intended source directory.Checklist