Skip to content

fix: keep auto-reconnect probes off the switch rate limiter and untrusted peers - #45

Merged
MegaManSec merged 1 commit into
mainfrom
fix/auto-reconnect-probe-safety
Jun 7, 2026
Merged

fix: keep auto-reconnect probes off the switch rate limiter and untrusted peers#45
MegaManSec merged 1 commit into
mainfrom
fix/auto-reconnect-probe-safety

Conversation

@MegaManSec

Copy link
Copy Markdown
Owner

Follow-up extending the same outbound-rate-limiter decoupling from #44 to the auto-reconnect watcher's read-only HOLDS_ONE probes (fired every ~5s while recovering a dropped peripheral, so the watcher never yanks a peripheral the peer is actively using).

Don't let background probes trip the switch rate limiter

HOLDS_ONE fed the shared OutboundRateLimiter, so a run of failing probes — a down peer, or several peripherals recovering at once — could trip it and fail-fast a user-initiated switch's preflight .ping (the row greys / the switch is rejected). Threads countsTowardRateLimit: false through executeHoldsOne so these fixed-cadence probes opt out, exactly as the reachability poll already does. Safe: the watcher's own bounds (in-flight guard, 5s timer, 600s give-up, post-failure local reconnect) already throttle it, and the outbound limiter is client-side back-off, not the security boundary.

Don't probe TOFU-mismatched peers

Both probe sites (reclaimIfPeerIsFree and the wake-time reclaim) consulted networkDevices.first unconditionally, so a peer flagged as an identity mismatch (pendingFingerprint set) still got probed with our stale key — auth-failing into the peer's inbound rate limiter and reaching out to an identity TOFU exists to quarantine. Gates both on pendingFingerprint == nil, folding the mismatch into the existing "no trusted peer → reclaim locally" branch (the safe default for an untrusted peer).

Foreground switches were already guarded at the UI layer (isSwitchable checks pendingFingerprint) and the reachability poll already guards both ways — this just makes the background watcher consistent with them.


Builds on the countsTowardRateLimit plumbing from #44 (now on main); rebased onto main so the diff is just these two watcher fixes.

…sted peers

The auto-reconnect watcher's read-only HOLDS_ONE probes now opt out of the OutboundRateLimiter (countsTowardRateLimit: false, threaded through executeHoldsOne) so a run of them — a down peer, or several peripherals recovering at once — can't trip the limiter that gates a user-initiated switch's preflight ping. This mirrors the reachability poll's existing exemption. Both probe sites (reclaimIfPeerIsFree and the wake-time reclaim) also now require device.pendingFingerprint == nil, so a TOFU-mismatched peer is treated as 'no trusted peer': the peripheral is reclaimed locally instead of probing a flagged identity with our stale key (which would auth-fail into the peer's inbound limiter).
@MegaManSec
MegaManSec merged commit 97e8585 into main Jun 7, 2026
2 checks passed
@MegaManSec
MegaManSec deleted the fix/auto-reconnect-probe-safety branch June 7, 2026 20:02
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 2.14.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant