openclaw - ✅(Solved) Fix Bug: pre-auth bootstrap-token verify allows mutex-stall DoS without rate limit [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#77978Fetched 2026-05-06 06:18:26
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
2
Timeline (top)
cross-referenced ×2commented ×1

Fix Action

Fixed

PR fix notes

PR #77527: fix(gateway): rate-limit pre-auth bootstrap-token verify to prevent mutex DoS

Description (problem / solution / changelog)

Closes #77978

Summary

  • verifyDeviceBootstrapToken is withLock-serialized in src/infra/device-bootstrap.ts:39 and runs a JSON state read + write per attempt. The verify call site at src/gateway/server/ws-connection/auth-context.ts:160-179 had no rate limit gate — only the sibling device-token path (line 187) was throttled. An attacker with a self-generated Ed25519 keypair can produce a valid device signature for any connect payload, then send auth.bootstrapToken: "anything" to keep the bootstrap mutex saturated. The mutex is shared with all bootstrap-pairing operations (requestDevicePairing, approveBootstrapDevicePairing, etc.), so the attack starves legitimate node onboarding rather than just CPU.
  • Adds AUTH_RATE_LIMIT_SCOPE_BOOTSTRAP_TOKEN and gates verifyBootstrapToken with the same optimistic-check pattern device-token already uses: pre-check for lockout, run verify, recordFailure on mismatch, reset on success. The gate fires for browser-origin clients via the always-on browserRateLimiter (exemptLoopback: false) and for non-browser remote clients when gateway.auth.rateLimit is configured — same reachability envelope as the existing device-token bucket.
  • Reaching verifyBootstrapToken only requires a valid Ed25519 signature on the connect payload (trivially producible with the attacker's own keypair) plus auth.bootstrapToken. There is no "must be paired" gate before the verify path.

Reproduction

The integration test (src/gateway/server.preauth-bootstrap-token-rate-limit.test.ts) configures withGatewayServer with rateLimit.maxAttempts: 3, exemptLoopback: false, opens a fresh WS handshake per attempt, and submits connectReq(ws, { skipDefaultAuth: true, bootstrapToken: "forged-bootstrap-token", deviceIdentityPath }). connectReq auto-builds a valid Ed25519 device block — same shape as a real attacker would produce.

The test asserts:

  1. The first maxAttempts attempts fail with details.authReason === "bootstrap_token_invalid" (the verify ran).
  2. The (N+1)th attempt fails with details.authReason === "rate_limited" — the gate short-circuited before the mutex was entered.

Reverting the recordFailure line in the gate makes the second test fail with expected 'bootstrap_token_invalid' to be 'rate_limited'.

Test plan

  • src/gateway/server/ws-connection/auth-context.test.ts — added 3 unit tests: gate fires when bucket exceeded (verify never invoked), recordFailure consumed on mismatch, reset called on success. Existing 9 tests remain green (12/12 pass).
  • src/gateway/server.preauth-bootstrap-token-rate-limit.test.ts — new in-process WS integration test (2 cases) using withGatewayServer. Both fail when the gate is removed.
  • No regressions: pnpm test src/gateway/server.preauth-bootstrap-token-rate-limit.test.ts src/gateway/server/ws-connection/auth-context.test.ts src/gateway/server.auth.control-ui.test.ts src/gateway/server.auth.browser-hardening.test.ts src/gateway/server.auth.modes.test.ts → 60/60 pass.

Verification

  • Targeted lint with TS-aware shard config: OPENCLAW_OXLINT_SKIP_PREPARE=1 node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json <touched files> → 0 warnings, 0 errors.
  • pnpm check:changed: only failure is the pre-existing web-tree-sitter typecheck error in src/infra/command-explainer/* that I did not touch — same error reproduces on origin/main without these changes.

Reachability envelope

  • Browser-origin clients: gated unconditionally via browserRateLimiter (always constructed, exemptLoopback: false).
  • Non-browser remote clients: gated when operator has configured gateway.auth.rateLimit. When unconfigured, neither this gate nor the existing device-token gate applies — that is a configuration concern that affects the whole pre-auth surface, not specific to bootstrap-token.
  • Loopback-exempt connections (default exemptLoopback: true) are unaffected, matching how legitimate local CLI sessions are exempted from all other gateway buckets.

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • src/gateway/auth-rate-limit.ts (modified, +7/-0)
  • src/gateway/server.preauth-bootstrap-token-rate-limit.test.ts (added, +115/-0)
  • src/gateway/server/ws-connection/auth-context.test.ts (modified, +104/-0)
  • src/gateway/server/ws-connection/auth-context.ts (modified, +46/-17)
RAW_BUFFERClick to expand / collapse

Problem

The gateway's pre-auth bootstrap-token verify path takes a process-wide mutex and runs verification work without a rate limit or lockout. An unauthenticated attacker can flood the bootstrap-token endpoint with bogus tokens to stall the mutex and starve legitimate auth traffic.

Documented as part of the bootstrap DoS audit in #76322.

Tracking PR

Fix in #77527.

extent analysis

TL;DR

Implementing a rate limit or lockout mechanism for the bootstrap-token verification path can prevent the gateway from being stalled by bogus tokens.

Guidance

  • Review the fix in #77527 to understand the proposed solution for implementing rate limiting or lockout.
  • Verify that the current implementation of the bootstrap-token verification path indeed lacks rate limiting or lockout, making it vulnerable to flooding attacks.
  • Consider applying the fix from #77527 to prevent similar denial-of-service (DoS) attacks in the future.
  • Evaluate the impact of this vulnerability on the overall system security and prioritize its resolution accordingly.

Notes

The provided information does not include specific details about the current implementation or the proposed fix, so it's essential to review #77527 for more context.

Recommendation

Apply workaround: Implementing a rate limit or lockout mechanism for the bootstrap-token verification path, as proposed in #77527, can effectively prevent the gateway from being stalled by bogus tokens, thus mitigating the vulnerability.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix Bug: pre-auth bootstrap-token verify allows mutex-stall DoS without rate limit [1 pull requests, 1 comments, 2 participants]