Skip to content

Commit 1ef8f17

Browse files
committed
fix(security): limit auto-pair to one-shot with identity check and token cleanup
Auto-pair unconditionally approved ALL pending device pairing requests for 10 minutes on every sandbox start. On headless/cloud installs this is an open window for unauthorized device pairing. Changes: - Clear all paired devices on sandbox start (revokes stale tokens from previous sessions — addresses token persistence concern) - Reduce initial timeout from 600s to 180s - Only approve devices with clientId 'openclaw-control-ui' (the chat UI); reject all other pending requests immediately - After first approval, reset deadline to now+5s (one-shot exit) - Clear remaining pending requests on exit - has_browser convergence logic unchanged
1 parent d37a09f commit 1ef8f17

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

‎scripts/nemoclaw-start.sh‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,17 @@ import json
7171
import subprocess
7272
import time
7373
74-
DEADLINE = time.time() + 600
74+
DEADLINE = time.time() + 180
7575
QUIET_POLLS = 0
7676
APPROVED = 0
7777
7878
def run(*args):
7979
proc = subprocess.run(args, capture_output=True, text=True)
8080
return proc.returncode, proc.stdout.strip(), proc.stderr.strip()
8181
82+
# Revoke all device tokens from previous sessions so they don't persist across restarts
83+
run('openclaw', 'devices', 'clear', '--yes')
84+
8285
while time.time() < DEADLINE:
8386
rc, out, err = run('openclaw', 'devices', 'list', '--json')
8487
if rc != 0 or not out:
@@ -97,15 +100,25 @@ while time.time() < DEADLINE:
97100
if pending:
98101
QUIET_POLLS = 0
99102
for device in pending:
100-
request_id = (device or {}).get('requestId')
103+
if not isinstance(device, dict):
104+
continue
105+
request_id = device.get('requestId')
101106
if not request_id:
102107
continue
108+
# Only approve the chat UI — reject unknown clients.
109+
client_id = device.get('clientId', '')
110+
if client_id != 'openclaw-control-ui':
111+
print(f'[auto-pair] skipping non-UI device request={request_id} clientId={client_id!r}')
112+
run('openclaw', 'devices', 'reject', request_id, '--json')
113+
continue
103114
arc, aout, aerr = run('openclaw', 'devices', 'approve', request_id, '--json')
104115
if arc == 0:
105116
APPROVED += 1
106-
print(f'[auto-pair] approved request={request_id}')
117+
print(f'[auto-pair] approved request={request_id} clientId={client_id}')
107118
elif aout or aerr:
108119
print(f'[auto-pair] approve failed request={request_id}: {(aerr or aout)[:400]}')
120+
if APPROVED >= 1:
121+
DEADLINE = time.time() + 5
109122
time.sleep(1)
110123
continue
111124
@@ -122,6 +135,9 @@ while time.time() < DEADLINE:
122135
time.sleep(1)
123136
else:
124137
print(f'[auto-pair] watcher timed out approvals={APPROVED}')
138+
139+
# Clean up: reject any remaining pending requests so no stale requests linger
140+
run('openclaw', 'devices', 'clear', '--pending', '--yes')
125141
PYAUTOPAIR
126142
echo "[gateway] auto-pair watcher launched (pid $!)"
127143
}

0 commit comments

Comments
 (0)