Skip to content

fix: validate session replay IDs - #2071

Merged
jpnurmi merged 3 commits into
masterfrom
jpnurmi/fix/validate-session-replay-ids
Sep 7, 2026
Merged

fix: validate session replay IDs#2071
jpnurmi merged 3 commits into
masterfrom
jpnurmi/fix/validate-session-replay-ids

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator

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 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.

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
jpnurmi force-pushed the jpnurmi/fix/validate-session-replay-ids branch from 6a4f65a to f526e3e Compare September 5, 2026 08:05
@codecov

codecov Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.47368% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.23%. Comparing base (5460803) to head (7daa0e8).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2071      +/-   ##
==========================================
- Coverage   76.65%   74.23%   -2.42%     
==========================================
  Files          93      103      +10     
  Lines       23428    26776    +3348     
  Branches     4221     4881     +660     
==========================================
+ Hits        17958    19878    +1920     
- Misses       4529     5554    +1025     
- Partials      941     1344     +403     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jpnurmi
jpnurmi merged commit 761a5ef into master Sep 7, 2026
113 of 114 checks passed
@jpnurmi
jpnurmi deleted the jpnurmi/fix/validate-session-replay-ids branch September 7, 2026 10:08
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.

3 participants