fix(code-mappings): Add path validation to prevent path traversal#3242
Open
fix-it-felix-sentry[bot] wants to merge 1 commit intomasterfrom
Open
fix(code-mappings): Add path validation to prevent path traversal#3242fix-it-felix-sentry[bot] wants to merge 1 commit intomasterfrom
fix-it-felix-sentry[bot] wants to merge 1 commit intomasterfrom
Conversation
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>
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
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
std::path::PathimportSecurity 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.rscover this functionality. The change is minimal and follows established patterns in the codebase.References