Skip to content

Security hardening: HOLDS_ONE scope, pairing-confirmation, session revocation, pre-auth connection cap - #107

Open
MegaManSec wants to merge 4 commits into
mainfrom
fix/security-hardening-batch
Open

Security hardening: HOLDS_ONE scope, pairing-confirmation, session revocation, pre-auth connection cap#107
MegaManSec wants to merge 4 commits into
mainfrom
fix/security-hardening-batch

Conversation

@MegaManSec

Copy link
Copy Markdown
Owner

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). devicePairingUserConfirmationRequest replied replyUserConfirmation(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 authenticated flag, 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)

  • Sync overwriting the peripheral allowlist (CWE-862): sync is a frequent, automatic, whole-list operation between the two paired Macs, so a safe fix (confirm peer-introduced new peripherals) is a UX change, not a patch.
  • User-chosen low-entropy pairing codes / static PBKDF2 salt (CWE-521): generated codes are safe (60 bits + 600k PBKDF2); a salt change would break cross-version pairing. Needs a decision on whether to forbid custom codes.
  • URL-scheme automation (CWE-306): inherent to macOS custom URL schemes; only toggles the user's own peripherals between their own paired Macs. Informational.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant