fix: validate session replay IDs - #2071
Open
jpnurmi wants to merge 2 commits into
Open
Conversation
Prevent path traversal through replay IDs. Replay flushing interpolated contexts.replay.replay_id from the stored crash event into JSON and MP4 paths after only checking for a nonempty string. A crafted ID containing path separators and parent-directory components could select files outside the replay staging directory. Matching JSON/MP4 files could be read, the video uploaded to the configured DSN, and both files deleted. Require a complete 32-digit hexadecimal UUID or its standard hyphenated form before constructing either path. Preserve casing and hyphenation to keep matching staged filenames. The existing UUID parser is unsuitable for validation because it accepts partial IDs and ignores trailing input once it has decoded 16 bytes. The related videoFilename issue allowed an on-disk JSON sidecar to redirect video uploads to arbitrary readable files using absolute paths or traversal components. Current code already derives video filenames from replay_id; document that videoFilename is ignored. Add UUID unit coverage for valid forms, invalid lengths and characters, misplaced hyphens, embedded NULs, and trailing data.
jpnurmi
force-pushed
the
jpnurmi/fix/validate-session-replay-ids
branch
from
September 5, 2026 08:05
6a4f65a to
f526e3e
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2071 +/- ##
==========================================
- Coverage 74.41% 74.22% -0.19%
==========================================
Files 103 103
Lines 26746 26761 +15
Branches 4873 4878 +5
==========================================
- Hits 19903 19864 -39
- Misses 5487 5556 +69
+ Partials 1356 1341 -15 🚀 New features to boost your workflow:
|
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.
Prevent path traversal through replay IDs.
Replay flushing interpolated
contexts.replay.replay_idfrom the stored crash event into JSON and MP4 paths after only checking for a non-empty string. A crafted ID containing path separators and parent-directory components could select files outside the replay staging directory. Matching JSON/MP4 files could be read, the video uploaded to the configured DSN, and both files deleted.Require a complete 32-digit hexadecimal UUID or its standard hyphenated form before constructing either path. Preserve casing and hyphenation to keep matching staged filenames. The existing UUID parser (
sentry__value_as_uuid/sentry_uuid_from_string) is unsuitable for validation because it accepts partial IDs and ignores trailing input once it has decoded 16 bytes.