fix(retry): protect parseRetryAfterHeader from integer and time duration overflow - #1178
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v3 #1178 +/- ##
==========================================
- Coverage 99.78% 99.73% -0.05%
==========================================
Files 20 20
Lines 4124 4141 +17
==========================================
+ Hits 4115 4130 +15
- Misses 6 7 +1
- Partials 3 4 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jeevatkm
left a comment
There was a problem hiding this comment.
@HarshalPatel1972 Thanks for the PR.
Can you add test cases for patch coverage? See codecov report.
|
@HarshalPatel1972 ping |
Signed-off-by: Harshal Patel <hp842484@gmail.com>
@jeevatkm Good catch! Just pushed an update to fix the coverage. I added a couple of test cases in retry_test.go to specifically hit those overflow paths. One passes an intentionally massive integer to hit the seconds ceiling, and the other uses a date way out in the year 2293 to trigger the duration wrap-around. Tests are passing locally, so codecov should be happy now. Let me know if everything looks good on your end! |
|
@HarshalPatel1972 Thanks for updating tests. It seems the overflow path is not covered. Can you please check codecov? |
jeevatkm
left a comment
There was a problem hiding this comment.
@HarshalPatel1972 I have added a test case and merging it.
Description
This PR addresses an un-guarded integer and time duration overflow vulnerability within the automatic retry header parsing engine (
parseRetryAfterHeader). By introducing safe multiplication boundary thresholds, we ensure the client cleanly caps astronomical server-provided delays instead of corrupting the backoff context scheduler or causing a runtime panic.Technical Context
When parsing an HTTP
Retry-Afterheader value, the client evaluates either delta-seconds or a specific HTTP-Date string.time.Second(time.Durationstructure (Resolution Strategy
math.MaxInt64 / time.Secondinsideretry.goto intercept excessive delay parameters out of the gate.