Skip to content

Fix chunked response size overflow#2520

Merged
grcevski merged 1 commit into
open-telemetry:mainfrom
MrAlias:fix-chunck-http-resp-overflow
Jun 26, 2026
Merged

Fix chunked response size overflow#2520
grcevski merged 1 commit into
open-telemetry:mainfrom
MrAlias:fix-chunck-http-resp-overflow

Conversation

@MrAlias

@MrAlias MrAlias commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Motivation

  • The manual chunked HTTP decoder parsed the chunk size as a signed int64 and added it to a slice index without checking for overflow, allowing an attacker-controlled large chunk size to cause a runtime panic and crash the agent.

Description

  • Parse the chunk-size line with strconv.ParseUint and remove the signed-negative check to avoid incorrect casting.
  • Compute available := len(data) - chunkStart and treat any chunkSize greater than available as a truncated chunk before converting to int and slicing.
  • Add a regression test in TestDechunkBody that asserts an oversized advertised chunk ("7fffffffffffffff\r\nA") is treated as truncated and returns the available bytes.

Testing

  • go test ./pkg/ebpf/common -run 'TestDechunkBody|TestHttpSafeParseResponseChunked'

@MrAlias MrAlias added this to the v0.10.0 milestone Jun 26, 2026
@MrAlias MrAlias requested a review from a team as a code owner June 26, 2026 17:08
@MrAlias MrAlias added bug Something isn't working go Related to Go code area: tracing Trace context, span construction, and trace attribute behavior labels Jun 26, 2026
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.07%. Comparing base (914ffa4) to head (b75acc4).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pkg/ebpf/common/http_transform.go 66.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2520      +/-   ##
==========================================
- Coverage   69.24%   69.07%   -0.18%     
==========================================
  Files         345      345              
  Lines       46747    46796      +49     
==========================================
- Hits        32372    32326      -46     
- Misses      12330    12435     +105     
+ Partials     2045     2035      -10     
Flag Coverage Δ
integration-test 50.30% <60.00%> (-0.62%) ⬇️
integration-test-arm 27.10% <0.00%> (-1.21%) ⬇️
integration-test-vm-5.15-lts ?
integration-test-vm-6.18-lts ?
k8s-integration-test 36.03% <0.00%> (+0.33%) ⬆️
oats-test 35.45% <60.00%> (+0.09%) ⬆️
unittests 63.36% <80.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@grcevski grcevski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@grcevski grcevski merged commit 343e2aa into open-telemetry:main Jun 26, 2026
114 of 117 checks passed
@MrAlias MrAlias deleted the fix-chunck-http-resp-overflow branch June 26, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: tracing Trace context, span construction, and trace attribute behavior bug Something isn't working go Related to Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants