Skip to content

Commit 30c4b83

Browse files
committed
replay policy must be "reject" for aead-2022
1 parent 0f970a7 commit 30c4b83

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

crates/shadowsocks/src/context.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100,22 +100,17 @@ impl Context {
100100
return Ok(());
101101
}
102102

103-
match self.replay_policy {
104-
ReplayAttackPolicy::Default => {
105-
#[cfg(feature = "aead-cipher-2022")]
106-
if method.is_aead_2022() {
107-
return if self.replay_protector.check_nonce_and_set(method, nonce) {
108-
let err = io::Error::new(io::ErrorKind::Other, "detected repeated nonce (iv/salt)");
109-
Err(err)
110-
} else {
111-
Ok(())
112-
};
113-
}
103+
#[allow(unused_mut)]
104+
let mut replay_policy = self.replay_policy;
114105

115-
// AEAD, Stream should ignore by default
116-
Ok(())
117-
}
118-
ReplayAttackPolicy::Ignore => Ok(()),
106+
#[cfg(feature = "aead-cipher-2022")]
107+
if method.is_aead_2022() {
108+
// AEAD-2022 can't be ignored.
109+
replay_policy = ReplayAttackPolicy::Reject;
110+
}
111+
112+
match replay_policy {
113+
ReplayAttackPolicy::Default | ReplayAttackPolicy::Ignore => Ok(()),
119114
ReplayAttackPolicy::Detect => {
120115
if self.replay_protector.check_nonce_and_set(method, nonce) {
121116
warn!("detected repeated nonce (iv/salt) {:?}", ByteStr::new(nonce));

0 commit comments

Comments
 (0)