fix: validate session replay IDs by jpnurmi · Pull Request #2071 · getsentry/sentry-native · GitHub
Skip to content

fix: validate session replay IDs - #2071

Open
jpnurmi wants to merge 2 commits into
masterfrom
jpnurmi/fix/validate-session-replay-ids
Open

fix: validate session replay IDs#2071
jpnurmi wants to merge 2 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

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.

1 participant