Skip to content

fix: add ssrf protection to Beam fetches - #123848

Merged
joshavant merged 8 commits into
openclaw:mainfrom
sjudson:ptp-oc-info-3
Aug 19, 2026
Merged

joshavant merged 8 commits into
openclaw:mainfrom
sjudson:ptp-oc-info-3

Conversation

@sjudson

@sjudson sjudson commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

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.endpoint must be the final receiver URL.

  • Redirect responses (301, 302, 303, 307, and 308) are never followed.
  • Within one mirror service instance, a redirect blocks later polls from resending the same sensitive POST.
  • Delivery resumes when the operator changes mirror.endpoint. A fresh service also probes the configured endpoint once so a receiver corrected in place can recover without a meaningless config change.
  • The warning identifies the redirect status and tells the operator to configure the final endpoint, but does not log Location.
  • Transient network and non-redirect HTTP failures remain retryable.

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 GuardedFetchRedirectError in 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

  • Routes Beam uploads through fetchWithSsrFGuard with the configured endpoint's exact-origin policy, DNS pinning, a 15-second timeout, and maxRedirects: 0.
  • Adds the typed GuardedFetchRedirectError at the shared guarded-fetch owner boundary and exports it through openclaw/plugin-sdk/ssrf-runtime.
  • Blocks repeated sends only for the redirecting endpoint while preserving retry behavior for transient failures.
  • Cancels ignored response bodies and releases dispatcher resources.
  • Documents the final-URL requirement in Beam configuration help and operator troubleshooting.

Relevant boundaries:

  • extensions/beam/src/mirror.ts owns upload policy, endpoint blocking, operator feedback, and delivery acknowledgement.
  • src/infra/net/fetch-guard.ts owns redirect classification and cleanup.
  • src/plugin-sdk/ssrf-runtime.ts exposes 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; fetch was not mocked. After a conflict-free rebase onto current main, the current head (3ff9a350c50) passed the same 27-test file locally:

$ node scripts/run-vitest.mjs extensions/beam/src/mirror.test.ts
Test Files  1 passed (1)
Tests       27 passed (27)

Coverage proves:

  • Cross-origin private redirect: one configured receiver request, zero redirected-target requests, and no POST replay.
  • All recognized redirect statuses: 301, 302, 303, 307, and 308, including a redirect without Location.
  • Two unchanged ticks after a redirect: one configured endpoint request total, one actionable warning, no leaked Location value.
  • Service restart: a fresh runner probes the configured endpoint once, while still refusing its redirect.
  • Endpoint correction: delivery resumes after mirror.endpoint changes to a direct URL.
  • Existing transient failure behavior: a 503 response is retried on the next tick.
  • Terminal recovery signal ordering: after a 503 warning, a 307 still emits the final-endpoint warning before the endpoint is blocked; a third tick sends no request.

Autoreview also completed cleanly with no accepted or actionable findings.

Review Surface

  • Production: +65/-14 (net +51). The growth establishes the shared typed redirect boundary, terminal endpoint state, cleanup, and operator-visible recovery path.
  • Tests: +277/-2 (net +275).
  • Docs, metadata, and SDK tooling: +9/-4 (net +5).

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.

@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added plugin: beam Beam session sharing plugin size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 14, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Aug 14, 2026
@clawsweeper

clawsweeper Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 18, 2026, 8:09 PM ET / August 19, 2026, 00:09 UTC.

ClawSweeper review

What this changes

This 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 readiness

⚠️ Ready for maintainer review - 2 items remain

No 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
Reviewed head: 3ff9a350c50580dc2c13616f8f6d3677da3c6f43

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong loopback transport proof, a focused owner-boundary implementation, and an explicit SDK-contract approval support a high-confidence merge review.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR records real loopback-server behavior through the production Beam runner with no mocked fetch, plus a final-head terminal run of the 27-test file.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR records real loopback-server behavior through the production Beam runner with no mocked fetch, plus a final-head terminal run of the 27-test file.
Evidence reviewed 7 items Current-main vulnerable path: Current main posts directly with the injected or global fetch implementation and does not set manual redirect handling, so a redirect can be followed by the platform fetch path.
Owner-boundary repair: The PR routes the upload through the existing guarded-fetch primitive with an exact-origin policy, DNS pinning, timeout, and zero redirects; a redirect becomes a terminal endpoint state while other errors continue to the existing retry path.
Shared redirect classification: Guarded fetch throws the typed error before reading Location when the redirect budget is exhausted, and its catch path cancels the response and releases the dispatcher.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs extensions/beam/src/mirror.test.ts

Result: PASS (completed)

node scripts/run-vitest.mjs extensions/beam/src/mirror.test.ts
runner@runnervmzvulz:/tmp/clawsweeper-live-proof-123848-TVQSyf/target$ node scripts/run-vitest.mjs extensions/beam/src/mirror.test.ts
node scripts/run-vitest.mjs extensions/beam/src/mirror.test.ts
[test] starting test/vitest/vitest.extensions.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-123848-TVQSyf/target

 ✓  extensions  extensions/beam/src/mirror.test.ts (27 tests) 143ms

 Test Files  1 passed (1)
      Tests  27 passed (27)
   Start at  00:10:10
   Duration  25.57s (transform 21.00s, setup 1.03s, import 24.03s, tests 143ms, environment 0ms)

[test] passed 1 Vitest shard in 31.57s
runner@runnervmzvulz:/tmp/clawsweeper-live-proof-123848-TVQSyf/target$ node scripts/run-vitest.mjs extensions/beam/src/mirror.test.ts



































Assertions:

  • PASS expect_output: Test Files
  • PASS expect_output: Tests

How this fits together

Beam 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]
Loading

Before merge

  • Resolve merge risk (P1) - Existing Beam installations whose receiver redirects will stop mirroring until the operator configures the final receiver URL; this intentional compatibility change is documented but still needs exact-head merge validation.
  • Resolve merge risk (P1) - The repair adds 51 net production lines; the shared typed redirect condition and per-run endpoint block are justified because the mirror otherwise cannot distinguish terminal redirects from retryable transport failures.
Agent review details

Security

None.

PR surface

Source +51, Tests +275, Docs +4, Other +1. Total +331 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 4 66 15 +51
Tests 1 277 2 +275
Docs 2 6 2 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 1 +1
Total 8 351 20 +331

Review metrics

Metric Value Why it matters
Production versus test delta production +51 net; tests +275 net; docs/metadata/tooling +5 net The production growth implements a shared terminal redirect condition and endpoint state, while the larger test addition covers real loopback delivery behavior.
Mirror endpoint contract 1 existing setting changed mirror.endpoint now must be the final receiver URL, so upgrades with redirecting receivers need the documented operator action.

Stored data model

Persistent data-model change detected: serialized state: extensions/beam/src/mirror.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Validate the merge head (recommended)
    Let required checks complete on the clean mergeable head before landing the documented direct-receiver behavior.
  2. Accept the direct-only upgrade
    Maintain the intentional break for redirecting receivers rather than restoring redirect following, which would reopen the sensitive POST replay boundary.

Technical review

Best 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.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P1: The PR addresses replay of authenticated mirrored session content across an outbound delivery boundary.
  • merge-risk: 🚨 compatibility: Redirecting existing Beam receiver endpoints will no longer deliver until configured with their final URL.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR records real loopback-server behavior through the production Beam runner with no mocked fetch, plus a final-head terminal run of the 27-test file.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR records real loopback-server behavior through the production Beam runner with no mocked fetch, plus a final-head terminal run of the 27-test file.

Evidence

What I checked:

  • Current-main vulnerable path: Current main posts directly with the injected or global fetch implementation and does not set manual redirect handling, so a redirect can be followed by the platform fetch path. (extensions/beam/src/mirror.ts:290, 10610d9f639e)
  • Owner-boundary repair: The PR routes the upload through the existing guarded-fetch primitive with an exact-origin policy, DNS pinning, timeout, and zero redirects; a redirect becomes a terminal endpoint state while other errors continue to the existing retry path. (extensions/beam/src/mirror.ts:303, 3ff9a350c505)
  • Shared redirect classification: Guarded fetch throws the typed error before reading Location when the redirect budget is exhausted, and its catch path cancels the response and releases the dispatcher. (src/infra/net/fetch-guard.ts:735, 3ff9a350c505)
  • Behavioral test coverage: The changed Beam test uses real loopback HTTP servers to prove one receiver POST, no redirected-target POST, all redirect statuses, endpoint suppression, restart probing, endpoint correction, and retained 503 retries. (extensions/beam/src/mirror.test.ts:261, 3ff9a350c505)
  • SDK contract approval: The supplied review comment from joshavant explicitly approves exposing GuardedFetchRedirectError through the existing public SSRF runtime subpath; the PR also updates that subpath’s documentation and surface budget. (src/plugin-sdk/ssrf-runtime.ts:19, 3ff9a350c505)
  • Feature provenance: Beam mirroring dates to the merged feature commit, while guarded redirect cleanup has separate established history; current-main blame identifies Peter Steinberger on both surrounding paths. (extensions/beam/src/mirror.ts:290, 7e8afba70325)

Likely related people:

  • Peter Steinberger: Introduced Beam mirroring and has the current-main blame/history for the surrounding mirror and guarded-fetch behavior. (role: feature owner and recent area contributor; confidence: high; commits: 7e8afba70325, 63f8b8454b75; files: extensions/beam/src/mirror.ts, src/infra/net/fetch-guard.ts)
  • joshavant: Provided the explicit approval for the public redirect-error export and carried the final branch commits that implement it. (role: SDK contract reviewer; confidence: high; commits: 3ff9a350c505; files: src/plugin-sdk/ssrf-runtime.ts, scripts/plugin-sdk-surface-report.mts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (14 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-18T21:41:59.263Z sha 7249ac1e986d850ef9b3e19f15c851639e04c868 :: found issues before merge. :: [P1] Rebase the SDK export budget against current main
  • reviewed 2026-08-18T22:19:23.311Z sha 7a9ba124da409ac13f1d001475ebdf8143e1b2ac :: found issues before merge. :: [P1] Obtain approval before exporting the redirect error
  • reviewed 2026-08-18T22:31:27.844Z sha 7a9ba124da409ac13f1d001475ebdf8143e1b2ac :: found issues before merge. :: [P1] Obtain SDK-owner approval for the redirect-error export
  • reviewed 2026-08-18T22:39:57.035Z sha 7a9ba124da409ac13f1d001475ebdf8143e1b2ac :: found issues before merge. :: [P1] Record SDK-owner approval for the public redirect-error export
  • reviewed 2026-08-18T22:52:23.309Z sha 7a9ba124da409ac13f1d001475ebdf8143e1b2ac :: needs changes before merge. :: [P1] Always log the first terminal redirect block
  • reviewed 2026-08-18T23:09:19.285Z sha 0d6d6bb0d0f6ae35938e73cfd62ff742ed683457 :: needs real behavior proof before merge. :: [P1] Always emit the first redirect-block recovery warning
  • reviewed 2026-08-18T23:23:44.527Z sha 5d7bb3e86dd1759ed2e60f7c08d4b921419d4045 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-18T23:44:14.379Z sha 5d7bb3e86dd1759ed2e60f7c08d4b921419d4045 :: needs maintainer review before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Aug 14, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 14, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 17, 2026
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Aug 18, 2026
@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 18, 2026
@joshavant

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 18, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 19, 2026
@joshavant
joshavant merged commit 6ccc57b into openclaw:main Aug 19, 2026
246 of 256 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 20, 2026
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. plugin: beam Beam session sharing plugin proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. scripts Repository scripts size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants