Skip to content

fix(retry-handler): validate response body length against Content-Range#4975

Open
mcollina wants to merge 2 commits intomainfrom
fix/4970-retry-handler-content-range-validation
Open

fix(retry-handler): validate response body length against Content-Range#4975
mcollina wants to merge 2 commits intomainfrom
fix/4970-retry-handler-content-range-validation

Conversation

@mcollina
Copy link
Copy Markdown
Member

@mcollina mcollina commented Apr 5, 2026

Fixes #4970

The RetryHandler was validating the Content-Range header when resuming
a response via Range request, but not verifying that the actual response
body length matched the claimed range.

This fix validates in onResponseEnd() that when there's a finite end
position (from Content-Length or Content-Range), the cumulative bytes
received (this.start) equals this.end + 1. If not, a RequestRetryError
is thrown with message 'Content-Range mismatch'.

Fixes: #4970
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.87%. Comparing base (9c24204) to head (4f1d96d).
⚠️ Report is 16 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4975      +/-   ##
==========================================
- Coverage   92.96%   92.87%   -0.09%     
==========================================
  Files         111      110       -1     
  Lines       35842    35793      -49     
==========================================
- Hits        33320    33243      -77     
- Misses       2522     2550      +28     

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown
Member

@metcoder95 metcoder95 left a comment

Choose a reason for hiding this comment

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

Regression test for it?

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.

RetryHandler allows silent response body corruption via forged 206 response

3 participants