Security hardening: HOLDS_ONE scope, pairing-confirmation, session revocation, pre-auth connection cap - #107
Open
MegaManSec wants to merge 4 commits into
Open
Security hardening: HOLDS_ONE scope, pairing-confirmation, session revocation, pre-auth connection cap#107MegaManSec wants to merge 4 commits into
MegaManSec wants to merge 4 commits into
Conversation
The HOLDS_ONE handler validated MAC syntax then queried live Bluetooth state for any address, letting an authenticated peer probe arbitrary MACs for connection presence. Gate on membership in the registered peripheral list, mirroring the .connectOne/.unregisterOne handlers; unregistered addresses get OP_FAILED.
devicePairingUserConfirmationRequest replied replyUserConfirmation(true) unconditionally, auto-accepting SSP numeric comparison for any pairing, including one an unsolicited device initiates toward this Mac. Only confirm when the request matches an in-flight pair this Mac started (pendingPairs === pair); otherwise refuse. Handoff/connect flows still auto-confirm, so the automatic switching UX is unchanged.
Command dispatch only checked the per-connection authenticated flag, so a peer that authenticated before the user unpaired/re-paired kept full command control until its timers expired (up to the 5-minute budget). Re-verify the current PSK fingerprint against the one the handshake proved before handling each frame, and tear down when it no longer matches. Steady-state sessions are unaffected (the key doesn't change).
The listener accepted and retained an IncomingConnection per socket with no concurrency limit, and a stalled handshake records no rate-limiter failure, so a LAN client could pin many pre-auth handshakes at once. Add per-IP and global caps on in-flight pre-auth connections in RateLimiter, reserved before the handshake and released on auth or teardown. Caps are generous, so the legitimate peer is never refused.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four independent, behavior-preserving hardening fixes (one commit each). Not build-verified locally (Command Line Tools only, no full Xcode).
HOLDS_ONE presence oracle (CWE-200). The handler answered a live-connection query for any syntactically valid MAC, letting an authenticated peer probe arbitrary Bluetooth devices. Now gated on membership in the registered peripheral list, mirroring
.connectOne/.unregisterOne.Auto-accepted pairing confirmation (CWE-287).
devicePairingUserConfirmationRequestrepliedreplyUserConfirmation(true)unconditionally. Now only confirms a pairing this Mac itself initiated (pendingPairs[address] === pair); unsolicited requests are refused. Handoff/connect flows still auto-confirm, so automatic switching is unchanged. (Does not fully close the same-address MITM race during an initiated re-pair — that needs a UI decision; see below.)Post-revocation command window (CWE-613). Dispatch only checked the per-connection
authenticatedflag, so a peer authenticated before an unpair/re-pair kept command control until its timers expired (up to 5 min). Each inbound frame now re-checks that the current PSK fingerprint still matches the one the handshake proved, tearing down on mismatch. Steady-state sessions are unaffected.Unbounded pre-auth connections (CWE-400). The listener accepted and retained a handler per socket with no cap, and stalled handshakes record no rate-limiter failure. Added per-IP (8) and global (64) caps on in-flight pre-auth connections, reserved before the handshake and released on auth or teardown. Caps are generous, so the legitimate peer is never refused.
Deliberately not included (need product/UX decisions, not mechanical fixes)