fix: sentry-trace header parsing#1749
Open
jpnurmi wants to merge 2 commits into
Open
Conversation
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>
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.
parse_sentry_tracealready receivesvalue_lenfrom the_nheader 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 insidevalue_lencould 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.