Skip to content

Commit f76e3c1

Browse files
committed
fix: enforce secure control ui auth
1 parent b4776af commit f76e3c1

18 files changed

Lines changed: 294 additions & 48 deletions

‎CHANGELOG.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ Docs: https://docs.clawd.bot
1414
- CLI: move gateway service commands under `clawdbot gateway` and add `gateway probe` for reachability.
1515
- Sessions: add per-channel reset overrides via `session.resetByChannel`. (#1353) Thanks @cash-echo-bot.
1616

17+
### Breaking
18+
- **BREAKING:** Control UI now rejects insecure HTTP without device identity by default. Use HTTPS (Tailscale Serve) or set `gateway.controlUi.allowInsecureAuth: true` to allow token-only auth. https://docs.clawd.bot/web/control-ui#insecure-http
19+
1720
### Fixes
1821
- Gateway: keep auto bind loopback-first and add explicit tailnet binding to avoid Tailscale taking over local UI. (#1380)
1922
- Embedded runner: persist injected history images so attachments aren’t reloaded each turn. (#1374) Thanks @Nicell.

‎docs/gateway/configuration.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2671,6 +2671,8 @@ Control UI base path:
26712671
- `gateway.controlUi.basePath` sets the URL prefix where the Control UI is served.
26722672
- Examples: `"/ui"`, `"/clawdbot"`, `"/apps/clawdbot"`.
26732673
- Default: root (`/`) (unchanged).
2674+
- `gateway.controlUi.allowInsecureAuth` allows token-only auth over **HTTP** (no device identity).
2675+
Default: `false`. Prefer HTTPS (Tailscale Serve) or `127.0.0.1`.
26742676

26752677
Related docs:
26762678
- [Control UI](/web/control-ui)

‎docs/gateway/protocol.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ The Gateway treats these as **claims** and enforces server-side allowlists.
198198
- **Local** connects include loopback and the gateway host’s own tailnet address
199199
(so same‑host tailnet binds can still auto‑approve).
200200
- All WS clients must include `device` identity during `connect` (operator + node).
201+
Control UI can omit it **only** when `gateway.controlUi.allowInsecureAuth` is enabled.
201202
- Non-local connections must sign the server-provided `connect.challenge` nonce.
202203

203204
## TLS + pinning

‎docs/gateway/security.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ When the audit prints findings, treat this as a priority order:
5252
5. **Plugins/extensions**: only load what you explicitly trust.
5353
6. **Model choice**: prefer modern, instruction-hardened models for any bot with tools.
5454

55+
## Control UI over HTTP
56+
57+
The Control UI needs a **secure context** (HTTPS or localhost) to generate device
58+
identity. If you enable `gateway.controlUi.allowInsecureAuth`, the UI falls back
59+
to **token-only auth** on plain HTTP and skips device pairing. This is a security
60+
downgrade—prefer HTTPS (Tailscale Serve) or open the UI on `127.0.0.1`.
61+
62+
`clawdbot security audit` warns when this setting is enabled.
63+
5564
## Local session logs live on disk
5665

5766
Clawdbot stores session transcripts on disk under `~/.clawdbot/agents/<agentId>/sessions/*.jsonl`.

‎docs/gateway/troubleshooting.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ See also: [Health checks](/gateway/health) and [Logging](/logging).
3131

3232
## Common Issues
3333

34+
### Control UI fails on HTTP ("device identity required" / "connect failed")
35+
36+
If you open the dashboard over plain HTTP (e.g. `http://<lan-ip>:18789/` or
37+
`http://<tailscale-ip>:18789/`), the browser runs in a **non-secure context** and
38+
blocks WebCrypto, so device identity can’t be generated.
39+
40+
**Fix:**
41+
- Prefer HTTPS via [Tailscale Serve](/gateway/tailscale).
42+
- Or open locally on the gateway host: `http://127.0.0.1:18789/`.
43+
- If you must stay on HTTP, enable `gateway.controlUi.allowInsecureAuth: true` and
44+
use a gateway token (token-only; no device identity/pairing). See
45+
[Control UI](/web/control-ui#insecure-http).
46+
3447
### CI Secrets Scan Failed
3548

3649
This means `detect-secrets` found new candidates not yet in the baseline.

‎docs/help/troubleshooting.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ Almost always a Node/npm PATH issue. Start here:
3838
- [Gateway troubleshooting](/gateway/troubleshooting)
3939
- [Gateway authentication](/gateway/authentication)
4040

41+
### Control UI fails on HTTP (device identity required)
42+
43+
- [Gateway troubleshooting](/gateway/troubleshooting)
44+
- [Control UI](/web/control-ui#insecure-http)
45+
4146
### Service says running, but RPC probe fails
4247

4348
- [Gateway troubleshooting](/gateway/troubleshooting)

‎docs/web/control-ui.md‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,33 @@ Then open:
8686

8787
Paste the token into the UI settings (sent as `connect.params.auth.token`).
8888

89+
## Insecure HTTP
90+
91+
If you open the dashboard over plain HTTP (`http://<lan-ip>` or `http://<tailscale-ip>`),
92+
the browser runs in a **non-secure context** and blocks WebCrypto. By default,
93+
Clawdbot **blocks** Control UI connections without device identity.
94+
95+
**Recommended fix:** use HTTPS (Tailscale Serve) or open the UI locally:
96+
- `https://<magicdns>/` (Serve)
97+
- `http://127.0.0.1:18789/` (on the gateway host)
98+
99+
**Downgrade example (token-only over HTTP):**
100+
101+
```json5
102+
{
103+
gateway: {
104+
controlUi: { allowInsecureAuth: true },
105+
bind: "tailnet",
106+
auth: { mode: "token", token: "replace-me" }
107+
}
108+
}
109+
```
110+
111+
This disables device identity + pairing for the Control UI. Use only if you
112+
trust the network.
113+
114+
See [Tailscale](/gateway/tailscale) for HTTPS setup guidance.
115+
89116
## Building the UI
90117

91118
The Gateway serves static files from `dist/control-ui`. Build them with:

‎src/config/schema.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ const FIELD_LABELS: Record<string, string> = {
187187
"tools.web.fetch.maxRedirects": "Web Fetch Max Redirects",
188188
"tools.web.fetch.userAgent": "Web Fetch User-Agent",
189189
"gateway.controlUi.basePath": "Control UI Base Path",
190+
"gateway.controlUi.allowInsecureAuth": "Allow Insecure Control UI Auth",
190191
"gateway.http.endpoints.chatCompletions.enabled": "OpenAI Chat Completions Endpoint",
191192
"gateway.reload.mode": "Config Reload Mode",
192193
"gateway.reload.debounceMs": "Config Reload Debounce (ms)",
@@ -345,6 +346,8 @@ const FIELD_HELP: Record<string, string> = {
345346
"gateway.auth.password": "Required for Tailscale funnel.",
346347
"gateway.controlUi.basePath":
347348
"Optional URL prefix where the Control UI is served (e.g. /clawdbot).",
349+
"gateway.controlUi.allowInsecureAuth":
350+
"Allow Control UI auth over insecure HTTP (token-only; not recommended).",
348351
"gateway.http.endpoints.chatCompletions.enabled":
349352
"Enable the OpenAI-compatible `POST /v1/chat/completions` endpoint (default: false).",
350353
"gateway.reload.mode": 'Hot reload strategy for config changes ("hybrid" recommended).',

‎src/config/types.gateway.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export type GatewayControlUiConfig = {
5151
enabled?: boolean;
5252
/** Optional base path prefix for the Control UI (e.g. "/clawdbot"). */
5353
basePath?: string;
54+
/** Allow token-only auth over insecure HTTP (default: false). */
55+
allowInsecureAuth?: boolean;
5456
};
5557

5658
export type GatewayAuthMode = "token" | "password";

‎src/config/zod-schema.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ export const ClawdbotSchema = z
282282
.object({
283283
enabled: z.boolean().optional(),
284284
basePath: z.string().optional(),
285+
allowInsecureAuth: z.boolean().optional(),
285286
})
286287
.strict()
287288
.optional(),

0 commit comments

Comments
 (0)