mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-22 23:12:32 +00:00
af606d077f
SAE side-channel attacks Published: April 10, 2019 Identifiers: - VU#871675 - CVE-2019-9494 (cache attack against SAE) Latest version available from: https://w1.fi/security/2019-1/ Vulnerability Number of potential side channel attacks were discovered in the SAE implementations used by both hostapd (AP) and wpa_supplicant (infrastructure BSS station/mesh station). SAE (Simultaneous Authentication of Equals) is also known as WPA3-Personal. The discovered side channel attacks may be able to leak information about the used password based on observable timing differences and cache access patterns. This might result in full password recovery when combined with an offline dictionary attack and if the password is not strong enough to protect against dictionary attacks. Cache attack A novel cache-based attack against SAE handshake was discovered. This attack targets SAE with ECC groups. ECC group 19 being the mandatory group to support and the most likely used group for SAE today, so this attack applies to the most common SAE use case. Even though the PWE derivation iteration in SAE has protections against timing attacks, this new cache-based attack enables an attacker to determine which code branch is taken in the iteration if the attacker is able to run unprivileged code on the victim machine (e.g., an app installed on a smart phone or potentially a JavaScript code on a web site loaded by a web browser). This depends on the used CPU not providing sufficient protection to prevent unprivileged applications from observing memory access patterns through the shared cache (which is the most likely case with today's designs). The attacker can use information about the selected branch to learn information about the password and combine this information from number of handshake instances with an offline dictionary attack. With sufficient number of handshakes and sufficiently weak password, this might result in full discovery of the used password. This attack requires the attacker to be able to run a program on the target device. This is not commonly the case on access points, so the most likely target for this would be a client device using SAE in an infrastructure BSS or mesh BSS. The commits listed in the end of this advisory change the SAE implementation shared by hostapd and wpa_supplicant to perform the PWE derivation loop using operations that use constant time and memory access pattern to minimize the externally observable differences from operations that depend on the password even for the case where the attacker might be able to run unprivileged code on the same device. Timing attack The timing attack applies to the MODP groups 22, 23, and 24 where the PWE generation algorithm defined for SAE can have sufficient timing differences for an attacker to be able to determine how many rounds were needed to find the PWE based on the used password and MAC addresses. When the attack is repeated with multiple times, the attacker may be able to gather enough information about the password to be able to recover it fully using an offline dictionary attack if the password is not strong enough to protect against dictionary attacks. This attack could be performed by an attacker in radio range of an access point or a station enabling the specific MODP groups. This timing attack requires the applicable MODP groups to be enabled explicitly in hostapd/wpa_supplicant configuration (sae_groups parameter). All versions of hostapd/wpa_supplicant have disabled these groups by default. While this security advisory lists couple of commits introducing additional protection for MODP groups in SAE, it should be noted that the groups 22, 23, and 24 are not considered strong enough to meet the current expectation for a secure system. As such, their use is discouraged even if the additional protection mechanisms in the implementation are included. Vulnerable versions/configurations All wpa_supplicant and hostapd versions with SAE support (CONFIG_SAE=y in the build configuration and SAE being enabled in the runtime configuration). Acknowledgments Thanks to Mathy Vanhoef (New York University Abu Dhabi) and Eyal Ronen (Tel Aviv University) for discovering the issues and for discussions on how to address them. Possible mitigation steps - Merge the following commits to wpa_supplicant/hostapd and rebuild: OpenSSL: Use constant time operations for private bignums Add helper functions for constant time operations OpenSSL: Use constant time selection for crypto_bignum_legendre() SAE: Minimize timing differences in PWE derivation SAE: Avoid branches in is_quadratic_residue_blind() SAE: Mask timing of MODP groups 22, 23, 24 SAE: Use const_time selection for PWE in FFC SAE: Use constant time operations in sae_test_pwd_seed_ffc() These patches are available from https://w1.fi/security/2019-1/ - Update to wpa_supplicant/hostapd v2.8 or newer, once available - In addition to either of the above alternatives, disable MODP groups 1, 2, 5, 22, 23, and 24 by removing them from hostapd/wpa_supplicant sae_groups runtime configuration parameter, if they were explicitly enabled since those groups are not considered strong enough to meet current security expectations. The groups 22, 23, and 24 are related to the discovered side channel (timing) attack. The other groups in the list are consider too weak to provide sufficient security. Note that all these groups have been disabled by default in all hostapd/wpa_supplicant versions and these would be used only if explicitly enabled in the configuration. - Use strong passwords to prevent dictionary attacks Signed-off-by: Stefan Lippers-Hollmann <s.l-h@gmx.de> [bump PKG_RELEASE] Signed-off-by: Jo-Philipp Wich <jo@mein.io>
89 lines
3.3 KiB
Diff
89 lines
3.3 KiB
Diff
From d42c477cc794163a3757956bbffca5cea000923c Mon Sep 17 00:00:00 2001
|
|
From: Jouni Malinen <jouni@codeaurora.org>
|
|
Date: Tue, 26 Feb 2019 11:43:03 +0200
|
|
Subject: [PATCH 01/14] OpenSSL: Use constant time operations for private
|
|
bignums
|
|
|
|
This helps in reducing measurable timing differences in operations
|
|
involving private information. BoringSSL has removed BN_FLG_CONSTTIME
|
|
and expects specific constant time functions to be called instead, so a
|
|
bit different approach is needed depending on which library is used.
|
|
|
|
The main operation that needs protection against side channel attacks is
|
|
BN_mod_exp() that depends on private keys (the public key validation
|
|
step in crypto_dh_derive_secret() is an exception that can use the
|
|
faster version since it does not depend on private keys).
|
|
|
|
crypto_bignum_div() is currently used only in SAE FFC case with not
|
|
safe-prime groups and only with values that do not depend on private
|
|
keys, so it is not critical to protect it.
|
|
|
|
crypto_bignum_inverse() is currently used only in SAE FFC PWE
|
|
derivation. The additional protection here is targeting only OpenSSL.
|
|
BoringSSL may need conversion to using BN_mod_inverse_blinded().
|
|
|
|
This is related to CVE-2019-9494 and CVE-2019-9495.
|
|
|
|
Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
|
|
---
|
|
src/crypto/crypto_openssl.c | 20 +++++++++++++++-----
|
|
1 file changed, 15 insertions(+), 5 deletions(-)
|
|
|
|
--- a/src/crypto/crypto_openssl.c
|
|
+++ b/src/crypto/crypto_openssl.c
|
|
@@ -549,7 +549,8 @@ int crypto_mod_exp(const u8 *base, size_
|
|
bn_result == NULL)
|
|
goto error;
|
|
|
|
- if (BN_mod_exp(bn_result, bn_base, bn_exp, bn_modulus, ctx) != 1)
|
|
+ if (BN_mod_exp_mont_consttime(bn_result, bn_base, bn_exp, bn_modulus,
|
|
+ ctx, NULL) != 1)
|
|
goto error;
|
|
|
|
*result_len = BN_bn2bin(bn_result, result);
|
|
@@ -1295,8 +1296,9 @@ int crypto_bignum_exptmod(const struct c
|
|
bnctx = BN_CTX_new();
|
|
if (bnctx == NULL)
|
|
return -1;
|
|
- res = BN_mod_exp((BIGNUM *) d, (const BIGNUM *) a, (const BIGNUM *) b,
|
|
- (const BIGNUM *) c, bnctx);
|
|
+ res = BN_mod_exp_mont_consttime((BIGNUM *) d, (const BIGNUM *) a,
|
|
+ (const BIGNUM *) b, (const BIGNUM *) c,
|
|
+ bnctx, NULL);
|
|
BN_CTX_free(bnctx);
|
|
|
|
return res ? 0 : -1;
|
|
@@ -1315,6 +1317,11 @@ int crypto_bignum_inverse(const struct c
|
|
bnctx = BN_CTX_new();
|
|
if (bnctx == NULL)
|
|
return -1;
|
|
+#ifdef OPENSSL_IS_BORINGSSL
|
|
+ /* TODO: use BN_mod_inverse_blinded() ? */
|
|
+#else /* OPENSSL_IS_BORINGSSL */
|
|
+ BN_set_flags((BIGNUM *) a, BN_FLG_CONSTTIME);
|
|
+#endif /* OPENSSL_IS_BORINGSSL */
|
|
res = BN_mod_inverse((BIGNUM *) c, (const BIGNUM *) a,
|
|
(const BIGNUM *) b, bnctx);
|
|
BN_CTX_free(bnctx);
|
|
@@ -1348,6 +1355,9 @@ int crypto_bignum_div(const struct crypt
|
|
bnctx = BN_CTX_new();
|
|
if (bnctx == NULL)
|
|
return -1;
|
|
+#ifndef OPENSSL_IS_BORINGSSL
|
|
+ BN_set_flags((BIGNUM *) a, BN_FLG_CONSTTIME);
|
|
+#endif /* OPENSSL_IS_BORINGSSL */
|
|
res = BN_div((BIGNUM *) c, NULL, (const BIGNUM *) a,
|
|
(const BIGNUM *) b, bnctx);
|
|
BN_CTX_free(bnctx);
|
|
@@ -1439,8 +1449,8 @@ int crypto_bignum_legendre(const struct
|
|
/* exp = (p-1) / 2 */
|
|
!BN_sub(exp, (const BIGNUM *) p, BN_value_one()) ||
|
|
!BN_rshift1(exp, exp) ||
|
|
- !BN_mod_exp(tmp, (const BIGNUM *) a, exp, (const BIGNUM *) p,
|
|
- bnctx))
|
|
+ !BN_mod_exp_mont_consttime(tmp, (const BIGNUM *) a, exp,
|
|
+ (const BIGNUM *) p, bnctx, NULL))
|
|
goto fail;
|
|
|
|
if (BN_is_word(tmp, 1))
|