Skip to content

Commit 8f364d6

Browse files
committed
ripv2: improve protection against replay attacks
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
1 parent 070107f commit 8f364d6

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

holo-rip/src/instance.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::collections::BTreeMap;
88
use std::net::Ipv4Addr;
99
use std::sync::atomic::AtomicU32;
1010
use std::sync::Arc;
11-
use std::time::Duration;
11+
use std::time::{Duration, SystemTime, UNIX_EPOCH};
1212

1313
use async_trait::async_trait;
1414
use chrono::{DateTime, Utc};
@@ -482,7 +482,17 @@ where
482482
neighbors: Default::default(),
483483
routes: Default::default(),
484484
statistics: Default::default(),
485-
auth_seqno: Default::default(),
485+
// Initialize the authentication sequence number as the number of
486+
// seconds since the Unix epoch (1 January 1970).
487+
// By using this approach, the chances of successfully replaying
488+
// packets from a restarted RIP instance are significantly reduced.
489+
auth_seqno: Arc::new(
490+
(SystemTime::now()
491+
.duration_since(UNIX_EPOCH)
492+
.expect("Time went backwards")
493+
.as_secs() as u32)
494+
.into(),
495+
),
486496
}
487497
}
488498

0 commit comments

Comments
 (0)