Repository navigation
fix: add ssrf protection to Beam fetches - #123848
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 18, 2026, 8:09 PM ET / August 19, 2026, 00:09 UTC. ClawSweeper reviewWhat this changesThis PR sends Beam mirror uploads through the shared SSRF guard, refuses redirects without replaying the POST body, and documents the required final receiver URL. Merge readinessNo blocking findings. The final head fixes the raw-fetch redirect path at the Beam owner boundary, preserves retry behavior for non-redirect failures, and has recorded loopback behavior proof; merge after exact-head checks complete. Likely related people: Peter Steinberger and joshavant. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherBeam mirrors redacted local session content to a configured remote receiver. Its mirror runner delegates outbound policy to guarded fetch, then records delivery, retries transient failures, or tells the operator how to recover from a terminal redirect. flowchart LR
A[Local session catalogs] --> B[Beam mirror runner]
B --> C[Guarded outbound fetch]
C --> D{Receiver response}
D -->|Success| E[Record delivered snapshot]
D -->|Transient failure| F[Retry next poll]
D -->|Redirect| G[Warn and block endpoint]
G --> H[Configure final receiver URL]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +51, Tests +275, Docs +4, Other +1. Total +331 across 8 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the direct-only delivery contract after exact-head checks pass, retaining the generic shared redirect error so Beam can classify a terminal redirect without duplicating guarded-fetch policy. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible with high confidence: current main posts via ordinary fetch, while the changed loopback-server test returns a redirect and observes that no redirected target receives the payload. Is this the best way to solve the issue? Yes. Using the shared guarded-fetch owner preserves DNS pinning and resource cleanup, while Beam alone owns direct-only acknowledgement, endpoint blocking, and operator recovery; a Beam-local redirect implementation would duplicate the transport policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 10610d9f639e. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (14 earlier review cycles; latest 8 shown)
|
d446dd5 to
ae318c7
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
5d7bb3e to
3ff9a35
Compare
* Add ssrf protection to Beam fetches. * Additional robustness following initial comments. * fix(beam): make redirect failures terminal * chore(plugin-sdk): refresh surface budget * docs(beam): define redirect restart behavior * docs(beam): align redirect config help * test(beam): cover warning before redirect block * fix(beam): always report terminal redirect blocks --------- Co-authored-by: joshavant <[email protected]>
What Problem This Solves
Beam mirror uploads carry session content and an optional bearer token. Before this change, the configured receiver could redirect that POST and cause the request body to be replayed to another origin.
Product Decision
Maintainer product decision (accepted): land the direct-only upgrade contract and require redirecting deployments to configure the final receiver URL.
Beam mirror delivery is direct-only. The configured
mirror.endpointmust be the final receiver URL.mirror.endpoint. A fresh service also probes the configured endpoint once so a receiver corrected in place can recover without a meaningless config change.Location.This intentionally changes the valid flow for deployments whose receiver currently redirects. Those operators must configure the final destination directly; there is no redirect compatibility switch because it would reopen the payload-forwarding boundary.
SDK-owner decision (approved): keep
GuardedFetchRedirectErrorin the public SSRF runtime subpath. It types an existing generic terminal condition of the already-public guarded-fetch primitive, lets plugins classify redirect-limit failures without matching error text, and exposes no new authority or Beam-specific policy. The scoped SDK restriction on single-consumer provider-local wrappers does not apply to this shared transport contract.Implementation
fetchWithSsrFGuardwith the configured endpoint's exact-origin policy, DNS pinning, a 15-second timeout, andmaxRedirects: 0.GuardedFetchRedirectErrorat the shared guarded-fetch owner boundary and exports it throughopenclaw/plugin-sdk/ssrf-runtime.Relevant boundaries:
extensions/beam/src/mirror.tsowns upload policy, endpoint blocking, operator feedback, and delivery acknowledgement.src/infra/net/fetch-guard.tsowns redirect classification and cleanup.src/plugin-sdk/ssrf-runtime.tsexposes the typed failure without a Beam-specific network implementation.Evidence
Real Behavior Proof
ClawSweeper exercised the pre-rebase patch head (
5d7bb3e86dd) in its isolated runner with the production Beam runner and real loopback HTTP servers;fetchwas not mocked. After a conflict-free rebase onto current main, the current head (3ff9a350c50) passed the same 27-test file locally:Coverage proves:
Location.Locationvalue.mirror.endpointchanges to a direct URL.Autoreview also completed cleanly with no accepted or actionable findings.
Review Surface
Trail of Bits developed this fix as part of the Patch The Planet project in collaboration with OpenAI. The issue was identified and fixed primarily by the Codex coding agent, and manually reviewed before submission.