Skip to content

fix(code-mappings): Add path validation to prevent path traversal#3242

Open
fix-it-felix-sentry[bot] wants to merge 1 commit intomasterfrom
fix/vuln-1356-path-traversal-validation
Open

fix(code-mappings): Add path validation to prevent path traversal#3242
fix-it-felix-sentry[bot] wants to merge 1 commit intomasterfrom
fix/vuln-1356-path-traversal-validation

Conversation

@fix-it-felix-sentry
Copy link

Summary

Adds path canonicalization and validation before reading the code mappings file to address a path traversal security finding (Semgrep rule: rust.actix.path-traversal.tainted-path.tainted-path).

Changes

  • Added std::path::Path import
  • Canonicalize the file path before reading to:
    • Resolve any symbolic links
    • Validate the path exists and is accessible
    • Prevent potential path traversal vulnerabilities
  • Updated error message to use the canonical path for clarity

Security Context

While this is a CLI tool where users explicitly provide file paths (similar to standard Unix utilities), this defense-in-depth approach ensures consistent security practices across the codebase and addresses the static analysis finding.

The canonicalize() method is already used in other parts of the codebase (e.g., debug_files/bundle_sources.rs, bash_hook.rs) for similar path validation purposes.

Testing

Existing integration tests in tests/integration/code_mappings/upload.rs cover this functionality. The change is minimal and follows established patterns in the codebase.

References

Add path canonicalization and validation before reading the mappings
file to address path traversal security finding. The canonicalize()
call resolves symbolic links and ensures the path is valid and
accessible, preventing potential path traversal attacks.

While this is a CLI tool where the user provides the path explicitly,
this defense-in-depth approach ensures consistent security practices
across the codebase.

Fixes: https://linear.app/getsentry/issue/VULN-1356
Fixes: https://linear.app/getsentry/issue/ENG-7162

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@fix-it-felix-sentry fix-it-felix-sentry bot requested review from a team and szokeasaurusrex as code owners March 25, 2026 03:11
@linear-code
Copy link

linear-code bot commented Mar 25, 2026

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.

0 participants