Repository navigation
fix(onboard): probe remote gateways with saved TLS pins and validate trusted proxies - #131475
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 4:42 PM ET / 20:42 UTC. ClawSweeper reviewWhat this changesThe PR carries saved remote TLS pins through onboarding and configure readiness probes, validates trusted-proxy addresses with the runtime parser, and prompts for loopback consent whenever runtime matching can reach loopback. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open for gateway-security maintainer review. The submitted head fixes a real caller-side gap still present on fetched main; no introduced correctness defect was found, but the TLS-pin and loopback-consent trust boundary merits explicit confirmation. Priority: P2 Review scores
Verification
How this fits togetherGateway setup saves a remote endpoint and its trust material, then probes that endpoint before reporting readiness. Trusted-proxy setup saves source ranges which Gateway authentication later checks before accepting proxy-provided identity headers. flowchart LR
A[Setup or configure] --> B[Remote endpoint settings]
B --> C[Gateway readiness probe]
C --> D[Remote TLS connection]
A --> E[Trusted proxy ranges]
E --> F[Gateway authorization]
D --> G[Operator result]
F --> G
Decision needed
Why: This is an intentional security boundary in setup behavior, not a mechanical compatibility detail that review automation can choose. Before merge
Agent review detailsSecurityNone. PR surfaceSource +15, Tests +236, Docs +5. Total +256 across 15 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain one readiness-probe path that receives the saved remote configuration and one parser shared with runtime matching, with the selected URL-scope and loopback-consent contract explicitly confirmed. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main’s probe accepts only an explicit pin while these setup callers have the saved remote configuration; the exact-head TLS fixture exercises the repaired polling path. Is this the best way to solve the issue? Yes, subject to the maintainer security choice: passing the existing configuration into the existing probe and extracting its parser avoids parallel TLS or CIDR logic in wizard callers. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4c6ed51733d3. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Honor the configured remote certificate pin in onboarding and configure readiness probes while keeping trust scoped to the exact saved endpoint. Retain explicit-pin precedence and exercise the real self-signed TLS handshake, rejection before credentials, and wizard config propagation. Follow up on #131042.
Share exact-IP and CIDR parsing between the trusted-proxy wizard and runtime matching. Reject malformed and empty list entries with expected-form guidance, preserve runtime matcher behavior, and recognize loopback CIDR aliases for the existing explicit consent prompt. Follow up on #131132; the diagnostic correction in #131196 did not validate this input.
Keep remote TLS pins and edge-auth inputs through health readiness polling by reusing the existing probe parameters. Keep remote config out of local health probes and cover polling through a real TLS socket. Check loopback consent against runtime proxy matching for both parsed bases and containing ranges, preserving mapped IPv4 and exact IPv6 zone semantics. Extend consent and URL-binding coverage without changing runtime authorization or config schemas.
6aec88a to
ea46bf5
Compare
|
Merged via squash.
|
…trusted proxies (openclaw#131475) * fix(onboard): probe remote gateways with saved TLS pins Honor the configured remote certificate pin in onboarding and configure readiness probes while keeping trust scoped to the exact saved endpoint. Retain explicit-pin precedence and exercise the real self-signed TLS handshake, rejection before credentials, and wizard config propagation. Follow up on openclaw#131042. * fix(configure): validate trusted proxy addresses with the runtime parser Share exact-IP and CIDR parsing between the trusted-proxy wizard and runtime matching. Reject malformed and empty list entries with expected-form guidance, preserve runtime matcher behavior, and recognize loopback CIDR aliases for the existing explicit consent prompt. Follow up on openclaw#131132; the diagnostic correction in openclaw#131196 did not validate this input. * fix(configure): align readiness and loopback consent with runtime Keep remote TLS pins and edge-auth inputs through health readiness polling by reusing the existing probe parameters. Keep remote config out of local health probes and cover polling through a real TLS socket. Check loopback consent against runtime proxy matching for both parsed bases and containing ranges, preserving mapped IPv4 and exact IPv6 zone semantics. Extend consent and URL-binding coverage without changing runtime authorization or config schemas.
Closes #137665 Related: #131475 ## What Problem This Solves Fixes an issue where an accepted IPv4-mapped CIDR such as `::ffff:10.0.0.0/104` rejected proxy addresses that belong to the equivalent `10.0.0.0/8` range. Proxied requests returned HTTP 403 `proxy_attribution_required`. The same matcher left eligible node pairing requests pending for mapped `autoApproveCidrs` and `sshVerify.cidrs` entries. ## Why This Change Was Made Normalize the prefix into IPv4's bit space before the existing IPv4 match. The shared matcher now handles plain and mapped ranges in one path, without a second mapped-address matcher. Exact addresses, native IPv6, parsing, and downstream authorization keep their existing paths. ## User Impact Mapped `/104`, `/120`, and `/128` ranges behave like IPv4 `/8`, `/24`, and exact addresses. Prefixes at or below `/96` cover all IPv4, including loopback; the wizard keeps its explicit loopback-consent prompt. Native IPv6 peers do not match mapped ranges. Keep proxy allowlists narrow: a catch-all still consumes every IPv4 forwarded hop and cannot attribute a client through that chain. Automatic pairing still requires a fresh, signed, scopeless node request. Roles, scopes, browser requests, manual approval, and SSH host/device identity checks retain their own gates. No configuration field, schema, dependency, or permission policy is added. ## Evidence Real source Gateway and CLI runs use isolated documentation-address peers, a real overwriting loopback reverse proxy, TLS, and actual SSH reading `openclaw node identity --json`. | Caller | Pinned main | Repair | | --- | --- | --- | | Matching mapped proxy range | HTTP 403 | HTTP 200 from protected `/v1/models` | | Plain equivalent proxy range | HTTP 200 | HTTP 200 | | Nearby nonmatching proxy range | HTTP 403 | HTTP 403 | | Matching mapped node auto-approval range | Manual pending | Approved via trusted CIDR and connected | | Matching mapped SSH-verification range | Manual pending | SSH verified and connected | Additional real controls cover `/64`, `/95`, `/96`, `/104`, `/128`, exact nonmatches, native IPv6, loopback consent, missing/disallowed identities, missing headers, invalid/loopback forwarded clients, origin allow/deny, scope caps, and SSH identity/key failures. Signed WebSocket checks retain manual role upgrades, scoped/browser requests, signature rejection, and manual read-only enrollment. The enrolled operator can read after restart and cannot invoke an administrative write. CIDR device pairing retains separate capability approval. The three focused regression files show nine intended failures on main and 123 passes with the repair. Another 232 focused network/pairing/SSH tests pass. The exact installed ipaddr.js 2.5.0 source was inspected: IPv4 matching consumes 32 bits, so mapped prefixes must subtract 96. Paired runtime proof uses main `1a7224b69f09b8e7a9edb8d9de27c3c534397f1e` plus this repair, preserving newer Gateway callers. The changed matcher has exact byte identity with the candidate; the old contributor branch retains its ancestry. The contributor-based tree separately passes its own runtime build, formatter check, and 120 focused tests with its pinned dependencies. An independent validator completed 47 fresh runtime cases without an observed defect; source, historical, wizard-presentation, broader-policy and cleanup observations are assessed separately rather than claimed as independent passes. Historical setup and probe-assumption corrections remain recorded privately. AI-assisted. Co-authored-by: Ayaan Zaidi <[email protected]>
Closes openclaw#137665 Related: openclaw#131475 ## What Problem This Solves Fixes an issue where an accepted IPv4-mapped CIDR such as `::ffff:10.0.0.0/104` rejected proxy addresses that belong to the equivalent `10.0.0.0/8` range. Proxied requests returned HTTP 403 `proxy_attribution_required`. The same matcher left eligible node pairing requests pending for mapped `autoApproveCidrs` and `sshVerify.cidrs` entries. ## Why This Change Was Made Normalize the prefix into IPv4's bit space before the existing IPv4 match. The shared matcher now handles plain and mapped ranges in one path, without a second mapped-address matcher. Exact addresses, native IPv6, parsing, and downstream authorization keep their existing paths. ## User Impact Mapped `/104`, `/120`, and `/128` ranges behave like IPv4 `/8`, `/24`, and exact addresses. Prefixes at or below `/96` cover all IPv4, including loopback; the wizard keeps its explicit loopback-consent prompt. Native IPv6 peers do not match mapped ranges. Keep proxy allowlists narrow: a catch-all still consumes every IPv4 forwarded hop and cannot attribute a client through that chain. Automatic pairing still requires a fresh, signed, scopeless node request. Roles, scopes, browser requests, manual approval, and SSH host/device identity checks retain their own gates. No configuration field, schema, dependency, or permission policy is added. ## Evidence Real source Gateway and CLI runs use isolated documentation-address peers, a real overwriting loopback reverse proxy, TLS, and actual SSH reading `openclaw node identity --json`. | Caller | Pinned main | Repair | | --- | --- | --- | | Matching mapped proxy range | HTTP 403 | HTTP 200 from protected `/v1/models` | | Plain equivalent proxy range | HTTP 200 | HTTP 200 | | Nearby nonmatching proxy range | HTTP 403 | HTTP 403 | | Matching mapped node auto-approval range | Manual pending | Approved via trusted CIDR and connected | | Matching mapped SSH-verification range | Manual pending | SSH verified and connected | Additional real controls cover `/64`, `/95`, `/96`, `/104`, `/128`, exact nonmatches, native IPv6, loopback consent, missing/disallowed identities, missing headers, invalid/loopback forwarded clients, origin allow/deny, scope caps, and SSH identity/key failures. Signed WebSocket checks retain manual role upgrades, scoped/browser requests, signature rejection, and manual read-only enrollment. The enrolled operator can read after restart and cannot invoke an administrative write. CIDR device pairing retains separate capability approval. The three focused regression files show nine intended failures on main and 123 passes with the repair. Another 232 focused network/pairing/SSH tests pass. The exact installed ipaddr.js 2.5.0 source was inspected: IPv4 matching consumes 32 bits, so mapped prefixes must subtract 96. Paired runtime proof uses main `db7fff94b0f516759efdb04f47fc4d2fc65996a7` plus this repair, preserving newer Gateway callers. The changed matcher has exact byte identity with the candidate; the old contributor branch retains its ancestry. The contributor-based tree separately passes its own runtime build, formatter check, and 120 focused tests with its pinned dependencies. An independent validator completed 47 fresh runtime cases without an observed defect; source, historical, wizard-presentation, broader-policy and cleanup observations are assessed separately rather than claimed as independent passes. Historical setup and probe-assumption corrections remain recorded privately. AI-assisted. Co-authored-by: Ayaan Zaidi <[email protected]>
Closes openclaw#137665 Related: openclaw#131475 ## What Problem This Solves Fixes an issue where an accepted IPv4-mapped CIDR such as `::ffff:10.0.0.0/104` rejected proxy addresses that belong to the equivalent `10.0.0.0/8` range. Proxied requests returned HTTP 403 `proxy_attribution_required`. The same matcher left eligible node pairing requests pending for mapped `autoApproveCidrs` and `sshVerify.cidrs` entries. ## Why This Change Was Made Normalize the prefix into IPv4's bit space before the existing IPv4 match. The shared matcher now handles plain and mapped ranges in one path, without a second mapped-address matcher. Exact addresses, native IPv6, parsing, and downstream authorization keep their existing paths. ## User Impact Mapped `/104`, `/120`, and `/128` ranges behave like IPv4 `/8`, `/24`, and exact addresses. Prefixes at or below `/96` cover all IPv4, including loopback; the wizard keeps its explicit loopback-consent prompt. Native IPv6 peers do not match mapped ranges. Keep proxy allowlists narrow: a catch-all still consumes every IPv4 forwarded hop and cannot attribute a client through that chain. Automatic pairing still requires a fresh, signed, scopeless node request. Roles, scopes, browser requests, manual approval, and SSH host/device identity checks retain their own gates. No configuration field, schema, dependency, or permission policy is added. ## Evidence Real source Gateway and CLI runs use isolated documentation-address peers, a real overwriting loopback reverse proxy, TLS, and actual SSH reading `openclaw node identity --json`. | Caller | Pinned main | Repair | | --- | --- | --- | | Matching mapped proxy range | HTTP 403 | HTTP 200 from protected `/v1/models` | | Plain equivalent proxy range | HTTP 200 | HTTP 200 | | Nearby nonmatching proxy range | HTTP 403 | HTTP 403 | | Matching mapped node auto-approval range | Manual pending | Approved via trusted CIDR and connected | | Matching mapped SSH-verification range | Manual pending | SSH verified and connected | Additional real controls cover `/64`, `/95`, `/96`, `/104`, `/128`, exact nonmatches, native IPv6, loopback consent, missing/disallowed identities, missing headers, invalid/loopback forwarded clients, origin allow/deny, scope caps, and SSH identity/key failures. Signed WebSocket checks retain manual role upgrades, scoped/browser requests, signature rejection, and manual read-only enrollment. The enrolled operator can read after restart and cannot invoke an administrative write. CIDR device pairing retains separate capability approval. The three focused regression files show nine intended failures on main and 123 passes with the repair. Another 232 focused network/pairing/SSH tests pass. The exact installed ipaddr.js 2.5.0 source was inspected: IPv4 matching consumes 32 bits, so mapped prefixes must subtract 96. Paired runtime proof uses main `1a7224b69f09b8e7a9edb8d9de27c3c534397f1e` plus this repair, preserving newer Gateway callers. The changed matcher has exact byte identity with the candidate; the old contributor branch retains its ancestry. The contributor-based tree separately passes its own runtime build, formatter check, and 120 focused tests with its pinned dependencies. An independent validator completed 47 fresh runtime cases without an observed defect; source, historical, wizard-presentation, broader-policy and cleanup observations are assessed separately rather than claimed as independent passes. Historical setup and probe-assumption corrections remain recorded privately. AI-assisted. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 7069a47)
Important
review-required: TLS trust + auth-config surface. Prepared under the auto-QA campaign; onboarding TLS trust and trusted-proxy validation are review-required, so this stays a draft for maintainer review.
What Problem This Solves
Two onboarding/configure-wizard hardening gaps found by deep-review passes:
src/gateway/probe.ts): after configuring a pinned self-signed remote gateway (pin preserved by the TLS-pin work in fix(onboard): preserve the remote gateway TLS pin for an unchanged endpoint #131042), the wizard's own readiness probe built its connection without forwarding that pin, so it failed to verify — or trusted differently than the runtime would. The probe now forwards the saved pin, but only for the exact configured URL (trim-normalized): a different host, port, path, query, or case cannot acquire another endpoint's pin, and a mid-wizard URL override cannot relabel an old pin onto its new target. The same fix also repairsconfigure --section health, whose readiness poll discarded all connection inputs except URL/token/password.src/commands/configure.gateway.ts): the prompt only rejected blank input, so a malformed address could be written to config that the runtime then silently never matches. It now validates every entry with the same canonical parser the runtime uses (parseIpAddressOrCidr, extracted from the existingisIpInCidrimplementation inpackages/net-policy), rejecting junk with an actionable message. This also fixes a connected loopback-consent miss: the runtime accepts127.1/8, but the old string-split+canonical-IP path missed its loopback identity, so consent wasn't prompted.Why This Change Was Made
Both fixes land at the producer: pin selection at the probe connection producer (one place, so status/daemon/future callers stay consistent), and address validation via the runtime's own parser (no second regex that could diverge from matching semantics). The parser extraction is behavior-preserving — verified against installed ipaddr.js 2.5.0 with a 19,950-combination parity probe (zero mismatches, zero throws) and confirmed byte-identical by the deep review.
The consent predicate now checks the parsed base plus IPv4/IPv6 loopback representatives through both runtime loopback classification and
isTrustedProxyAddress, covering subnets within loopback and ranges containing it (126.0.0.0/7,::/127,::/0) without substituting hand-rolled CIDR arithmetic for runtime semantics.User Impact
Configuring a pinned remote gateway through the wizard now verifies readiness with the runtime's exact trust; a malformed trusted-proxy entry is rejected at the prompt with guidance instead of silently never matching; loopback consent is asked whenever the entry actually matches loopback.
Evidence
probe.tls.test.tswas union-merged with the transport PR's cases — 48 TLS/worker tests green including the zero-byte exposure assertions, proving pin forwarding does not reintroduce pre-pin bytes.waitForGatewayReachablecarries no pins); bootstrap environment-override pin contract vs exact-target diagnostics; mapped-IPv4 CIDR prefix interpretation.