Skip to content
Open
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
99 changes: 75 additions & 24 deletions impit/src/fingerprint/database/chrome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ pub mod chrome_155 {
/// profile leaves it out.
///
/// Relative to the chrome_142 profile, Chrome 151 leads its signature_algorithms
/// list with the three ML-DSA codepoints, and this profile also sends the GREASE
/// extensions above.
/// list with the three ML-DSA codepoints.
pub mod chrome_151 {
use super::*;

Expand Down Expand Up @@ -348,6 +347,9 @@ pub mod chrome_151 {
}

/// Chrome 142 fingerprint module
///
/// Sends Chrome's two GREASE extensions, an empty one first and a 1-byte one
/// last, as real Chrome 142 does in every TCP ClientHello.
pub mod chrome_142 {
use super::*;

Expand Down Expand Up @@ -438,7 +440,8 @@ pub mod chrome_142 {
ExtensionType::ApplicationSettings,
],
)
.with_new_alps_codepoint(true),
.with_new_alps_codepoint(true)
.with_grease_first_and_last(true),
// ECH configuration (GREASE mode)
Some(EchConfig::new(
EchMode::Grease {
Expand Down Expand Up @@ -495,6 +498,9 @@ pub mod chrome_142 {
}

/// Chrome 136 fingerprint module
///
/// Sends Chrome's two GREASE extensions, an empty one first and a 1-byte one
/// last, as real Chrome 136 does in every TCP ClientHello.
pub mod chrome_136 {
use super::*;

Expand Down Expand Up @@ -585,7 +591,8 @@ pub mod chrome_136 {
ExtensionType::ApplicationSettings,
],
)
.with_new_alps_codepoint(true),
.with_new_alps_codepoint(true)
.with_grease_first_and_last(true),
// ECH configuration (GREASE mode)
Some(EchConfig::new(
EchMode::Grease {
Expand Down Expand Up @@ -642,6 +649,9 @@ pub mod chrome_136 {
}

/// Chrome 133 fingerprint module
///
/// Sends Chrome's two GREASE extensions, an empty one first and a 1-byte one
/// last, as real Chrome 133 does in every TCP ClientHello.
pub mod chrome_133 {
use super::*;

Expand Down Expand Up @@ -726,7 +736,8 @@ pub mod chrome_133 {
ExtensionType::CompressCertificate,
ExtensionType::ApplicationSettings,
],
),
)
.with_grease_first_and_last(true),
// ECH configuration (GREASE mode)
Some(EchConfig::new(
EchMode::Grease {
Expand Down Expand Up @@ -783,6 +794,9 @@ pub mod chrome_133 {
}

/// Chrome 124 fingerprint module
///
/// Sends Chrome's two GREASE extensions, an empty one first and a 1-byte one
/// last, as real Chrome 124 does in every TCP ClientHello.
pub mod chrome_124 {
use super::*;

Expand Down Expand Up @@ -867,7 +881,8 @@ pub mod chrome_124 {
ExtensionType::CompressCertificate,
ExtensionType::ApplicationSettings,
],
),
)
.with_grease_first_and_last(true),
// ECH configuration (GREASE mode)
Some(EchConfig::new(
EchMode::Grease {
Expand Down Expand Up @@ -924,6 +939,9 @@ pub mod chrome_124 {
}

/// Chrome 131 fingerprint module
///
/// Sends Chrome's two GREASE extensions, an empty one first and a 1-byte one
/// last, as real Chrome 131 does in every TCP ClientHello.
pub mod chrome_131 {
use super::*;

Expand Down Expand Up @@ -1011,7 +1029,8 @@ pub mod chrome_131 {
ExtensionType::CompressCertificate,
ExtensionType::ApplicationSettings,
],
),
)
.with_grease_first_and_last(true),
// ECH configuration (GREASE mode)
Some(EchConfig::new(
EchMode::Grease {
Expand Down Expand Up @@ -1068,6 +1087,11 @@ pub mod chrome_131 {
}

/// Chrome 100 fingerprint module
///
/// Its TLS fingerprint, which chrome_101 to chrome_116 reuse, sends Chrome's two
/// GREASE extensions: an empty one first and a 1-byte one last, then padding.
/// This follows real Chrome 116, where it was measured, and BoringSSL, which
/// already placed them this way before Chrome 100.
pub mod chrome_100 {
use super::*;

Expand Down Expand Up @@ -1134,7 +1158,6 @@ pub mod chrome_100 {
false,
None,
vec![
ExtensionType::Grease,
ExtensionType::ServerName,
ExtensionType::ExtendedMasterSecret,
ExtensionType::RenegotiationInfo,
Expand All @@ -1150,12 +1173,10 @@ pub mod chrome_100 {
ExtensionType::SupportedVersions,
ExtensionType::CompressCertificate,
ExtensionType::ApplicationSettings,
// No trailing GREASE: rustls has one GREASE extension type, and repeating it
// makes BoringSSL servers reject the ClientHello (#575).
ExtensionType::Padding,
],
)
.with_padding(true), // Chrome 100 uses padding extension
.with_padding(true) // Chrome 100 uses padding extension
.with_grease_first_and_last(true),
// No ECH in Chrome 100
None,
// ALPN protocols
Expand Down Expand Up @@ -1371,6 +1392,9 @@ pub mod chrome_116 {
}

/// Chrome 125 fingerprint module
///
/// Sends Chrome's two GREASE extensions, an empty one first and a 1-byte one
/// last, as real Chrome 125 does in every TCP ClientHello.
pub mod chrome_125 {
use super::*;

Expand Down Expand Up @@ -1457,7 +1481,8 @@ pub mod chrome_125 {
ExtensionType::CompressCertificate,
ExtensionType::ApplicationSettings,
],
),
)
.with_grease_first_and_last(true),
// ECH configuration (GREASE mode)
Some(EchConfig::new(
EchMode::Grease {
Expand Down Expand Up @@ -1653,24 +1678,50 @@ mod tests {
}
}

// Chrome's two GREASE extensions: an empty one first and a 1-byte one last. impit's hello carries GREASE ECH and
// no pre_shared_key, so last also means after ECH.
// Chrome's two GREASE extensions: an empty one first and a 1-byte one last, after ECH when the profile sends it.
// Only padding follows the last one (impit's hello here carries no pre_shared_key).
#[test]
fn chrome_profiles_send_grease_extensions_first_and_last() {
for (name, fp) in [
("chrome_157", chrome_157::fingerprint()),
("chrome_156", chrome_156::fingerprint()),
("chrome_155", chrome_155::fingerprint()),
("chrome_151", chrome_151::fingerprint()),
// (profile, sends GREASE ECH)
for (name, fp, has_ech) in [
("chrome_157", chrome_157::fingerprint(), true),
("chrome_156", chrome_156::fingerprint(), true),
("chrome_155", chrome_155::fingerprint(), true),
("chrome_151", chrome_151::fingerprint(), true),
("chrome_142", chrome_142::fingerprint(), true),
("chrome_136", chrome_136::fingerprint(), true),
("chrome_133", chrome_133::fingerprint(), true),
("chrome_131", chrome_131::fingerprint(), true),
("chrome_125", chrome_125::fingerprint(), true),
("chrome_124", chrome_124::fingerprint(), true),
("chrome_116", chrome_116::fingerprint(), false),
("chrome_110", chrome_110::fingerprint(), false),
("chrome_107", chrome_107::fingerprint(), false),
("chrome_104", chrome_104::fingerprint(), false),
("chrome_101", chrome_101::fingerprint(), false),
("chrome_100", chrome_100::fingerprint(), false),
] {
let (_, _, exts) = client_hello(fp);
assert!(exts.iter().any(|(t, _)| *t == 0xfe0d), "{name}: no ECH");
assert_eq!(exts[0], (0xbaba, vec![]), "{name}: first extension");
assert_eq!(
*exts.last().unwrap(),
(0xaaaa, vec![0]),
"{name}: last extension"
exts.iter().filter(|(t, _)| is_grease(*t)).count(),
2,
"{name}: two GREASE extensions"
);
let last = exts
.iter()
.position(|(t, _)| *t == 0xaaaa)
.unwrap_or_else(|| panic!("{name}: no 0xaaaa"));
assert_eq!(exts[last].1, vec![0], "{name}: 0xaaaa body");
assert!(
exts[last + 1..].iter().all(|(t, _)| *t == 0x0015),
"{name}: only padding after 0xaaaa"
);
let ech = exts.iter().position(|(t, _)| *t == 0xfe0d);
assert_eq!(ech.is_some(), has_ech, "{name}: ECH");
if let Some(ech) = ech {
assert!(ech < last, "{name}: ECH before 0xaaaa");
}
}
}
}