Skip to content

Commit 72a28a2

Browse files
fix(negotiation): exclude SHA-1 MACs from Preferred::DEFAULT
HMAC_SHA1 and HMAC_SHA1_ETM were included in the default MAC negotiation list (HMAC_ORDER). SHA-1 based MACs are deprecated per RFC 8308 and removed from OpenSSH 8.7+ defaults. Introduce SAFE_HMAC_ORDER (SHA-512 and SHA-256 variants only) and use it in Preferred::DEFAULT and Preferred::COMPRESSED. HMAC_ORDER is kept as-is for users who need to interoperate with legacy servers that support only SHA-1 MACs — set it explicitly via Preferred { mac: Cow::Borrowed(HMAC_ORDER) }. The KEX default (SAFE_KEX_ORDER) already excludes SHA-1 correctly; this aligns MAC defaults to the same standard.
1 parent a9057ed commit 72a28a2

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

russh/src/negotiation.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,14 @@ const CIPHER_ORDER: &[cipher::Name] = &[
131131
cipher::AES_128_CTR,
132132
];
133133

134+
// SHA-1 MAC variants excluded; see HMAC_ORDER for the full list including legacy algorithms.
135+
const SAFE_HMAC_ORDER: &[mac::Name] = &[
136+
mac::HMAC_SHA512_ETM,
137+
mac::HMAC_SHA256_ETM,
138+
mac::HMAC_SHA512,
139+
mac::HMAC_SHA256,
140+
];
141+
134142
const HMAC_ORDER: &[mac::Name] = &[
135143
mac::HMAC_SHA512_ETM,
136144
mac::HMAC_SHA256_ETM,
@@ -171,15 +179,15 @@ impl Preferred {
171179
Algorithm::Rsa { hash: None },
172180
]),
173181
cipher: Cow::Borrowed(CIPHER_ORDER),
174-
mac: Cow::Borrowed(HMAC_ORDER),
182+
mac: Cow::Borrowed(SAFE_HMAC_ORDER),
175183
compression: Cow::Borrowed(COMPRESSION_ORDER),
176184
};
177185

178186
pub const COMPRESSED: Preferred = Preferred {
179187
kex: Cow::Borrowed(SAFE_KEX_ORDER),
180188
key: Preferred::DEFAULT.key,
181189
cipher: Cow::Borrowed(CIPHER_ORDER),
182-
mac: Cow::Borrowed(HMAC_ORDER),
190+
mac: Cow::Borrowed(SAFE_HMAC_ORDER),
183191
compression: Cow::Borrowed(COMPRESSION_ORDER),
184192
};
185193
}

0 commit comments

Comments
 (0)