Skip to content

test(plugin-sdk): cover origin trust SSRF edges - #97674

Closed
lin-hongkuan wants to merge 3 commits into
openclaw:mainfrom
lin-hongkuan:test/plugin-sdk-origin-trust-docs
Closed

lin-hongkuan wants to merge 3 commits into
openclaw:mainfrom
lin-hongkuan:test/plugin-sdk-origin-trust-docs

Conversation

@lin-hongkuan

@lin-hongkuan lin-hongkuan commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds the remaining origin-trust SSRF edge coverage and plugin SDK docs requested by #81963.

Issue / Motivation

Fixes #81963.

The core origin-scoped SSRF behavior already landed in #80751. The follow-up issue asks for narrow provider baseUrl normalization coverage plus documentation of the trust semantics for plugin authors, without changing runtime policy.

Changes

  • Add regression coverage for provider baseUrl origin normalization:
    • trailing slash/path ignored for origin trust
    • default HTTP/HTTPS ports elided
    • userinfo stripped by URL.origin
    • configured trailing-dot hosts match their dotless request origin
  • Add a concurrent isolation test showing overlapping private origins with different ports do not leak trust between configured base URLs.
  • Document exact-origin trust semantics in docs/plugins/sdk-subpaths.md, including redirect re-evaluation and continued metadata/link-local/private-network resolver blocking.

Testing

  • pnpm exec vitest run src/infra/net/ssrf.test.ts
    • 57 tests passed on the previous head; exact-head local rerun is unavailable in the low-disk worktree because workspace dependencies are not installed, so exact-head CI is the runtime-test authority
  • pnpm oxfmt --check src/infra/net/ssrf.test.ts docs/plugins/sdk-subpaths.md
    • All matched files use the correct format.
  • git diff --check
    • passed
  • staged diff secret scan
    • no secret-like added lines

What Problem This Solves

Plugin/provider authors need a precise contract for when configured baseUrl values may promote a private hostname through the SSRF guard. This PR pins the intended origin-normalization behavior in tests and documents that the trust is exact-origin, per-request, and does not bypass resolver-level metadata/link-local/private network protections.

Evidence

Exact-head static validation passed: npx --yes oxfmt@latest --check docs/plugins/sdk-subpaths.md src/infra/net/ssrf.test.ts, npx --yes oxlint@latest --tsconfig config/tsconfig/oxlint.core.json src/infra/net/ssrf.test.ts, node scripts/generate-docs-map.mjs --check, git diff --check, and diff secret scan. The new regression directly covers the configured trailing-dot baseUrl contract identified in review. The PR intentionally contains tests/docs only and does not change production SSRF policy behavior.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: XS labels Jun 29, 2026
@clawsweeper

clawsweeper Bot commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 1, 2026, 4:56 AM ET / 08:56 UTC.

ClawSweeper review

What this changes

This PR adds origin-normalization and isolation coverage for provider baseUrl SSRF trust, plus plugin SDK documentation describing exact-origin semantics.

Merge readiness

⛔ Blocked until real behavior proof is added - 6 items remain

Keep this PR open: its normalization tests and plugin SDK documentation remain absent from current main, but its claimed concurrent-isolation coverage is not actually concurrent and the external PR still lacks current-head real-behavior evidence.

Priority: P2
Reviewed head: 47f0dcd2dab1535258b8c1a44b0bd17df1dc24fd

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The follow-up is focused and mostly aligned with current policy, but missing real behavior proof and the non-concurrent isolation test leave it below merge readiness.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: The PR body shows static validation and prior focused-test claims, but no redacted current-head after-fix guarded-fetch or provider-transport output demonstrating isolated behavior; add terminal output, logs, or a recording and redact private endpoints, IPs, credentials, and tokens. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body shows static validation and prior focused-test claims, but no redacted current-head after-fix guarded-fetch or provider-transport output demonstrating isolated behavior; add terminal output, logs, or a recording and redact private endpoints, IPs, credentials, and tokens. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Current origin normalization: Current main parses HTTP(S) URLs, removes trailing hostname dots, and returns a lower-cased serialized origin; this supports the path, default-port, userinfo, host-case, and trailing-dot assertions proposed here.
Current request-scoped trust owner: Current main only adds the current request hostname after the normalized request origin matches an allowed origin, so redirects must re-evaluate their own URL.
Concurrent test does not overlap work: The new Promise.all inputs synchronously call the pure resolver before Promise.resolve wraps their completed values, so this is equivalent to sequential calls and cannot detect leakage through an actual overlapping guarded-fetch or provider-transport path.
Findings 1 actionable finding [P2] Exercise actual overlapping guarded requests
Security None None.

How this fits together

Configured provider and plugin HTTP requests pass through OpenClaw's SSRF guard before DNS resolution and outbound transport. A matching configured origin can promote only the current request hostname, while redirects and resolver-level private-network blocks are evaluated independently.

flowchart LR
  A[Configured provider base URL] --> B[Origin normalization]
  B --> C[Per-request SSRF policy]
  C --> D[Guarded fetch redirect loop]
  D --> E[Resolver safety checks]
  E --> F[Provider HTTP request]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body shows static validation and prior focused-test claims, but no redacted current-head after-fix guarded-fetch or provider-transport output demonstrating isolated behavior; add terminal output, logs, or a recording and redact private endpoints, IPs, credentials, and tokens. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Exercise actual overlapping guarded requests (P2) - resolveSsrFPolicyForUrl runs synchronously before each Promise.resolve, so Promise.all only awaits three completed values. This is equivalent to sequential calls and cannot detect trust leaking through an overlapping guarded-fetch or provider-transport path; replace it with a boundary-level overlap test.
  • Resolve merge risk (P1) - GitHub reports this PR as dirty against current main, so it needs a rebase and refreshed review before it can merge.
  • Resolve merge risk (P1) - The test currently presents a security-isolation guarantee without exercising simultaneous guarded requests or a transport boundary where shared state could leak.
  • Resolve merge risk (P1) - The PR body provides static checks and earlier focused-test claims, but no redacted current-head after-fix runtime output demonstrating the intended isolated request behavior.
  • Complete next step (P2) - The contributor must supply real behavior proof and resolve the current dirty merge state; the remaining test repair is concrete but cannot satisfy the contributor-proof gate by automation alone.

Findings

  • [P2] Exercise actual overlapping guarded requests — src/infra/net/ssrf.test.ts:276-280
Agent review details

Security

None.

PR surface

Tests +47, Docs +11. Total +58 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 47 0 +47
Docs 1 11 0 +11
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 58 0 +58

Review metrics

None.

Stored data model

Persistent data-model change detected: vector/embedding metadata: docs/plugins/sdk-subpaths.md. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Prove transport-level isolation before merge (recommended)
    Rebase the branch, exercise genuinely overlapping guarded requests for distinct configured origins, and attach redacted current-head runtime proof that cross-port trust remains blocked.
  2. Pause the follow-up
    Keep the original merged SSRF policy as the supported behavior and defer this tests-and-docs follow-up until its security-boundary proof can cover the real request path.

Technical review

Best possible solution:

Rebase onto current main, replace the Promise-wrapped resolver assertions with an overlapping guarded-fetch or provider-transport test for two distinct private origins, and add redacted current-head runtime evidence showing each configured origin succeeds while the cross-port request remains blocked.

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

Yes for the review finding: source inspection shows each resolver call completes synchronously before Promise.all receives its resolved values, so the added test cannot reproduce real overlap. No current-main SSRF regression was independently reproduced in this read-only review.

Is this the best way to solve the issue?

No: the normalization cases and documentation are appropriate, but a pure resolver test wrapped in promises is not the best way to establish concurrent isolation. The narrow maintainable proof is an overlapping request at the existing guarded-fetch or provider-transport boundary.

Full review comments:

  • [P2] Exercise actual overlapping guarded requests — src/infra/net/ssrf.test.ts:276-280
    resolveSsrFPolicyForUrl runs synchronously before each Promise.resolve, so Promise.all only awaits three completed values. This is equivalent to sequential calls and cannot detect trust leaking through an overlapping guarded-fetch or provider-transport path; replace it with a boundary-level overlap test.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded security-hardening follow-up whose remaining defect is limited to coverage and proof rather than a demonstrated runtime regression.
  • merge-risk: 🚨 security-boundary: The PR documents and claims coverage for an SSRF trust invariant, but its named concurrency test does not exercise concurrent request behavior.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body shows static validation and prior focused-test claims, but no redacted current-head after-fix guarded-fetch or provider-transport output demonstrating isolated behavior; add terminal output, logs, or a recording and redact private endpoints, IPs, credentials, and tokens. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Current origin normalization: Current main parses HTTP(S) URLs, removes trailing hostname dots, and returns a lower-cased serialized origin; this supports the path, default-port, userinfo, host-case, and trailing-dot assertions proposed here. (src/infra/net/ssrf.ts:156, 41051fe37c7f)
  • Current request-scoped trust owner: Current main only adds the current request hostname after the normalized request origin matches an allowed origin, so redirects must re-evaluate their own URL. (src/infra/net/ssrf.ts:238, 41051fe37c7f)
  • Concurrent test does not overlap work: The new Promise.all inputs synchronously call the pure resolver before Promise.resolve wraps their completed values, so this is equivalent to sequential calls and cannot detect leakage through an actual overlapping guarded-fetch or provider-transport path. (src/infra/net/ssrf.test.ts:276, 47f0dcd2dab1)
  • Core feature provenance: The underlying exact-origin SSRF policy was merged in the earlier core implementation; this PR is a follow-up for tests and documentation rather than a runtime-policy change. (src/infra/net/ssrf.ts:186, 44840007d42d)
  • Current-main comparison: Current main does not contain this PR's added normalization cases, concurrent-isolation test, or SDK trust paragraph; the follow-up is not implemented on main. Public docs: docs/plugins/sdk-subpaths.md. (docs/plugins/sdk-subpaths.md:238, 41051fe37c7f)

Likely related people:

  • Kaspre: Authored and merged the original exact-origin provider baseUrl SSRF policy that this PR extends with coverage and documentation. (role: feature owner; confidence: high; commits: 44840007d42d; files: src/infra/net/ssrf.ts)
  • Yuval Dinodia: Current-main blame attributes the active SSRF origin-policy implementation lines to this recent source-history commit, making them a useful routing contact for current behavior. (role: recent area contributor; confidence: medium; commits: c13a0493aa10; files: src/infra/net/ssrf.ts)

Rank-up moves

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

  • Rebase onto current main and resolve the dirty merge state.
  • Replace the Promise-wrapped resolver test with overlapping guarded-fetch or provider-transport coverage.
  • Attach redacted current-head runtime output showing allowed configured origins and blocked cross-port access.

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 (6 earlier review cycles)
  • reviewed 2026-06-30T12:36:46.987Z sha 5b94f632bacc32bcde43a13859bab842cbad9e04 :: needs real behavior proof before merge. :: [P2] Narrow the resolver-blocking claim
  • reviewed 2026-07-18T01:18:28.439Z sha 76d33bcca65451cc561236c7b2aa2adea57e9550 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-18T02:07:54.741Z sha 4fc78732fc0d3ad0280aa6b734d85a2ededf1107 :: needs real behavior proof before merge. :: [P2] Remove the unproven trailing-dot trust guarantee
  • reviewed 2026-07-18T03:10:55.441Z sha 743885d3376f1edfa665ffdd5e0d4a0d951c3bc6 :: needs real behavior proof before merge. :: [P2] Describe trailing-dot normalization separately from URL.origin
  • reviewed 2026-07-18T05:13:21.646Z sha 47f0dcd :: needs real behavior proof before merge. :: [P2] Exercise actual overlap for origin-isolation coverage
  • reviewed 2026-07-29T21:49:18.359Z sha 47f0dcd :: needs real behavior proof before merge. :: [P2] Exercise real overlap for the isolation guarantee

@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jun 29, 2026
@lin-hongkuan

Copy link
Copy Markdown
Contributor Author

Ensured the PR body has explicit real-behavior proof sections for the proof gate.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 30, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 15, 2026
@lin-hongkuan

Copy link
Copy Markdown
Contributor Author

Rebased the focused issue-backed patch onto current main in commit ``, preserving the newer webhook-request-guards documentation while resolving the docs overlap. Validation: npx --yes oxfmt@latest --check docs/plugins/sdk-subpaths.md src/infra/net/ssrf.test.ts — passed (2 files); `npx --yes oxlint@latest --tsconfig config/tsconfig/oxlint.core.json src/infra/net/ssrf.test.ts` — 0 warnings, 0 errors; `git diff origin/main...HEAD --check` — passed; diff secret scan — clean. The focused Vitest run could not execute locally because dependencies are absent and pnpm's automatic install failed in the sparse low-disk worktree; exact-head CI is the remaining test read-back.

@lin-hongkuan
lin-hongkuan force-pushed the test/plugin-sdk-origin-trust-docs branch from 5b94f63 to 76d33bc Compare July 18, 2026 01:14
@lin-hongkuan

Copy link
Copy Markdown
Contributor Author

Correction/read-back: the refreshed public head is now 76d33bcca65451cc561236c7b2aa2adea57e9550. Exact local validation remains: npx --yes oxfmt@latest --check docs/plugins/sdk-subpaths.md src/infra/net/ssrf.test.ts — passed (2 files); npx --yes oxlint@latest --tsconfig config/tsconfig/oxlint.core.json src/infra/net/ssrf.test.ts — 0 warnings, 0 errors; git diff origin/main...HEAD --check — passed; diff secret scan — clean. Focused Vitest remains delegated to exact-head CI because the low-disk sparse worktree has no dependencies and pnpm install failed.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jul 18, 2026
@lin-hongkuan
lin-hongkuan force-pushed the test/plugin-sdk-origin-trust-docs branch from 76d33bc to 4fc7873 Compare July 18, 2026 02:04
@lin-hongkuan

Copy link
Copy Markdown
Contributor Author

Rebased the focused two-file patch onto current main and pushed 4fc78732fc0d3ad0280aa6b734d85a2ededf1107.

This also clears the prior exact-head docs failure: check-docs had reported docs/docs_map.md is out of date; on the refreshed head, node scripts/generate-docs-map.mjs --check passes with docs:map: docs/docs_map.md is up to date.

Validation on the refreshed head:

  • git diff --check upstream/main...HEAD — passed
  • node scripts/generate-docs-map.mjs --check — passed
  • npx --yes oxfmt@latest --check docs/plugins/sdk-subpaths.md src/infra/net/ssrf.test.ts — passed (2 files)
  • npx --yes oxlint@latest --tsconfig config/tsconfig/oxlint.core.json src/infra/net/ssrf.test.ts — 0 warnings, 0 errors
  • diff secret scan — clean

Public read-back confirms base main, exact head 4fc78732fc0d3ad0280aa6b734d85a2ededf1107, and only the intended two files. Exact-head CI is running.

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Jul 18, 2026
@lin-hongkuan

Copy link
Copy Markdown
Contributor Author

Addressed the trailing-host-dot finding in 743885d3376. The provider baseUrl coverage now directly asserts that a configured http://example.com.:11434/v1 policy matches the dotless request origin and promotes only example.com for that request. Exact-head validation: npx --yes oxfmt@latest --check docs/plugins/sdk-subpaths.md src/infra/net/ssrf.test.ts (passed), npx --yes oxlint@latest --tsconfig config/tsconfig/oxlint.core.json src/infra/net/ssrf.test.ts (0 warnings/errors), node scripts/generate-docs-map.mjs --check (up to date), git diff --check (passed), and diff secret scan (clean). The local low-disk worktree lacks workspace dependencies, so the exact-head Vitest rerun is deferred to CI; the previous head had 57 focused tests passing. @clawsweeper re-review

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jul 18, 2026
@lin-hongkuan
lin-hongkuan force-pushed the test/plugin-sdk-origin-trust-docs branch from 743885d to 47f0dcd Compare July 18, 2026 05:09
@lin-hongkuan

Copy link
Copy Markdown
Contributor Author

Addressed the current documentation finding and the exact-head CI assertion in 47f0dcd2dab after rebasing onto current main.

  • The SDK text now attributes path/query/default-port/userinfo/host-case serialization to URL.origin, while describing trailing-dot equivalence separately as OpenClaw SSRF hostname comparison behavior.
  • The configured trailing-dot regression now expects the helper's canonical dotless allowedOrigins output observed by exact-head CI, while retaining the matching hostname assertion.

Validation on the refreshed head:

  • npx --yes oxfmt@latest --check docs/plugins/sdk-subpaths.md src/infra/net/ssrf.test.ts — passed (2 files)
  • npx --yes oxlint@latest --tsconfig config/tsconfig/oxlint.core.json src/infra/net/ssrf.test.ts — 0 warnings, 0 errors
  • node scripts/generate-docs-map.mjs --check — up to date
  • git diff --check upstream/main...HEAD — passed
  • added-line diff secret scan — clean

The prior compact-large test failure was the stale expected dotted origin; compact-small's Apple catalog failure was branch-external and the branch is now on current main. Public exact-head CI is running. @clawsweeper re-review

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 18, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 29, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Aug 28, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

@openclaw-barnacle openclaw-barnacle Bot closed this Sep 5, 2026
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: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS stale Marked as stale due to inactivity 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.

test(plugin-sdk): track origin-trust SSRF edge coverage and docs

1 participant