mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 05:25:19 +00:00
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:
@@ -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
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user