Skip to content

feat(cron): allow trusted private webhook targets - #118286

Merged
steipete merged 1 commit into
mainfrom
codex/cron-webhook-ssrf-policy
Aug 3, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/cron-webhook-ssrf-policy

Conversation

@steipete

@steipete steipete commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #118237

Additional instructions

MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.

What Problem This Solves

Fixes an issue where operators sending automation webhooks to loopback or private-network receivers always got a recorded not-delivered result with no supported opt-in. The restriction also applied to completion destinations, failure destinations, and failure-alert webhooks, but the automation docs did not explain it.

Why This Change Was Made

Cron now exposes cron.webhookSsrfPolicy using one canonical four-field SSRF config type and Zod schema shared with browser and web fetch. The Gateway resolves that policy once per cron-service snapshot and passes it through the existing central guarded-fetch owner for primary, completion-destination, failure-destination, and failure-alert webhook sends. Omitted config remains strict.

Current source differed from the issue's file map: browser and web fetch had separate, disjoint inline schemas rather than the referenced shared object. This change first extracts the approved canonical schema/type, then reuses the existing mergeSsrFPolicies runtime primitive at all three surfaces. The cron key is flat because the existing cron config is flat around webhookToken, and cron.webhook is an explicitly retired namespace.

Config-surface metric: 9 intentional schema paths are added (the cron policy object plus four leaves, two new browser leaves, and two new web-fetch leaves). Generated core config entries move from 2309 to 2321 because array leaves also project item paths. Defaults do not change; every relaxation remains an explicit operator opt-in. Production code is +52 net lines, primarily the required shared type/schema/help/label contract and the central security-policy handoff; tests and docs are counted separately.

User Impact

Operators can now deliver automation webhooks to a trusted local or private service with a narrow exact-host exception such as allowedHostnames: ["127.0.0.1"], or use dangerouslyAllowPrivateNetwork: true when every configured automation webhook may reach trusted private-network services. Existing installations remain blocked by default.

Release note: Automation webhooks now support explicit private-network and exact-host SSRF policy opt-ins through cron.webhookSsrfPolicy, while retaining strict defaults.

Evidence

Source-blind packaged CLI/Gateway validation against a real 127.0.0.1 HTTP receiver passed:

  • With no policy, the job completed but recorded delivered: false, deliveryStatus: "not-delivered", and the SSRF block reason; the receiver saw zero requests.
  • With allowedHostnames: ["127.0.0.1"], the identical job and URL recorded delivered: true; the receiver saw a real POST.
  • After hot reload to dangerouslyAllowPrivateNetwork: true with an empty hostname list, the identical job and URL delivered a second real POST.
  • config validate --json accepted all four canonical leaves together with no warnings.
  • Wrong types for each leaf, a numeric allowedHostnames entry, and an unknown policy leaf were rejected.

Focused tests:

  • OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/run-vitest.mjs src/infra/net/ssrf.test.ts src/config/config-misc.test.ts src/config/schema.test.ts — 206 passed.
  • OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/run-vitest.mjs src/agents/tools/web-fetch.ssrf.test.ts — 13 passed.
  • OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/run-vitest.mjs src/gateway/server-cron-primary-webhook.test.ts src/gateway/server-cron-notifications.test.ts src/gateway/server-cron.test.ts — 92 passed.
  • OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/run-vitest.mjs extensions/browser/src/browser/config.test.ts — 69 passed, 1 skipped.
  • OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/run-vitest.mjs src/plugin-sdk/ssrf-policy.test.ts src/config/schema.help.quality.test.ts — 86 passed.

Changed gate:

  • node scripts/check-changed.mjs attempted the configured remote workload route, but Blacksmith/Testbox health failed and no owned-cloud broker was authenticated.
  • Per the trusted-source fallback policy, OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/check-changed.mjs passed the full selected core, core-test, extension, extension-test, docs, config-metadata, typecheck, lint, dead-code, SDK-contract, and architecture/security guard plan locally.
  • git diff --check — passed.

Review:

  • .agents/skills/autoreview/scripts/autoreview --mode local --engine codex --model gpt-5.6-sol --thinking high --stream-engine-output — clean, no accepted/actionable findings (0.97 confidence on the final diff).

Maintainer live proof (dist build, ephemeral gateway :19874, isolated state dir)

  • Config cron.webhookSsrfPolicy: { dangerouslyAllowPrivateNetwork: true } + loopback listener on 127.0.0.1:9151: command job with --webhook http://127.0.0.1:9151/hook → run status: ok, webhook payload received by the listener, run record shows "delivered": true, "deliveryStatus": "delivered".
  • Strict default (no policy): already live-proven on team.openclaw.ai during today's stress suite — same job shape records not-delivered with "Blocked hostname or private/internal/special-use IP address".

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 2, 2026
@steipete
steipete marked this pull request as ready for review August 2, 2026 23:02
@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Aug 2, 2026
@clawsweeper

clawsweeper Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 2, 2026, 7:49 PM ET / 23:49 UTC.

ClawSweeper review

What this changes

The branch adds cron.webhookSsrfPolicy, reuses one shared SSRF policy schema for cron, browser, and web fetch, and applies the cron policy to every guarded automation webhook delivery path.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

This is a coherent, well-proven implementation of the linked cron-webhook request. The patch keeps omitted configuration strict, routes the one resolved policy through primary, completion, failure-destination, and failure-alert webhook delivery, and preserves the central SSRF guard; no discrete correctness defect was found. Because the new setting intentionally authorizes every cron webhook route to reach trusted private targets, the remaining gate is explicit maintainer acceptance of that service-wide security boundary.

Priority: P2
Reviewed head: 3b96502baf412c35d4b34440ccb40ea787598921
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong real behavior evidence and a coherent owner-boundary implementation; the remaining gate is deliberate maintainer approval of the new security/configuration contract.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body gives after-fix packaged Gateway/CLI evidence: strict mode sent no loopback request, exact-host and broad opt-ins delivered real POSTs, and the result records changed from not-delivered to delivered.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body gives after-fix packaged Gateway/CLI evidence: strict mode sent no loopback request, exact-host and broad opt-ins delivered real POSTs, and the result records changed from not-delivered to delivered.
Evidence reviewed 8 items Current-main strict default: Current main calls the central guarded fetch without a policy for cron webhooks, so loopback and private targets remain blocked by the existing default.
Central policy contract: The guard treats private-network permission and exact allowed hostnames as explicit policy exceptions, while exact-host mode still rejects unsafe DNS answers such as link-local and metadata addresses.
Branch preserves the guard owner: The proposed cron delivery path adds the resolved policy as an argument to fetchWithSsrFGuard; it does not bypass the guarded-fetch implementation.
Findings None None.
Security None None.

How this fits together

Gateway cron jobs can send primary and follow-up webhook notifications after an automation run. The cron service reads operator configuration, passes the selected outbound policy to the central guarded-fetch layer, and records whether each delivery succeeded or was intentionally blocked.

flowchart LR
  Config[Operator cron configuration] --> Snapshot[Cron service snapshot]
  Job[Automation job and delivery target] --> Delivery[Primary and follow-up webhook delivery]
  Snapshot --> Policy[Resolved SSRF policy]
  Policy --> Guard[Central guarded fetch]
  Delivery --> Guard
  Guard --> Outcome[Delivered or recorded not-delivered outcome]
Loading

Decision needed

Question Recommendation
Should a single cron.webhookSsrfPolicy authorize trusted private targets across every cron webhook route, or should OpenClaw require a narrower per-job permission model? Accept the service-wide cron policy: Merge the documented strict-by-default policy, using exact hostnames as the normal path and retaining the broad private-network flag only for operator-owned deployments.

Why: Both choices are viable product/security contracts. The branch is mechanically coherent, but only maintainers can choose the intended blast radius of a configuration-controlled SSRF relaxation.

Before merge

  • Resolve merge risk (P1) - dangerouslyAllowPrivateNetwork: true is intentionally service-wide: it permits trusted private targets for primary, completion, failure-destination, and failure-alert cron webhooks, rather than only one job. The strict default and narrow allowedHostnames path reduce the upgrade risk, but maintainers must explicitly accept that scope.
  • Complete next step (P2) - No mechanical repair is needed; a maintainer must decide whether the intended cron-wide private-network permission scope is acceptable.
Agent review details

Security

None.

PR surface

Source +57, Tests +114, Docs +42, Generated +2. Total +215 across 30 files.

View PR surface stats
Area Files Added Removed Net
Source 16 118 61 +57
Tests 7 135 21 +114
Docs 4 44 2 +42
Config 0 0 0 0
Generated 3 7 5 +2
Other 0 0 0 0
Total 30 304 89 +215

Review metrics

Metric Value Why it matters
SSRF configuration surface 1 cron policy object and 4 cron leaves added; 2 browser and 2 web-fetch leaves aligned These settings intentionally expand the operator-controlled outbound-network contract and require explicit security-boundary acceptance.

Stored data model

Persistent data-model change detected: unknown-data-model-change: src/config/schema.help.runtime.ts, unknown-data-model-change: src/config/schema.labels.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #118237
Summary: This PR is the concrete candidate implementation for the linked open request concerning cron webhook SSRF opt-ins.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Accept the documented service-wide opt-in (recommended)
    Approve the branch if maintainers accept that one cron setting governs all automation webhook routes while omitted configuration remains fail-closed.
  2. Redesign around a per-job permission
    Pause this branch if the intended security contract requires a separate authorization decision for each webhook destination.

Technical review

Best possible solution:

Accept the flat cron.webhookSsrfPolicy surface only if maintainers want one documented, operator-owned policy for every cron webhook route; retain strict defaults and recommend exact allowedHostnames over the broad private-network opt-in.

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

Yes, source-reproducible: current main’s cron test and guarded-fetch call establish that loopback delivery records not-delivered under the strict default. This read-only review did not execute it, while the PR body provides after-fix packaged Gateway evidence against a real loopback receiver.

Is this the best way to solve the issue?

Yes, subject to the maintainer security-scope choice: resolving one canonical policy at the cron-service boundary and passing it through the existing guard is cleaner than duplicating SSRF logic or adding per-route exceptions.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded automation capability improvement with clear operator impact but no default-path regression.
  • merge-risk: 🚨 security-boundary: Merging adds an operator opt-in that permits cron webhook delivery to otherwise blocked private-network targets.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body gives after-fix packaged Gateway/CLI evidence: strict mode sent no loopback request, exact-host and broad opt-ins delivered real POSTs, and the result records changed from not-delivered to delivered.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body gives after-fix packaged Gateway/CLI evidence: strict mode sent no loopback request, exact-host and broad opt-ins delivered real POSTs, and the result records changed from not-delivered to delivered.

Evidence

What I checked:

  • Current-main strict default: Current main calls the central guarded fetch without a policy for cron webhooks, so loopback and private targets remain blocked by the existing default. (src/gateway/server-cron-notifications.ts:230, b7f9cd0a0167)
  • Central policy contract: The guard treats private-network permission and exact allowed hostnames as explicit policy exceptions, while exact-host mode still rejects unsafe DNS answers such as link-local and metadata addresses. (src/infra/net/ssrf.ts:231, b7f9cd0a0167)
  • Branch preserves the guard owner: The proposed cron delivery path adds the resolved policy as an argument to fetchWithSsrFGuard; it does not bypass the guarded-fetch implementation. (src/gateway/server-cron-notifications.ts:235, 3b96502baf41)
  • All cron webhook routes receive one snapshot policy: The branch resolves cron.webhookSsrfPolicy once and passes it to primary delivery, completion/failure destinations, and failure-alert delivery. (src/gateway/server-cron.ts:286, 3b96502baf41)
  • Schema and strict configuration shape: The new shared strict Zod object contains four explicit operator-controlled leaves, and cron accepts it only as webhookSsrfPolicy. (src/config/zod-schema.root-shape.ts:316, 3b96502baf41)
  • Cache partition follows broadened web-fetch policy: The shared web-fetch expansion includes private-network and hashed allowed-hostname policy discriminators before reading the process-wide cache, avoiding a cross-policy cached result reuse. (src/agents/tools/web-fetch.ts:711, 3b96502baf41)

Likely related people:

  • steipete: Recent current-main cron notification work and the branch’s policy handoff/cache partition are attributed to this contributor. (role: recent cron delivery contributor and proposed-change author; confidence: high; commits: 3b96502baf41, 383363e36233, 761c3e33be19; files: src/gateway/server-cron.ts, src/gateway/server-cron-notifications.ts, src/agents/tools/web-fetch.ts)
  • Ian Moog: Recent history shows direct maintenance of the pinned-address SSRF guard that this feature relies on. (role: recent SSRF hardening contributor; confidence: medium; commits: 40c17e76da21; files: src/infra/net/ssrf.ts, src/infra/net/fetch-guard.ts)
  • mushuiyu886: Recent history includes the web-fetch cache partitioning work extended by this branch for the new policy fields. (role: recent web-fetch cache contributor; confidence: medium; commits: 20c959c22766, f9ede1e39aee; files: src/agents/tools/web-fetch.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Obtain explicit maintainer acceptance of the service-wide cron webhook SSRF scope before merge.

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 (2 earlier review cycles)
  • reviewed 2026-08-02T23:07:22.749Z sha b1b5beae0f8620ec5211fe6b3d15aaf3db468058 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-02T23:22:46.556Z sha b1b5beae0f8620ec5211fe6b3d15aaf3db468058 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the codex/cron-webhook-ssrf-policy branch from b1b5bea to 3b96502 Compare August 2, 2026 23:43
@steipete
steipete merged commit e9d8869 into main Aug 3, 2026
120 checks passed
@steipete
steipete deleted the codex/cron-webhook-ssrf-policy branch August 3, 2026 00:02
@steipete

steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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.

[Feature]: operator escape hatch for cron webhooks to loopback/private targets (SSRF guard has no cron policy wiring)

1 participant