Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport robust reset detection to 0.10 #1647

Merged
merged 2 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion quinn-proto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "quinn-proto"
version = "0.10.3"
version = "0.10.4"
edition = "2021"
rust-version = "1.63"
license = "MIT OR Apache-2.0"
Expand Down
41 changes: 18 additions & 23 deletions quinn-proto/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2007,29 +2007,28 @@ impl Connection {
.map(move |number| (packet, number)),
};
let result = match decrypted {
_ if stateless_reset => {
debug!("got stateless reset");
Err(ConnectionError::Reset)
}
Err(Some(e)) => {
warn!("illegal packet: {}", e);
Err(e.into())
}
Err(None) => {
if stateless_reset {
debug!("got stateless reset");
Err(ConnectionError::Reset)
debug!("failed to authenticate packet");
self.authentication_failures += 1;
let integrity_limit = self.spaces[self.highest_space]
.crypto
.as_ref()
.unwrap()
.packet
.local
.integrity_limit();
if self.authentication_failures > integrity_limit {
Err(TransportError::AEAD_LIMIT_REACHED("integrity limit violated").into())
} else {
debug!("failed to authenticate packet");
self.authentication_failures += 1;
let integrity_limit = self.spaces[self.highest_space]
.crypto
.as_ref()
.unwrap()
.packet
.local
.integrity_limit();
if self.authentication_failures > integrity_limit {
Err(TransportError::AEAD_LIMIT_REACHED("integrity limit violated").into())
} else {
return;
}
return;
}
}
Ok((packet, number)) => {
Expand All @@ -2041,12 +2040,8 @@ impl Connection {

let is_duplicate = |n| self.spaces[packet.header.space()].dedup.insert(n);
if number.map_or(false, is_duplicate) {
if stateless_reset {
Err(ConnectionError::Reset)
} else {
warn!("discarding possible duplicate packet");
return;
}
warn!("discarding possible duplicate packet");
return;
} else if self.state.is_handshake() && packet.header.is_short() {
// TODO: SHOULD buffer these to improve reordering tolerance.
trace!("dropping short packet during handshake");
Expand Down
Loading