fix: Sanitize fileName to prevent path traversal vulnerability (VULN-1123)#259
Open
fix-it-felix-sentry[bot] wants to merge 1 commit intomainfrom
Open
fix: Sanitize fileName to prevent path traversal vulnerability (VULN-1123)#259fix-it-felix-sentry[bot] wants to merge 1 commit intomainfrom
fix-it-felix-sentry[bot] wants to merge 1 commit intomainfrom
Conversation
This fixes VULN-1123 by sanitizing user-provided file names to prevent path traversal attacks. The fix uses Path.GetFileName() to extract only the filename component, removing any directory path traversal sequences like '../' that could be used to access files outside the intended directories. Changes: - Sanitize fileName parameter in Store() method before using it in path construction - Sanitize fileName in conflict file handling within StoreIsolated() method - Add validation to reject empty or null filenames after sanitization References: - https://linear.app/getsentry/issue/VULN-1123 - https://owasp.org/www-community/attacks/Path_Traversal
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛
Internal Changes 🔧Release
Other
🤖 This preview updates automatically when you update the 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
This PR fixes a path traversal vulnerability by sanitizing user-provided file names before using them in file path construction.
Changes
fileNameparameter inStore()method usingPath.GetFileName()to extract only the filename componentfileNamein conflict file handling withinStoreIsolated()methodSecurity Impact
The application was building file paths from potentially untrusted data (user-provided file names), which could lead to path traversal attacks. An attacker could manipulate the path using sequences like
../../../to access or write files outside the intended directories.The fix uses
Path.GetFileName()which:../from being effectiveTesting
Existing tests cover the changed code paths and will verify that:
References