Skip to content

Commit 6f603c7

Browse files
committed
security: harden gateway auth defaults and restrict auto-pair (Fixes #117)
- dangerouslyDisableDeviceAuth now defaults to false; only enabled when NEMOCLAW_DISABLE_DEVICE_AUTH=1 is explicitly set (removes the "temporary" bypass from commit 5fb629f that was never reverted) - allowInsecureAuth is now derived from the CHAT_UI_URL scheme: true for http (local dev), false for https (production/remote) - auto-pair watcher now only approves known client types (openclaw-control-ui, webchat) instead of unconditionally approving every pending device request
1 parent 241ffb2 commit 6f603c7

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

‎scripts/nemoclaw-start.sh‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
# gateway inside the sandbox so the forwarded host port has a live upstream.
77
#
88
# Optional env:
9-
# NVIDIA_API_KEY API key for NVIDIA-hosted inference
10-
# CHAT_UI_URL Browser origin that will access the forwarded dashboard
9+
# NVIDIA_API_KEY API key for NVIDIA-hosted inference
10+
# CHAT_UI_URL Browser origin that will access the forwarded dashboard
11+
# NEMOCLAW_DISABLE_DEVICE_AUTH Set to "1" to skip device-pairing auth (development only)
1112

1213
set -euo pipefail
1314

@@ -42,9 +43,11 @@ if chat_origin not in origins:
4243
4344
gateway = cfg.setdefault('gateway', {})
4445
gateway['mode'] = 'local'
46+
disable_device_auth = os.environ.get('NEMOCLAW_DISABLE_DEVICE_AUTH', '') == '1'
47+
allow_insecure = parsed.scheme != 'https'
4548
gateway['controlUi'] = {
46-
'allowInsecureAuth': True,
47-
'dangerouslyDisableDeviceAuth': True,
49+
'allowInsecureAuth': allow_insecure,
50+
'dangerouslyDisableDeviceAuth': disable_device_auth,
4851
'allowedOrigins': origins,
4952
}
5053
gateway['trustedProxies'] = ['127.0.0.1', '::1']
@@ -136,14 +139,23 @@ while time.time() < DEADLINE:
136139
137140
if pending:
138141
QUIET_POLLS = 0
142+
ALLOWED_CLIENTS = {'openclaw-control-ui'}
143+
ALLOWED_MODES = {'webchat'}
139144
for device in pending:
140-
request_id = (device or {}).get('requestId')
145+
if not isinstance(device, dict):
146+
continue
147+
client_id = device.get('clientId', '')
148+
client_mode = device.get('clientMode', '')
149+
if client_id not in ALLOWED_CLIENTS and client_mode not in ALLOWED_MODES:
150+
print(f'[auto-pair] rejected unknown client={client_id} mode={client_mode}')
151+
continue
152+
request_id = device.get('requestId')
141153
if not request_id:
142154
continue
143155
arc, aout, aerr = run('openclaw', 'devices', 'approve', request_id, '--json')
144156
if arc == 0:
145157
APPROVED += 1
146-
print(f'[auto-pair] approved request={request_id}')
158+
print(f'[auto-pair] approved request={request_id} client={client_id}')
147159
elif aout or aerr:
148160
print(f'[auto-pair] approve failed request={request_id}: {(aerr or aout)[:400]}')
149161
time.sleep(1)

0 commit comments

Comments
 (0)