Skip to content

fix(gateway): honor dangerouslyDisableDeviceAuth in evaluateMissingDeviceIdentity#44034

Closed
NayukiChiba wants to merge 2 commits intoopenclaw:mainfrom
NayukiChiba:fix/dangerously-disable-device-auth-bypass
Closed

fix(gateway): honor dangerouslyDisableDeviceAuth in evaluateMissingDeviceIdentity#44034
NayukiChiba wants to merge 2 commits intoopenclaw:mainfrom
NayukiChiba:fix/dangerously-disable-device-auth-bypass

Conversation

@NayukiChiba
Copy link
Copy Markdown

Summary

Fixes #43909gateway.controlUi.dangerouslyDisableDeviceAuth: true was not actually bypassing device identity checks in evaluateMissingDeviceIdentity.

Root Cause

evaluateMissingDeviceIdentity skipped the reject-control-ui-insecure-auth rejection block when allowBypass === true, but had no explicit allow path for that case. The function then fell through to roleCanSkipDeviceIdentity(role, sharedAuthOk), which returns false when no shared token is provided (e.g. iframe environments like Coze that can't issue device crypto). This caused reject-device-required instead of the intended bypass.

Fix

Add an explicit early return when isControlUi && allowBypass === true:

// dangerouslyDisableDeviceAuth bypasses device identity gating entirely.
// Shared-secret / token auth is still enforced separately via resolveConnectAuthDecision.
if (params.isControlUi && params.controlUiAuthPolicy.allowBypass) {
  return { kind: "allow" };
}

Token/password auth is still enforced after this check by resolveConnectAuthDecision — only device-identity crypto is bypassed.

Tests

Two regression test cases added in connect-policy.test.ts:

All 4 existing tests continue to pass.

Checklist

  • Regression tests added
  • All existing tests pass
  • No auth bypass introduced — token/password auth still checked downstream by resolveConnectAuthDecision

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS labels Mar 12, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 12, 2026

Greptile Summary

This PR fixes a bug where setting dangerouslyDisableDeviceAuth: true in the gateway Control UI config failed to bypass device identity checks in evaluateMissingDeviceIdentity, resulting in reject-device-required errors for iframe environments that cannot issue device crypto and have no shared token.

Key changes:

  • connect-policy.ts: Adds an explicit early-return { kind: "allow" } when isControlUi && controlUiAuthPolicy.allowBypass is true, placed between the existing trustedProxyAuthOk guard and the existing !allowBypass block. This prevents the unintended fall-through to roleCanSkipDeviceIdentity.
  • connect-policy.test.ts: Adds two regression tests — one for the exact failing scenario and one for the remote-iframe baseline. All pre-existing tests continue to pass.

The fix is minimal and well-scoped. Token/password auth enforcement remains intact downstream via resolveConnectAuthDecision; only device-identity crypto is bypassed by this flag.

Confidence Score: 4/5

  • Safe to merge; the fix is small and correctly targeted, with regression tests for the reported failure case.
  • The one-point deduction is for the missing test coverage of the failed-auth state through the bypass path — the PR relies on a downstream function (resolveConnectAuthDecision) to enforce token auth when allowBypass is true, but this is not exercised in the unit tests for evaluateMissingDeviceIdentity. The fix itself is logically correct and the existing tests all pass.
  • No files require special attention beyond the noted test coverage gap in connect-policy.ts.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/gateway/server/ws-connection/connect-policy.ts
Line: 85-89

Comment:
**Missing test for failed-auth state in bypass path**

The new early return skips the `reject-unauthorized` guard at line 103 (which checks `!params.authOk && params.hasSharedAuth`). The PR description asserts that authentication is enforced downstream by `resolveConnectAuthDecision`, but neither of the two new regression tests exercises the case where `allowBypass` is `true` while authentication has failed. Adding a test with a failed-auth state through this bypass path would document the expected behavior and confirm that the downstream guard actually fires, making the security boundary easier to reason about in isolation.

How can I resolve this? If you propose a fix, please make it concise.

Last reviewed commit: 9f5da84

Comment on lines +85 to +89
// dangerouslyDisableDeviceAuth bypasses device identity gating entirely.
// Shared-secret / token auth is still enforced separately via resolveConnectAuthDecision.
if (params.isControlUi && params.controlUiAuthPolicy.allowBypass) {
return { kind: "allow" };
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing test for failed-auth state in bypass path

The new early return skips the reject-unauthorized guard at line 103 (which checks !params.authOk && params.hasSharedAuth). The PR description asserts that authentication is enforced downstream by resolveConnectAuthDecision, but neither of the two new regression tests exercises the case where allowBypass is true while authentication has failed. Adding a test with a failed-auth state through this bypass path would document the expected behavior and confirm that the downstream guard actually fires, making the security boundary easier to reason about in isolation.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/gateway/server/ws-connection/connect-policy.ts
Line: 85-89

Comment:
**Missing test for failed-auth state in bypass path**

The new early return skips the `reject-unauthorized` guard at line 103 (which checks `!params.authOk && params.hasSharedAuth`). The PR description asserts that authentication is enforced downstream by `resolveConnectAuthDecision`, but neither of the two new regression tests exercises the case where `allowBypass` is `true` while authentication has failed. Adding a test with a failed-auth state through this bypass path would document the expected behavior and confirm that the downstream guard actually fires, making the security boundary easier to reason about in isolation.

How can I resolve this? If you propose a fix, please make it concise.

@katoue

This comment was marked as spam.

@steipete
Copy link
Copy Markdown
Contributor

Closing this as implemented after Codex review.

Current main already implements the dangerouslyDisableDeviceAuth bypass for Control UI operator sessions, covers the reported sharedAuthOk=false regression in unit tests, and exercises the behavior in the gateway auth suite. This PR is redundant against main, and its broader unconditional bypass no longer matches the current intentionally operator-scoped behavior.

What I checked:

So I’m closing this as already implemented rather than keeping a duplicate issue open.

Review notes: reviewed against 4e4aeacae4a8; fix evidence: commit 5f702b464bb5.

@steipete steipete closed this Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: dangerouslyDisableDeviceAuth not working in v2026.3.11

3 participants