Repository navigation
Description
Bug type
Behavior bug (incorrect output/state without crash)
Beta release blocker
No
Summary
A gateway.trustedProxies entry written as an IPv4-mapped IPv6 CIDR such as ::ffff:10.0.0.0/104 is accepted by config validation and by the onboarding wizard, but the runtime matcher never matches any address in that range except the exact base address. Every request arriving through that proxy with forwarded headers is rejected with HTTP 403 proxy_attribution_required.
The same matcher backs gateway.nodes.pairing.autoApproveCidrs and gateway.nodes.pairing.sshVerify.cidrs, so those silently stop matching too.
Steps to reproduce
- Run OpenClaw from source at
main(6d8d67fae). - Put a reverse proxy at
10.1.2.3and setgateway.trustedProxies: ["::ffff:10.0.0.0/104"], the mapped spelling of10.0.0.0/8. Theopenclaw configuretrusted-proxy prompt accepts this value. - Send any request through the proxy so it reaches the gateway with
X-Forwarded-For. - Observe HTTP 403 with body
Proxy client attribution is required. Configure gateway.trustedProxies narrowly and make the proxy overwrite or safely rebuild forwarded client headers. - Change the entry to
10.0.0.0/8and repeat: the request is attributed to the forwarded client and succeeds.
Unit-level reproduction against packages/net-policy/src/ip.ts and src/gateway/net.ts:
isIpInCidr("10.1.2.3", "::ffff:10.0.0.0/104"); // false, expected true
isIpInCidr("::ffff:10.1.2.3", "::ffff:10.0.0.0/104"); // false, expected true
isIpInCidr("::ffff:10.1.2.3", "::ffff:0:0/96"); // false, expected true
isIpInCidr("10.0.0.0", "::ffff:10.0.0.0/104"); // true (only the exact base matches)
isIpInCidr("10.1.2.3", "10.0.0.0/8"); // true (control)
isTrustedProxyAddress("10.1.2.3", ["::ffff:10.0.0.0/104"]); // falseExpected behavior
::ffff:10.0.0.0/104 is the IPv4-mapped form of 10.0.0.0/8, so a proxy at 10.1.2.3 should be trusted exactly as it is with 10.0.0.0/8.
docs/gateway/trusted-proxy-auth.md:97 says the request's source IP "must match gateway.trustedProxies (CIDR-aware)". docs/cli/configure.md:43 says the wizard accepts "IPv4 or IPv6 addresses or CIDR ranges". The existing case in packages/net-policy/src/ip.test.ts:53 expects ::ffff:127.0.0.1/128 to be a valid mapped range, so mapped CIDRs are an intended input.
Actual behavior
isIpInCidr normalizes the mapped base ::ffff:10.0.0.0 to the IPv4 address 10.0.0.0 but passes the original 104-bit prefix length unchanged to ipaddr.js match(). On a four-octet address a prefix of 104 compares every octet in full, so the range degrades to an exact match on the base address. Any prefix from 96 to 127 behaves the same way, and ::ffff:0:0/96 (all of IPv4) matches only 0.0.0.0. The existing /128 case passes only because an exact match happens to be the right answer there.
Because the proxy is not trusted, the request is classified as unattributable-proxy and answered with 403 before any auth or rate-limit decision. The failure is fail-closed: no request is ever wrongly trusted.
OpenClaw version
2026.8.1 (source, main at 6d8d67fae). Present since 333fbb863 (2026-02-22, "refactor(net): consolidate IP checks with ipaddr.js"), which introduced isIpInCidr.
Operating system
Windows 11 (reproduced with vitest); the code path is platform-independent.
Install method
Source checkout
Model
n/a (gateway network policy, model-independent)
Provider / routing chain
n/a (reverse proxy to gateway; no model provider involved)
Additional provider/model setup details
No response
Logs
Scoped repro test at `main` `6d8d67fae`:
× 10.1.2.3 in ::ffff:10.0.0.0/104 → expected false to be true
× ::ffff:10.1.2.3 in ::ffff:10.0.0.0/104 → expected false to be true
× ::ffff:10.1.2.3 in ::ffff:0:0/96 → expected false to be true
× isTrustedProxyAddress("10.1.2.3", ["::ffff:10.0.0.0/104"]) → expected false to be true
✓ 10.0.0.0 exact in ::ffff:10.0.0.0/104
✓ 10.1.2.3 in 10.0.0.0/8 (control)Screenshots, recordings, and evidence
packages/net-policy/src/ip.ts,isIpInCidr:comparableBase = normalizeIpv4MappedAddress(baseAddress)is followed bycomparableIp.match([comparableBase, prefixLength])withprefixLengthstill in 128-bit space.src/commands/configure.gateway.ts:310validates trusted-proxy entries withparseIpAddressOrCidr, which accepts the mapped form, so the wizard writes a value the runtime cannot honor.src/gateway/net.ts:207(isTrustedProxyAddress) is the trusted-proxy caller.src/gateway/node-pairing-auto-approve.ts:104andsrc/gateway/node-pairing-ssh-verify.ts:129reach the same helper forautoApproveCidrsandsshVerify.cidrs.- PR fix(onboard): probe remote gateways with saved TLS pins and validate trusted proxies #131475 lists "mapped-IPv4 CIDR prefix interpretation" among its Named follow-ups, not addressed there. Its parameterized test in
src/commands/configure.gateway.test.ts("does not ask for loopback consent when runtime cannot match loopback through %s", with::ffff:0:0/96as a case) pins the current behavior. - Verified against ipaddr.js 2.5.0, the version pinned by
packages/net-policy:IPv4.match([10.0.0.0, 104])is true only for10.0.0.0, whilematch([10.0.0.0, 104 - 96])behaves as/8.
Impact and severity
- Affected: operators who write
gateway.trustedProxies,gateway.nodes.pairing.autoApproveCidrs, orgateway.nodes.pairing.sshVerify.cidrsentries in IPv4-mapped CIDR form.src/infra/tailnet.tsis not affected; it uses fixed native CIDR constants. - Severity: low to medium. Fail-closed, no auth bypass. All proxied gateway traffic is rejected with 403, and CIDR-based node pairing auto-approval silently falls back to manual prompts.
- Frequency: always, for any mapped CIDR with a prefix from 96 to 127.
- Consequence: the wizard and schema accept a value the runtime never matches, with no warning at config load,
openclaw doctor, or startup. The only signal is the 403 on the first proxied request, whose guidance points at "configure trustedProxies narrowly" rather than at the address family.
Additional information
Not a regression; the behavior has been the same since isIpInCidr was introduced.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Sep 4, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed September 3, 2026, 8:23 PM ET / September 4, 2026, 00:23 UTC.
Summary
Keep open: current main and v2026.8.2 retain the shared matcher defect, and the formally linked open PR is the active fix candidate.
Reproducibility: no. executed reproduction was possible in this read-only review, but current source clearly routes accepted mapped CIDRs through a normalized IPv4 base with the unreduced prefix.
Root-cause cluster
Relationship:
fixed_by_candidateCanonical: #137668
Summary: The linked open PR is the single canonical implementation candidate for this source-proven matcher defect.
Members:
canonical: fix(gateway): honor mapped IPv4 CIDR ranges #137668 - It explicitly links this issue as the behavior it fixes and targets the shared CIDR matcher plus its affected boundaries.Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Ways to help us reproduce this
Next step
A linked open PR formally owns the bounded repair, so a second repair job would duplicate active work.
Security
Needs attention: The defect is security-sensitive trusted-proxy policy, but the reviewed current behavior fails closed and no bypass is evidenced.
Review details
Best possible solution:
Review and land the linked PR if it corrects prefix rebasing in the shared matcher and retains boundary coverage for ingress, loopback consent, and pairing callers.
Do we have a high-confidence way to reproduce the issue?
No executed reproduction was possible in this read-only review, but current source clearly routes accepted mapped CIDRs through a normalized IPv4 base with the unreduced prefix.
Is this the best way to solve the issue?
Yes for the repair shape: fix the shared matcher’s prefix interpretation and cover ingress and pairing consumers rather than adding downstream exceptions.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against cd8c74889d21.
Label changes
Label changes:
P2: Accepted mapped CIDRs consistently fail closed for affected proxy and pairing configurations, but no authorization bypass is evidenced.impact:security: The mismatch occurs in trusted-proxy attribution and trusted-CIDR pairing policy before authentication or approval decisions.maturity:stable: The broken established trusted-proxy contract is primarily owned by the Gateway runtime, scored M4 Stable in qa/maturity-scores.yaml, under its Security Controls surface.issue-rating: 🐚 platinum hermit: Current issue advisory state selects this label.clawsweeper:needs-live-repro: Current issue advisory state selects this label.clawsweeper:linked-pr-open: Current issue advisory state selects this label.clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.clawsweeper:needs-security-review: Current issue advisory state selects this label.Label justifications:
P2: Accepted mapped CIDRs consistently fail closed for affected proxy and pairing configurations, but no authorization bypass is evidenced.impact:security: The mismatch occurs in trusted-proxy attribution and trusted-CIDR pairing policy before authentication or approval decisions.maturity:stable: The broken established trusted-proxy contract is primarily owned by the Gateway runtime, scored M4 Stable in qa/maturity-scores.yaml, under its Security Controls surface.Evidence reviewed
Security concerns:
packages/net-policy/src/ip.ts:399Mapped IPv6 CIDR configuration accepted by the wizard can fail to trust intended IPv4 peers, blocking proxy attribution and configured CIDR pairing behavior.
Confidence: 0.9
What I checked:
packages/net-policy/src/ip.ts:390, cd8c74889d21)src/gateway/ingress-attribution.ts:228, cd8c74889d21)src/commands/configure.gateway.ts:310, cd8c74889d21)packages/net-policy/src/ip.ts:390, 0965053fe6b9)docs/gateway/trusted-proxy-auth.md. (docs/gateway/trusted-proxy-auth.md:97, cd8c74889d21)Likely related people:
How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.fix(gateway): honor mapped IPv4 CIDR ranges (#137668)
fix(gateway): honor mapped IPv4 CIDR ranges (openclaw#137668)
fix(gateway): honor mapped IPv4 CIDR ranges (openclaw#137668)