F11: Failed HPKE authentication consumes the opener sequence number
F11: Failed HPKE authentication consumes the opener sequence number
- Finding: HPKE sequence desynchronization after authentication failure
- Affected Software: rustls 0.23.45 (AWS-LC HPKE implementation); rustls-aws-lc-rs development snapshot
99f2358cae29. - Date: September 2026
- Discoverer: OpenAI ([email protected])
HpkeOpener::open increments its sequence before authenticating the ciphertext. Retrying the same valid ciphertext after an incorrect-AAD failure then fails; sequence 1 succeeds instead. This diverges from the success-only transition in RFC 9180 §5.2.
Cause and prior work
The wrapper supplies its mutable key schedule as AWS-LC's nonce sequence. OpeningKey advances it before authentication. This is the Rustls HPKE wrapper's sequencing obligation, not a flaw in the generic AWS-LC nonce API. #3215 fixes counter width/overflow without changing failed-open behavior. #1963 explicitly supports standalone use of the HPKE API.
Source: rustls-aws-lc-rs/src/hpke.rs.
Reproduction
Use the existing rustls/ checkout at 99f2358cae29 and a standalone sibling repro/ directory outside its Cargo workspace. Save the blocks below as repro/Cargo.toml and repro/src/main.rs; run the commands from the directory containing both rustls/ and repro/.
[package]
name = "hpke-opener-check"
version = "0.0.0"
edition = "2024"
[workspace]
[dependencies]
rustls = { path = "../rustls/rustls", default-features = false }
rustls-aws-lc-rs = { path = "../rustls/rustls-aws-lc-rs" }use rustls_aws_lc_rs::hpke::ALL_SUPPORTED_SUITES;
fn main() {
for suite in ALL_SUPPORTED_SUITES {
let (public_key, private_key) = suite
.generate_key_pair()
.expect("generate keys");
let (enc, mut sealer) = suite
.setup_sealer(b"example", &public_key)
.expect("sealer");
let ciphertext = sealer
.seal(b"aad", b"message 0")
.expect("seal");
let ciphertext_1 = sealer
.seal(b"aad", b"message 1")
.expect("seal");
// Use independent contexts for the fresh control and the failed-open retry.
let mut opener = suite
.setup_opener(&enc, b"example", &private_key)
.expect("opener");
let mut control = suite
.setup_opener(&enc, b"example", &private_key)
.expect("control");
// The same ciphertext and AAD authenticate with an untouched opener.
assert_eq!(
control
.open(b"aad", &ciphertext)
.expect("fresh opener"),
b"message 0"
);
// Fail authentication first, then retry the original valid sequence-zero message.
assert!(
opener
.open(b"wrong aad", &ciphertext)
.is_err()
);
let retry_succeeded = opener.open(b"aad", &ciphertext).is_ok();
println!(
"{:?}: valid sequence-0 retry succeeds after failed authentication: {retry_succeeded}",
suite.suite()
);
assert!(!retry_succeeded, "bug no longer reproduces");
// A separate opener tests whether one failure advanced exactly to sequence one.
let mut skipped = suite
.setup_opener(&enc, b"example", &private_key)
.expect("opener");
assert!(
skipped
.open(b"wrong aad", &ciphertext)
.is_err()
);
assert_eq!(
skipped
.open(b"aad", &ciphertext_1)
.expect("sequence 1 after rejection"),
b"message 1"
);
println!(" sequence 1 succeeds, confirming rejected message consumed sequence 0");
}
}cargo +1.98.1 run --release --manifest-path repro/Cargo.tomlResult
In all 12 suites, an untouched opener authenticated sequence 0; wrong AAD failed; retrying genuine sequence 0 failed; a separate opener accepted genuine sequence 1 after one failed attempt.
Production TLS uses the sender for ECH; no production TLS opener path is established here. This is context desynchronization, not nonce reuse, authentication bypass, or a demonstrated TLS denial of service.
The 0.23.45 implementation behaved the same way in all 12 suites.
Suggested correction
Commit the recipient sequence increment only after authentication succeeds, retaining the existing overflow checks.
Disclaimer
This information is being shared by OpenAI solely for the purpose of improving security and reducing potential harm. This information is presented as-is. We make no representations or warranties, express or implied, as to the completeness, accuracy, or fitness for any particular purpose of the information. This includes, without limitation any suggestions or ideas presented on how to remedy or mitigate an identified vulnerability, including whether such suggestions or ideas would be effective and/or could have other negative impacts.
OpenAI disclaims any liability for direct or indirect damages arising from the reliance on, or use, misuse, or interpretation of this information. Any references to third-party systems, services, or entities are included solely for identification purposes and do not imply endorsement, responsibility, or attribution.
Source: rustls/rustls