1 From ecbb0b3dc122b0d290987cf9c84010bbe53e1022 Mon Sep 17 00:00:00 2001
2 From: Jouni Malinen <jouni@qca.qualcomm.com>
3 Date: Fri, 4 Mar 2016 17:20:18 +0200
4 Subject: [PATCH 1/2] WPS: Reject a Credential with invalid passphrase
6 WPA/WPA2-Personal passphrase is not allowed to include control
7 characters. Reject a Credential received from a WPS Registrar both as
8 STA (Credential) and AP (AP Settings) if the credential is for WPAPSK or
9 WPA2PSK authentication type and includes an invalid passphrase.
11 This fixes an issue where hostapd or wpa_supplicant could have updated
12 the configuration file PSK/passphrase parameter with arbitrary data from
13 an external device (Registrar) that may not be fully trusted. Should
14 such data include a newline character, the resulting configuration file
15 could become invalid and fail to be parsed.
17 Upstream-Status: Backport
21 Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
22 Signed-off-by: Zhixiong Chi <Zhixiong.Chi@windriver.com>
24 src/utils/common.c | 12 ++++++++++++
25 src/utils/common.h | 1 +
26 src/wps/wps_attr_process.c | 10 ++++++++++
27 3 files changed, 23 insertions(+)
29 diff --git a/src/utils/common.c b/src/utils/common.c
30 index 450e2c6..27b7c02 100644
31 --- a/src/utils/common.c
32 +++ b/src/utils/common.c
33 @@ -697,6 +697,18 @@ int is_hex(const u8 *data, size_t len)
37 +int has_ctrl_char(const u8 *data, size_t len)
41 + for (i = 0; i < len; i++) {
42 + if (data[i] < 32 || data[i] == 127)
49 size_t merge_byte_arrays(u8 *res, size_t res_len,
50 const u8 *src1, size_t src1_len,
51 const u8 *src2, size_t src2_len)
52 diff --git a/src/utils/common.h b/src/utils/common.h
53 index 701dbb2..a972240 100644
54 --- a/src/utils/common.h
55 +++ b/src/utils/common.h
56 @@ -488,6 +488,7 @@ const char * wpa_ssid_txt(const u8 *ssid, size_t ssid_len);
58 char * wpa_config_parse_string(const char *value, size_t *len);
59 int is_hex(const u8 *data, size_t len);
60 +int has_ctrl_char(const u8 *data, size_t len);
61 size_t merge_byte_arrays(u8 *res, size_t res_len,
62 const u8 *src1, size_t src1_len,
63 const u8 *src2, size_t src2_len);
64 diff --git a/src/wps/wps_attr_process.c b/src/wps/wps_attr_process.c
65 index eadb22f..e8c4579 100644
66 --- a/src/wps/wps_attr_process.c
67 +++ b/src/wps/wps_attr_process.c
68 @@ -229,6 +229,16 @@ static int wps_workaround_cred_key(struct wps_credential *cred)
70 #endif /* CONFIG_WPS_STRICT */
74 + if (cred->auth_type & (WPS_AUTH_WPAPSK | WPS_AUTH_WPA2PSK) &&
75 + (cred->key_len < 8 || has_ctrl_char(cred->key, cred->key_len))) {
76 + wpa_printf(MSG_INFO, "WPS: Reject credential with invalid WPA/WPA2-Personal passphrase");
77 + wpa_hexdump_ascii_key(MSG_INFO, "WPS: Network Key",
78 + cred->key, cred->key_len);