Skip to content

fix: sentry-trace header parsing#1749

Open
jpnurmi wants to merge 2 commits into
masterfrom
jpnurmi/fix/sentry-trace-header
Open

fix: sentry-trace header parsing#1749
jpnurmi wants to merge 2 commits into
masterfrom
jpnurmi/fix/sentry-trace-header

Conversation

@jpnurmi
Copy link
Copy Markdown
Collaborator

@jpnurmi jpnurmi commented May 25, 2026

parse_sentry_trace already receives value_len from the _n header API, but the span ID delimiter path still used unbounded string operations. A non-NUL-terminated header with a valid trace ID and no second dash inside value_len could read past the declared buffer.

This changes the second delimiter search and no-sampled span ID creation to use bounded APIs, guards the sampled flag read, and adds regression coverage for the truncated-length case.

jpnurmi and others added 2 commits May 25, 2026 13:59
parse_sentry_trace receives value_len so
sentry_transaction_context_update_from_header_n can parse non-NUL-terminated
header buffers. The trace ID delimiter search already honored that bound, but
the span ID delimiter used strchr and the no-sampled path used
sentry_value_new_string, which calls strlen.

A header with a valid trace ID, one dash, and no second dash inside value_len
could make parsing read past the declared buffer and include adjacent bytes in
the parent span ID or sampled flag.

Search for the second delimiter with memchr, create no-sampled span IDs with
sentry_value_new_string_n, and guard the sampled flag read. Add regression
coverage for a truncated sentry-trace value passed through the _n API.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
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