fix(ui): send token/password auth in Control UI insecure contexts#44865
fix(ui): send token/password auth in Control UI insecure contexts#44865asyncjason wants to merge 3 commits intoopenclaw:mainfrom
Conversation
When crypto.subtle is unavailable (plain HTTP, non-localhost), selectConnectAuth() is skipped entirely, leaving selectedAuth empty. The explicit gateway token and password from the login form are read into explicitGatewayToken but never used in the auth object sent in the connect frame — auth ends up undefined. Fall back to the explicit token/password when selectedAuth has no auth fields, matching the comment on line 241 that promises "fall back to token-only auth" in insecure contexts. Without this fix, Control UI over plain HTTP always gets "device identity required" even with dangerouslyDisableDeviceAuth enabled, because sharedAuthOk is false (no token sent).
Verify that explicit token and password are sent in the connect frame when crypto.subtle is unavailable (plain HTTP contexts). Co-Authored-By: Claude <[email protected]>
Greptile SummaryThis PR fixes a bug where The fix adds two
Confidence Score: 5/5
Last reviewed commit: b0f3077 |
…cure-context-auth
🔒 Automated Security AssessmentStatus: ✅ PASSED — No security issues detected by automated scan. Scan Date: 2026-03-13 09:12 UTC Checks Performed
RecommendationAutomated checks passed. Manual review is still recommended for:
This comment was posted by the automated PR security scanner. False positives may occur — please verify findings manually. |
|
Superseded by #45088 which was merged with an equivalent fix (seeding |
Summary
GatewayBrowserClient.sendConnect()only callsselectConnectAuth()insideif (isSecureContext), so when the Control UI is accessed over plain HTTP (wherecrypto.subtleis unavailable), the explicit token and password from the login form are never included in the connect frame.sharedAuthOkis false, and the connection is rejected withCONTROL_UI_DEVICE_IDENTITY_REQUIRED— even whendangerouslyDisableDeviceAuthis enabled. This makes the Control UI completely unusable over plain HTTP (common in LAN/Docker reverse-proxy setups).isSecureContextblock, the explicit token (this.opts.token) and password (this.opts.password) are now used as fallbacks whenselectConnectAuth()was skipped. One new test verifies the insecure context path.selectConnectAuth()still runs and its results take precedence via??fallback. Device identity flow, retry logic, and all existing auth paths are untouched.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
Control UI now connects successfully over plain HTTP when a valid token or password is provided. Previously it always failed with "device identity required".
Security Impact (required)
this.opts, they just weren't being sentRepro + Verification
Environment
gateway.controlUi.dangerouslyDisableDeviceAuth: trueSteps
dangerouslyDisableDeviceAuth: truehttp://host/gateway/#token=<valid-token>Expected
Actual (before fix)
CONTROL_UI_DEVICE_IDENTITY_REQUIRED, close code 4008Evidence
New test
sends explicit token and password in insecure contexts without crypto.subtlefails before the fix (connect frame hasauth: undefined) and passes after (connect frame includes token and password).Gateway logs before fix:
code=4008, reason="connect failed", detailCONTROL_UI_DEVICE_IDENTITY_REQUIREDAfter fix: successful hello handshake, Control UI connected.
Human Verification (required)
Compatibility / Migration
Failure Recovery (if this breaks)
sendConnect()ui/src/ui/gateway.tsRisks and Mitigations
selectConnectAuth()already resolved different credentials??operator ensuresselectConnectAuth()results always take precedence; explicit values are only used when selectedAuth fields are undefined (i.e., when the function was skipped)Authored by Claude Code (Opus 4.6). Reviewed and tested by @asyncjason.