Skip to content

opentelemetry-propagator-jaeger: enforce baggage limits on extract - #5556

Open
serhiy-bzhezytskyy wants to merge 5 commits into
open-telemetry:mainfrom
serhiy-bzhezytskyy:fix/jaeger-baggage-limits
Open

opentelemetry-propagator-jaeger: enforce baggage limits on extract#5556
serhiy-bzhezytskyy wants to merge 5 commits into
open-telemetry:mainfrom
serhiy-bzhezytskyy:fix/jaeger-baggage-limits

Conversation

@serhiy-bzhezytskyy

@serhiy-bzhezytskyy serhiy-bzhezytskyy commented Aug 18, 2026

Copy link
Copy Markdown

The Jaeger propagator extracts every uberctx- header into baggage with no bound: _extract_baggage walks all carrier keys and sets each one, so an inbound carrier decides how much baggage enters the context. inject had the same problem in the other direction: it wrote every entry from an in-process baggage map into the carrier with no bound either.

The Jaeger format defines no limits, so this borrows the W3C Baggage spec limits — 180 entries, 4096 bytes per entry, 8192 bytes total, byte-denominated — dropping members once a limit is reached and keeping the earlier ones, on both extract and inject. opentelemetry-java caps its own Jaeger propagator's extract the same way and for the same reason; the core W3CBaggagePropagator in this package already uses the same three numbers.

Adds extract tests for entry count, per-entry bytes (the = inside an entry and the , between accepted entries, pinned separately), and the total-bytes cap; mirrors those with two inject tests. Each fails without the change.

Assisted-By: Claude Fable 5

The Jaeger propagator extracts every uberctx- header into baggage with
no bound: _extract_baggage walks all carrier keys and sets each one, so
an inbound carrier decides how much baggage enters the context.

The Jaeger format defines no limits, so this borrows the W3C Baggage
spec limits (180 entries, 4096 bytes per entry, 8192 bytes total,
byte-denominated), dropping members once a limit is reached and keeping
the earlier ones. opentelemetry-java caps its Jaeger propagator the
same way for the same reason (CVE-2026-45292).

Adds four extract tests: entry count, per-entry bytes, per-entry bytes
measured in bytes rather than characters, and the total-bytes cap. Each
fails without the change.

Assisted-By: Claude Fable 5
@serhiy-bzhezytskyy
serhiy-bzhezytskyy requested a review from a team as a code owner August 18, 2026 14:44
Two points from review. The entry limit bounded the entries kept, not the
candidates inspected, so a carrier full of oversized uberctx- headers could force
unbounded decoding and byte accounting; the limit now bounds the candidates via
itertools.islice, which also makes the accepted-entry counter redundant since kept
is at most inspected. opentelemetry-java bounds its jaeger baggage parse the same
way, in MAX_BAGGAGE_HEADER_TOKENS.

The per-entry accounting also omitted the "=" and "," a baggage header carries, so
each entry now counts two more bytes. That makes the numbers slightly stricter
than opentelemetry-java, which counts key and value only.

Assisted-By: Claude Fable 5
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Aug 18, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on maintainers · refreshed 2026-08-21 15:55 UTC

Merge when ready.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

The tests added here take the class past pylint's max-public-methods of 20, which
fails `lint-opentelemetry-propagator-jaeger`. Disable that check on the class, the
same way `propagator/opentelemetry-propagator-b3/tests/test_b3_format.py` does, and
rename the loop variables the new tests introduced so `invalid-name` stays quiet
without a second suppression.

Assisted-By: Claude Fable 5
Fix the extract-side byte accounting: entry_bytes charged both the "="
and the "," on every entry, but the "," only ever appears between
entries. Charge "=" per entry and "," once per already-accepted entry
against the running total instead, in a shared _limit_baggage_bytes
helper.

Cap inject the same way extract is capped, so an in-process baggage map
built without going through extract cannot produce an unbounded number
or volume of uberctx- headers either. Both paths now build a bounded
list of candidate pairs, then filter it through the same byte budget.

Update the changelog fragment to cover both directions.
@xrmx
xrmx requested a review from lzchen August 21, 2026 08:27
@github-project-automation github-project-automation Bot moved this to Approved PRs in Python PR digest Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Approved PRs

Development

Successfully merging this pull request may close these issues.

3 participants