Skip to content

fix(network): guarded redirects survive cleanup rejection - #111156

Merged
steipete merged 3 commits into
openclaw:mainfrom
steipete:fix/guarded-redirect-cancel-rejection
Jul 19, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
steipete:fix/guarded-redirect-cancel-rejection

Conversation

@steipete

@steipete steipete commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where guarded fetch redirects could fail after receiving a valid redirect response when best-effort response-body cleanup rejected.

Why This Change Was Made

Redirect processing now observes and ignores only the asynchronous rejection from cancelling the superseded response body. Redirect validation, redirect limits, and all fetch failures retain their existing behavior. A native ReadableStream regression covers the two-hop redirect and verifies the process-level rejection listener is always removed. The adjacent web_fetch SSRF fixture now honors the promise-returning stream cancellation contract.

User Impact

Users can complete SSRF-guarded redirects even when the discarded redirect response cannot be cleanly cancelled.

Evidence

AI-assisted maintainer follow-up from the cancellation-rejection audit for #111105, #111106, and #111056.

@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Jul 19, 2026
@steipete
steipete force-pushed the fix/guarded-redirect-cancel-rejection branch from a48900e to 00094f6 Compare July 19, 2026 03:13
@steipete
steipete force-pushed the fix/guarded-redirect-cancel-rejection branch from 11afd63 to dc7ef73 Compare July 19, 2026 03:18
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 19, 2026
@clawsweeper

clawsweeper Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 18, 2026, 11:46 PM ET / July 19, 2026, 03:46 UTC.

Summary
The branch observes rejected cancellation of a superseded redirect response body in fetchWithSsrFGuard and adds native ReadableStream regression coverage.

PR surface: Source 0, Tests +51. Total +51 across 3 files.

Reproducibility: yes. A two-hop fetchWithSsrFGuard call using a native Response/ReadableStream whose discarded redirect body rejects during cancel() directly exercises the current-main detached-cleanup path.

Review metrics: none identified.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add a redacted production-entry proof using a native rejecting redirect-body cancellation and show both the successful final response and an empty unhandled-rejection result.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The body shows focused regression tests and CI/check output only; please add a redacted production-entry terminal transcript, runtime log, or equivalent live artifact showing the final redirect response succeeds with no unhandled rejection, then update the PR body for automatic re-review or ask a maintainer to comment @clawsweeper re-review.

Risk before merge

  • [P1] Because this changes a security-adjacent redirect lifecycle, the supplied test and CI evidence do not yet demonstrate the after-fix production entry path and absence of a process-level unhandled rejection in a real runtime setup.

Maintainer options:

  1. Decide the mitigation before merge
    Keep the one-line best-effort cleanup observer, then add a redacted production-entry proof that a native rejecting redirect-body cancellation still returns the final response without an unhandled rejection.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] The protected maintainer label and missing external real-behavior proof require a human merge decision after the contributor adds evidence; there is no mechanical patch defect for an automated repair lane.

Security
Cleared: The diff is confined to observing a rejected best-effort stream cleanup and test fixtures; it does not alter SSRF policy, credentials, dependencies, permissions, or supply-chain execution.

Review details

Best possible solution:

Keep the one-line best-effort cleanup observer, then add a redacted production-entry proof that a native rejecting redirect-body cancellation still returns the final response without an unhandled rejection.

Do we have a high-confidence way to reproduce the issue?

Yes. A two-hop fetchWithSsrFGuard call using a native Response/ReadableStream whose discarded redirect body rejects during cancel() directly exercises the current-main detached-cleanup path.

Is this the best way to solve the issue?

Yes. Catching only the detached cleanup promise is the narrowest maintainable fix because redirect validation and the final fetch result remain authoritative, and the related merged fixes use the same best-effort-cleanup principle.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b57660d02491.

Label changes

Label justifications:

  • P2: This is a bounded reliability fix in the shared guarded network-fetch path, with limited but cross-caller blast radius.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The body shows focused regression tests and CI/check output only; please add a redacted production-entry terminal transcript, runtime log, or equivalent live artifact showing the final redirect response succeeds with no unhandled rejection, then update the PR body for automatic re-review or ask a maintainer to comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source 0, Tests +51. Total +51 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 1 0
Tests 2 52 1 +51
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 53 2 +51

What I checked:

  • Current-main behavior: Current main manually follows redirects, performs all redirect validation and loop checks, then detaches response.body?.cancel() before closing the dispatcher; a rejected cancellation can therefore become a process-level unhandled rejection after a valid redirect response. (src/infra/net/fetch-guard.ts:698, b57660d02491)
  • Patch scope: The proposed runtime change catches only the promise rejection from detached response-body cancellation; it leaves redirect parsing, redirect limits, origin/header rewriting, dispatcher closing, and fetch failures unchanged. (src/infra/net/fetch-guard.ts:698, 0abe75b5525c)
  • Regression coverage: The added test uses a native ReadableStream whose cancellation throws, verifies the second redirect hop returns its body, checks cancellation was attempted once, and removes its process-level rejection listener in finally. (src/infra/net/fetch-guard.ssrf.test.ts:949, 0abe75b5525c)
  • Feature provenance: GitHub blame attributes the original guarded-fetch redirect cancellation line to the main-line SSRF-guard introduction, commit 81c68f582d4a9a20d9cca9f367d2da9edc5a65ae, which also moved web fetch onto fetchWithSsrFGuard. (src/infra/net/fetch-guard.ts:698, 81c68f582d4a)
  • Related cleanup audit: The linked merged Matrix, Tlon, and OpenRouter PRs address the same best-effort stream-cleanup rejection pattern in separate owner paths; they support the rationale but do not implement this generic guarded-fetch site. (ead8f691eacf)
  • Security pass: The attached Opengrep alert concerns pre-existing unbounded response reads in the web-fetch/media family, not this PR’s three-file cancellation-rejection change; this diff adds no dependency, action, permission, or request-policy surface. (src/infra/net/fetch-guard.ts:698, 0abe75b5525c)

Likely related people:

  • steipete: Authored the main-line commit that introduced the shared SSRF guarded-fetch path and its detached redirect-body cleanup, and is also carrying this narrow follow-up. (role: initial implementation author and recent area contributor; confidence: high; commits: 81c68f582d4a, 0abe75b5525c; files: src/infra/net/fetch-guard.ts, src/agents/tools/web-fetch.ssrf.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (1 earlier review cycle)
  • reviewed 2026-07-19T03:21:06.050Z sha dc7ef73129d2c8dd1127c57febf6c6851d9bc125 :: needs real behavior proof before merge. :: none

@steipete
steipete force-pushed the fix/guarded-redirect-cancel-rejection branch from dc7ef73 to 0abe75b Compare July 19, 2026 03:38
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Jul 19, 2026
@steipete
steipete merged commit 63f8b84 into openclaw:main Jul 19, 2026
130 of 131 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete
steipete deleted the fix/guarded-redirect-cancel-rejection branch July 19, 2026 03:48
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 19, 2026
…11156)

* fix(network): preserve redirects when cleanup fails

* test(network): bound redirect response assertion

* test(network): honor stream cancellation contract
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…11156)

* fix(network): preserve redirects when cleanup fails

* test(network): bound redirect response assertion

* test(network): honor stream cancellation contract
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants