#22280: fix(gateway): silently auto-approve local paired-device scope upgrades
gateway
size: S
Cluster:
Device Pairing and Gateway Fixes
## Summary
Fix local paired-device reconnect regressions where role/scope upgrades could return `pairing required` instead of silently proceeding.
## What changed
- Gateway pairing decision now allows silent pairing for local upgrade paths only when there is an existing paired-device context.
- Keeps silent behavior for `not-paired` local flow.
- Adds an e2e regression test: `silently auto-approves local CLI scope upgrades`.
## Security rationale
- Avoids trusting client-claimed `client.id` / `client.mode` for privileged silent behavior.
- Uses gateway-observed locality plus existing paired-device context for upgrade silent path.
## Validation
- Added targeted e2e test in `src/gateway/server.auth.e2e.test.ts`.
- Verified behavior:
- test fails without patch (`expected true, received false`)
- test passes with patch
## Related issue
- Closes #22279
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Fixes local paired-device reconnect regression by allowing silent auto-approval for scope/role upgrades when a device is already paired and connecting locally.
- Modified `requirePairing` function to accept `hasExistingPairing` parameter
- Silent pairing now allowed for: `not-paired` reason OR when `hasExistingPairing=true` (both require `isLocalClient`)
- All upgrade path calls (`role-upgrade`, `scope-upgrade`) now pass `hasExistingPairing=true`
- Added e2e regression test verifying CLI scope upgrade (`operator.read` → `operator.admin`) succeeds silently for local connections
- Security model preserved: relies on gateway-observed locality (`isLocalDirectRequest`) rather than client-claimed attributes
<h3>Confidence Score: 5/5</h3>
- Safe to merge with minimal risk
- Fix is well-targeted with clear security rationale, comprehensive test coverage, and preserves existing security model by using server-validated locality rather than client claims
- No files require special attention
<sub>Last reviewed commit: d52bbde</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#22587: fix(gateway): silently auto-approve local paired-device scope upgrades
by abhishekp76 · 2026-02-21
94.6%
#22712: fix(gateway): auto-approve all device pairing for localhost connect...
by NewdlDewdl · 2026-02-21
90.5%
#23708: fix(gateway): auto-approve scope upgrades for loopback clients
by widingmarcus-cyber · 2026-02-22
89.4%
#17425: fix(gateway): auto-approve scope/role upgrades for already-paired d...
by sauerdaniel · 2026-02-15
88.0%
#22365: fix(gateway): auto-approve loopback scope upgrades
by AIflow-Labs · 2026-02-21
87.1%
#23690: fix(gateway): subagent sessions fail with pairing required on loopb...
by yinghaosang · 2026-02-22
86.1%
#21666: fix(gateway): restrict auto-paired device scopes to safe defaults
by AI-Reviewer-QS · 2026-02-20
86.0%
#19088: fix(gateway): allow startup with unset mode and fix pairing for local…
by mdanassaif · 2026-02-17
85.4%
#21664: fix(gateway): require re-pairing for legacy devices that lack scope...
by AI-Reviewer-QS · 2026-02-20
85.3%
#22794: fix: allow local clients to auto-pair without manual approval
by Matrix-Meta · 2026-02-21
84.9%