Skip to content

Commit 2a586c7

Browse files
committed
fix: Use fail-closed behavior for IP access control lock contention
1 parent 541eedb commit 2a586c7

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/server/security/access.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,14 +336,18 @@ impl SharedIpAccessControl {
336336
/// Check if an IP address is allowed (blocking version).
337337
///
338338
/// This is useful when you need to check access in a synchronous context.
339+
/// On lock contention, defaults to DENY for security (fail-closed).
339340
pub fn check_sync(&self, ip: &IpAddr) -> AccessPolicy {
340341
// Try to acquire read lock without blocking
341342
if let Ok(guard) = self.inner.try_read() {
342343
return guard.check(ip);
343344
}
344-
// If lock is contended, default to allow to avoid blocking
345-
tracing::warn!("Access control lock contended, defaulting to allow");
346-
AccessPolicy::Allow
345+
// Fail-closed: deny on lock contention to prevent security bypass
346+
tracing::warn!(
347+
ip = %ip,
348+
"Access control lock contended, denying for security"
349+
);
350+
AccessPolicy::Deny
347351
}
348352

349353
/// Block an IP address at runtime.

0 commit comments

Comments
 (0)