fix: extend backoff window on blocked attempts (Codex P2 feedback)

Update lastAnnounceTime to 'now' when rate-limiting subscription attempts.
This ensures each blocked attempt extends the suppression window, preventing
attackers from waiting out the backoff while continuously spamming attempts.

Previously, the backoff timer was only based on the last successful announce,
allowing attackers to receive an announce as soon as the initial backoff
expired regardless of how many blocked attempts occurred in between.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
jack
2026-01-12 11:00:36 -10:00
co-authored by Claude Opus 4.5
parent 99896bcded
commit 9cd955ae2f
+3 -1
View File
@@ -2211,13 +2211,15 @@ extension BLEService: CBPeripheralManagerDelegate {
SecureLogger.warning("🛡️ BCH-01-004: Rate-limited announce for central \(centralUUID.prefix(8))... (backoff: \(Int(existingState.currentBackoffSeconds))s, attempts: \(existingState.attemptCount))", category: .security)
// Increment attempt count and increase backoff
// Update lastAnnounceTime to 'now' so each blocked attempt extends the suppression window
// This prevents attackers from waiting out the backoff while spamming attempts
let newAttemptCount = existingState.attemptCount + 1
let newBackoff = min(
existingState.currentBackoffSeconds * TransportConfig.bleSubscriptionRateLimitBackoffFactor,
TransportConfig.bleSubscriptionRateLimitMaxBackoffSeconds
)
centralSubscriptionRateLimits[centralUUID] = SubscriptionRateLimitState(
lastAnnounceTime: existingState.lastAnnounceTime,
lastAnnounceTime: now, // Reset timer on each blocked attempt
attemptCount: newAttemptCount,
currentBackoffSeconds: newBackoff
)