Skip to content

Potential fix for code scanning alert no. 14: Uncontrolled data used in path expression#10

Merged
xdrew87 merged 1 commit into
mainfrom
alert-autofix-14
May 22, 2026
Merged

Potential fix for code scanning alert no. 14: Uncontrolled data used in path expression#10
xdrew87 merged 1 commit into
mainfrom
alert-autofix-14

Conversation

@xdrew87
Copy link
Copy Markdown
Owner

@xdrew87 xdrew87 commented May 22, 2026

Potential fix for https://github.com/xdrew87/nexusintel/security/code-scanning/14

General fix: ensure any user-derived path component is transformed into a strictly safe filename/path-segment form (allowlist + normalization) before being used in path expressions, and only use the sanitized value downstream.

Best fix here (without changing functionality):
In backend/api/routes/evidence_router.py, add a dedicated sanitize_path_segment helper and use it for investigation_id before building upload_dir. Keep existing containment checks. This makes the sanitization explicit and deterministic, reducing taint concerns and preserving behavior (alphanumeric, _, - IDs only).

Changes needed:

  • Add new helper function near existing sanitize_filename.
  • Replace current regex id_match block in upload_evidence with call to new sanitizer and same 400 response on invalid input.
  • No new imports or dependencies required.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…in path expression

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@xdrew87 xdrew87 marked this pull request as ready for review May 22, 2026 20:30
@xdrew87 xdrew87 merged commit c039699 into main May 22, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant