fix: path traversal on /documents (NVBug 6553697) - #440
Open
chloecrozier wants to merge 2 commits into
Open
Conversation
Sanitize collection_name/filename and confine uploads to INGESTOR_UPLOAD_ROOT so unauthenticated POST/PATCH /documents cannot write arbitrary files.
There was a problem hiding this comment.
Pull request overview
Addresses a path-traversal arbitrary file write risk on the sizing advisor ingestor /documents endpoints by validating collection_name / filenames and confining upload paths under a resolved upload root directory.
Changes:
- Adds centralized path-validation helpers (
path_security.py) to validate collection names and confine upload destinations underINGESTOR_UPLOAD_ROOT. - Updates ingestor
/documentsendpoints to use safe path construction and return 400s for unsafe paths. - Updates deletion logic and docs/changelog to reflect the new security behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| community/ai-vws-sizing-advisor/src/utils.py | Adds basic collection_name/filename sanitization for deletion path keys (but still needs fixes for robustness and root alignment). |
| community/ai-vws-sizing-advisor/src/ingestor_server/server.py | Routes upload/write paths through safe helpers; adds request validation and maps unsafe paths to HTTP 400. |
| community/ai-vws-sizing-advisor/src/ingestor_server/path_security.py | New validation + resolved-path confinement utilities using INGESTOR_UPLOAD_ROOT. |
| community/ai-vws-sizing-advisor/README.md | Documents upload confinement and warns against exposing demo endpoints to untrusted networks. |
| community/ai-vws-sizing-advisor/CHANGELOG.md | Records the security fix in the changelog (NVBug 6553697). |
Suppressed comments (2)
community/ai-vws-sizing-advisor/src/utils.py:612
del_docs_vectorstore_langchain()still hard-codes/tmp-data/uploaded_files, but uploads are now confined underINGESTOR_UPLOAD_ROOT. If that env var is changed, deletes will buildsource_valuekeys that don’t match what was ingested, causing deletes to silently fail.
upload_folder = f"/tmp-data/uploaded_files/{safe_collection}"
community/ai-vws-sizing-advisor/src/utils.py:623
- The Milvus delete expression is built with a single-quoted string literal. If
source_valuecontains a double quote (or other characters the Milvus expr parser treats specially), this can break the expression or delete the wrong rows. Since filenames are user-controlled andvalidate_safe_filename()allows quotes, escape the value and use a consistent quoting strategy.
source_value = os.path.join(upload_folder, safe_filename)
if settings.vector_store.name == "milvus":
# Delete Milvus Entities
resp = vectorstore.col.delete(f"source['source_name'] == '{source_value}'")
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dglogo
previously approved these changes
Aug 4, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@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.
Summary
/documentsupload path (NVBug 6553697).collection_name/ filenames and confines writes toINGESTOR_UPLOAD_ROOTvia resolved-path checks.Test plan
/v1/documentswith a validcollection_name— succeedscollection_namelike../../tmp— rejected with 400../is basename-sanitized / confined under upload rootvgpu_docsPDFs (names with spaces/parens) still works