Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ivanrvpereira
Copy link
Contributor

Summary

Fix inverted auth resolution logic in maybeProbeGateway that caused clawdbot security audit --deep to fail with "unauthorized" when connecting to a local gateway.

The Bug

In src/security/audit.ts, the auth selection condition was inverted:

// BEFORE (broken)
const auth = remoteUrlMissing ? resolveAuth("local") : resolveAuth("remote");

For local mode (gateway.mode undefined or "local"):

  • isRemoteMode = false
  • remoteUrlMissing = false (since isRemoteMode && !remoteUrlRaw)
  • This incorrectly called resolveAuth("remote") which returns undefined token

The Fix

// AFTER (fixed)
const auth = !isRemoteMode || remoteUrlMissing ? resolveAuth("local") : resolveAuth("remote");

Testing

  • pnpm lint - 0 warnings, 0 errors
  • pnpm test src/security/audit.test.ts - 20 tests pass
  • clawdbot security audit --deep - works without "unauthorized" error
  • Added 4 new tests covering auth selection logic

AI-Assisted PR 🤖

  • Built with Claude Code
  • Fully tested locally
  • I understand what the code does

@steipete steipete merged commit 6bf627b into openclaw:main Jan 16, 2026
21 of 22 checks passed
@steipete
Copy link
Contributor

Landed via temp rebase onto main.\n\n- Gate: pnpm lint && pnpm build && pnpm test\n- Land commit: c8003ae47c4e4b5c04f9b1a7c5f8b6b5136c4fe5\n- Merge commit: 6bf627b\n\nThanks @ivanrvpereira!

@steipete
Copy link
Contributor

Correction: Land commit is c8003ae (changelog follow-up).

@steipete
Copy link
Contributor

Follow-up: added extra auth/probe test coverage after merge.

  • Commit: 624ff09
  • Gate: pnpm lint && pnpm build && pnpm test

Thanks @ivanrvpereira!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants