-
Notifications
You must be signed in to change notification settings - Fork 3k
fix(http): lost request body on retries & redirects #6666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(http): lost request body on retries & redirects #6666
Conversation
Updates the HTTP protocol to use `(*retryablehttp.Request).SetBodyString` instead of direct `Body` assignment. This fixes #6665 where the request body was dropped during retries or 307/308 redirects because `GetBody` was not being populated. Thanks to @zzyjsj for reporting the bug in the upstream dependency and the hints! Signed-off-by: Dwi Siswanto <[email protected]>
WalkthroughUpgraded Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10–15 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
|
Note that this PR also bump $ go get -v github.com/projectdiscovery/[email protected]
go: warning: github.com/klauspost/[email protected]: retracted by module author: https://github.com/klauspost/compress/issues/1114
go: to switch to the latest unretracted version, run:
go get github.com/klauspost/compress@latest
go: upgraded github.com/projectdiscovery/retryablehttp-go v1.0.133 => v1.1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
pkg/protocols/http/build_request.go (1)
458-471: UsingSetBodyStringcorrectly wires request bodies for retries/redirectsSwitching from manually setting
req.Bodytoreq.SetBodyString(body)after evaluation is the right fix to ensure the underlyinghttp.Requestcan replay the body on retries and 307/308 redirects. The surrounding logic (Interactsh replacement, expression evaluation, headers) stays intact, and the new error wrap is fine, though you may eventually want to standardize onerrkitfor consistency.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (2)
go.mod(2 hunks)pkg/protocols/http/build_request.go(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.go
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.go: Format Go code usinggo fmt ./...
Run static analysis usinggo vet ./...on Go code
Files:
pkg/protocols/http/build_request.go
pkg/protocols/**/*.go
📄 CodeRabbit inference engine (CLAUDE.md)
pkg/protocols/**/*.go: Each protocol implementation should implement the Request interface with Compile(), ExecuteWithResults(), Match(), and Extract() methods
Protocol implementations should embed Operators for matching/extraction functionality
Files:
pkg/protocols/http/build_request.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Lint
🔇 Additional comments (1)
go.mod (1)
30-30: Dependency bumps look appropriate for new HTTP body handlingUpgrading
github.com/projectdiscovery/retryablehttp-gotov1.1.0andgithub.1485827954.workers.dev/klauspost/compresstov1.18.2is consistent with the newSetBodyStringusage and should be low‑risk, especially with tests and lint already passing. No issues from the diff itself; just keep an eye out for any subtle retry/redirect or compression behavior changes in downstream runs.Also applies to: 273-273
Co-authored-by: zzy <[email protected]> Signed-off-by: Dwi Siswanto <[email protected]>
| // override the body with a new one that will be used to read the request body in parallel threads | ||
| // for race condition testing | ||
| if r.request.Threads > 0 && r.request.Race { | ||
| req.Body = race.NewOpenGateWithTimeout(req.Body, time.Duration(2)*time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wraps the body in a sync primitive to control the timing of the read for race condition testing. Using SetBody* here would obscure or break this timing mechanism, so I will leave it as is.
|
Any other occurrences of direct |
Okay, so I was wrong about that. I'm still finding a couple more occurrences that might be impacted too. @coderabbitai create an issue for that. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain@dwisiswant0: I'll search for additional occurrences of direct 🏁 Script executed: Length of output: 6168 🏁 Script executed: Length of output: 54 @dwisiswant0: I've created issue #6692 to track the additional occurrences of direct I found 5 locations that may be impacted:
The issue includes detailed context and recommendations for reviewing each occurrence. Some may be less critical (like the curl generation), but they should all be evaluated to ensure retry/redirect reliability. |
Continue the fix from #6666 by converting remaining direct Body assignments to use setter methods: * pkg/fuzz/component/body.go:139: use `SetBodyReader()` in transfer-encoding path. * pkg/protocols/http/request.go:694: use `SetBodyString()` in fuzz component `Rebuild()`. Fixes #6692. Signed-off-by: Dwi Siswanto <[email protected]>
Continue the fix from #6666 by converting remaining direct Body assignments to use setter methods: * pkg/fuzz/component/body.go:139: use `SetBodyReader()` in transfer-encoding path. * pkg/protocols/http/request.go:694: use `SetBodyString()` in fuzz component `Rebuild()`. Fixes #6692. Signed-off-by: Dwi Siswanto <[email protected]>
* fix(http): lost request body on retries & redirects Updates the HTTP protocol to use `(*retryablehttp.Request).SetBodyString` instead of direct `Body` assignment. This fixes #6665 where the request body was dropped during retries or 307/308 redirects because `GetBody` was not being populated. Thanks to @zzyjsj for reporting the bug in the upstream dependency and the hints! Signed-off-by: Dwi Siswanto <[email protected]> * empty: add co-author Co-authored-by: zzy <[email protected]> Signed-off-by: Dwi Siswanto <[email protected]> --------- Signed-off-by: Dwi Siswanto <[email protected]> Co-authored-by: zzy <[email protected]>
Continue the fix from #6666 by converting remaining direct Body assignments to use setter methods: * pkg/fuzz/component/body.go:139: use `SetBodyReader()` in transfer-encoding path. * pkg/protocols/http/request.go:694: use `SetBodyString()` in fuzz component `Rebuild()`. Fixes #6692. Signed-off-by: Dwi Siswanto <[email protected]>
* fix(http): lost request body on retries & redirects Updates the HTTP protocol to use `(*retryablehttp.Request).SetBodyString` instead of direct `Body` assignment. This fixes #6665 where the request body was dropped during retries or 307/308 redirects because `GetBody` was not being populated. Thanks to @zzyjsj for reporting the bug in the upstream dependency and the hints! Signed-off-by: Dwi Siswanto <[email protected]> * empty: add co-author Co-authored-by: zzy <[email protected]> Signed-off-by: Dwi Siswanto <[email protected]> --------- Signed-off-by: Dwi Siswanto <[email protected]> Co-authored-by: zzy <[email protected]>
Continue the fix from #6666 by converting remaining direct Body assignments to use setter methods: * pkg/fuzz/component/body.go:139: use `SetBodyReader()` in transfer-encoding path. * pkg/protocols/http/request.go:694: use `SetBodyString()` in fuzz component `Rebuild()`. Fixes #6692. Signed-off-by: Dwi Siswanto <[email protected]>
* fix(http): lost request body on retries & redirects Updates the HTTP protocol to use `(*retryablehttp.Request).SetBodyString` instead of direct `Body` assignment. This fixes #6665 where the request body was dropped during retries or 307/308 redirects because `GetBody` was not being populated. Thanks to @zzyjsj for reporting the bug in the upstream dependency and the hints! Signed-off-by: Dwi Siswanto <[email protected]> * empty: add co-author Co-authored-by: zzy <[email protected]> Signed-off-by: Dwi Siswanto <[email protected]> --------- Signed-off-by: Dwi Siswanto <[email protected]> Co-authored-by: zzy <[email protected]>
Continue the fix from #6666 by converting remaining direct Body assignments to use setter methods: * pkg/fuzz/component/body.go:139: use `SetBodyReader()` in transfer-encoding path. * pkg/protocols/http/request.go:694: use `SetBodyString()` in fuzz component `Rebuild()`. Fixes #6692. Signed-off-by: Dwi Siswanto <[email protected]>
* fix(http): lost request body on retries & redirects Updates the HTTP protocol to use `(*retryablehttp.Request).SetBodyString` instead of direct `Body` assignment. This fixes #6665 where the request body was dropped during retries or 307/308 redirects because `GetBody` was not being populated. Thanks to @zzyjsj for reporting the bug in the upstream dependency and the hints! Signed-off-by: Dwi Siswanto <[email protected]> * empty: add co-author Co-authored-by: zzy <[email protected]> Signed-off-by: Dwi Siswanto <[email protected]> --------- Signed-off-by: Dwi Siswanto <[email protected]> Co-authored-by: zzy <[email protected]>
Continue the fix from #6666 by converting remaining direct Body assignments to use setter methods: * pkg/fuzz/component/body.go:139: use `SetBodyReader()` in transfer-encoding path. * pkg/protocols/http/request.go:694: use `SetBodyString()` in fuzz component `Rebuild()`. Fixes #6692. Signed-off-by: Dwi Siswanto <[email protected]>
Proposed changes
fix(http): lost request body on retries & redirects
Updates the HTTP protocol to use
(*retryablehttp.Request).SetBodyStringinsteadof direct
Bodyassignment.This fixes #6665 where the request body was
dropped during retries or 307/308 redirects
because
GetBodywas not being populated.Thanks to @zzyjsj for reporting the bug in the
upstream dependency and the hints!
Checklist
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.