Merge pull request #944 from permissionlesstech/fix/BCH-01-011-timestamp-validation

fix(security): reduce timestamp validation window to ±5 minutes [BCH-01-011]
This commit is contained in:
jack
2026-01-12 15:33:38 -10:00
committed by GitHub
2 changed files with 37 additions and 17 deletions
+5 -3
View File
@@ -52,11 +52,13 @@ struct InputValidator {
// MessageType/NoisePayloadType enums; keeping validator free of stale lists.
/// Validates timestamp is reasonable (not too far in past or future)
/// BCH-01-011: Reduced from ±1 hour to ±5 minutes to limit replay attack window
static func validateTimestamp(_ timestamp: Date) -> Bool {
let now = Date()
let oneHourAgo = now.addingTimeInterval(-3600)
let oneHourFromNow = now.addingTimeInterval(3600)
return timestamp >= oneHourAgo && timestamp <= oneHourFromNow
// 5 minutes = 300 seconds (industry standard for replay protection)
let fiveMinutesAgo = now.addingTimeInterval(-300)
let fiveMinutesFromNow = now.addingTimeInterval(300)
return timestamp >= fiveMinutesAgo && timestamp <= fiveMinutesFromNow
}
}