fix(gateway): honor dangerouslyDisableDeviceAuth in evaluateMissingDeviceIdentity#44034
fix(gateway): honor dangerouslyDisableDeviceAuth in evaluateMissingDeviceIdentity#44034NayukiChiba wants to merge 2 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR fixes a bug where setting Key changes:
The fix is minimal and well-scoped. Token/password auth enforcement remains intact downstream via Confidence Score: 4/5
Prompt To Fix All With AIThis 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 |
| // 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" }; | ||
| } |
There was a problem hiding this 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.
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.
This comment was marked as spam.
This comment was marked as spam.
|
Closing this as implemented after Codex review. Current 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. |
Summary
Fixes #43909 —
gateway.controlUi.dangerouslyDisableDeviceAuth: truewas not actually bypassing device identity checks inevaluateMissingDeviceIdentity.Root Cause
evaluateMissingDeviceIdentityskipped thereject-control-ui-insecure-authrejection block whenallowBypass === true, but had no explicitallowpath for that case. The function then fell through toroleCanSkipDeviceIdentity(role, sharedAuthOk), which returnsfalsewhen no shared token is provided (e.g. iframe environments like Coze that can't issue device crypto). This causedreject-device-requiredinstead of the intended bypass.Fix
Add an explicit early return when
isControlUi && allowBypass === true: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:dangerouslyDisableDeviceAuth=truewithsharedAuthOk=false(the exact failing case from [Bug]:dangerouslyDisableDeviceAuthnot working in v2026.3.11 #43909)dangerouslyDisableDeviceAuth=truewithsharedAuthOk=true(remote iframe baseline)All 4 existing tests continue to pass.
Checklist
resolveConnectAuthDecision