Skip to content

Commit a96bc5c

Browse files
committed
Merge branch 'bugfix/cve-2023-52160' into 'master'
fix(wpa_supplicant): (PEAP client) Update Phase 2 auth requirements See merge request sdk/ESP8266_RTOS_SDK!1692
2 parents c463401 + 898bf9e commit a96bc5c

File tree

3 files changed

+47
-5
lines changed

3 files changed

+47
-5
lines changed

Diff for: components/wpa_supplicant/src/eap_peer/eap_peap.c

+34-3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ struct eap_peap_data {
6666
u8 cmk[20];
6767
int soh; /* Whether IF-TNCCS-SOH (Statement of Health; Microsoft NAP)
6868
* is enabled. */
69+
enum { NO_AUTH, FOR_INITIAL, ALWAYS } phase2_auth;
6970
};
7071

7172

@@ -114,6 +115,19 @@ eap_peap_parse_phase1(struct eap_peap_data *data,
114115
wpa_printf(MSG_DEBUG, "EAP-PEAP: Require cryptobinding");
115116
}
116117

118+
if (os_strstr(phase1, "phase2_auth=0")) {
119+
data->phase2_auth = NO_AUTH;
120+
wpa_printf(MSG_DEBUG,
121+
"EAP-PEAP: Do not require Phase 2 authentication");
122+
} else if (os_strstr(phase1, "phase2_auth=1")) {
123+
data->phase2_auth = FOR_INITIAL;
124+
wpa_printf(MSG_DEBUG,
125+
"EAP-PEAP: Require Phase 2 authentication for initial connection");
126+
} else if (os_strstr(phase1, "phase2_auth=2")) {
127+
data->phase2_auth = ALWAYS;
128+
wpa_printf(MSG_DEBUG,
129+
"EAP-PEAP: Require Phase 2 authentication for all cases");
130+
}
117131
#ifdef EAP_TNC
118132
if (os_strstr(phase1, "tnc=soh2")) {
119133
data->soh = 2;
@@ -145,6 +159,7 @@ eap_peap_init(struct eap_sm *sm)
145159
data->force_peap_version = -1;
146160
data->peap_outer_success = 2;
147161
data->crypto_binding = OPTIONAL_BINDING;
162+
data->phase2_auth = FOR_INITIAL;
148163

149164
if (config && config->phase1 &&
150165
eap_peap_parse_phase1(data, config->phase1) < 0) {
@@ -449,6 +464,18 @@ eap_tlv_validate_cryptobinding(struct eap_sm *sm,
449464
return 0;
450465
}
451466

467+
static bool peap_phase2_sufficient(struct eap_sm *sm,
468+
struct eap_peap_data *data)
469+
{
470+
if ((data->phase2_auth == ALWAYS ||
471+
(data->phase2_auth == FOR_INITIAL &&
472+
!tls_connection_resumed(sm->ssl_ctx, data->ssl.conn) &&
473+
!data->ssl.client_cert_conf) ||
474+
data->phase2_eap_started) &&
475+
!data->phase2_eap_success)
476+
return false;
477+
return true;
478+
}
452479

453480
/**
454481
* eap_tlv_process - Process a received EAP-TLV message and generate a response
@@ -565,6 +592,11 @@ eap_tlv_process(struct eap_sm *sm, struct eap_peap_data *data,
565592
" - force failed Phase 2");
566593
resp_status = EAP_TLV_RESULT_FAILURE;
567594
ret->decision = DECISION_FAIL;
595+
} else if (!peap_phase2_sufficient(sm, data)) {
596+
wpa_printf(MSG_INFO,
597+
"EAP-PEAP: Server indicated Phase 2 success, but sufficient Phase 2 authentication has not been completed");
598+
resp_status = EAP_TLV_RESULT_FAILURE;
599+
ret->decision = DECISION_FAIL;
568600
} else {
569601
resp_status = EAP_TLV_RESULT_SUCCESS;
570602
ret->decision = DECISION_UNCOND_SUCC;
@@ -939,8 +971,7 @@ eap_peap_decrypt(struct eap_sm *sm, struct eap_peap_data *data,
939971
/* EAP-Success within TLS tunnel is used to indicate
940972
* shutdown of the TLS channel. The authentication has
941973
* been completed. */
942-
if (data->phase2_eap_started &&
943-
!data->phase2_eap_success) {
974+
if (!peap_phase2_sufficient(sm, data)) {
944975
wpa_printf(MSG_DEBUG, "EAP-PEAP: Phase 2 "
945976
"Success used to indicate success, "
946977
"but Phase 2 EAP was not yet "
@@ -1194,7 +1225,7 @@ eap_peap_has_reauth_data(struct eap_sm *sm, void *priv)
11941225
{
11951226
struct eap_peap_data *data = priv;
11961227
return tls_connection_established(sm->ssl_ctx, data->ssl.conn) &&
1197-
data->phase2_success;
1228+
data->phase2_success && data->phase2_auth != ALWAYS;
11981229
}
11991230

12001231

Diff for: components/wpa_supplicant/src/eap_peer/eap_tls_common.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static void eap_tls_params_from_conf1(struct tls_connection_params *params,
8484
static int eap_tls_params_from_conf(struct eap_sm *sm,
8585
struct eap_ssl_data *data,
8686
struct tls_connection_params *params,
87-
struct eap_peer_config *config)
87+
struct eap_peer_config *config, int phase2)
8888
{
8989
os_memset(params, 0, sizeof(*params));
9090
if (sm->workaround && data->eap_type != EAP_TYPE_FAST) {
@@ -119,6 +119,12 @@ static int eap_tls_params_from_conf(struct eap_sm *sm,
119119
return -1;
120120
}
121121

122+
if (!phase2)
123+
data->client_cert_conf = params->client_cert ||
124+
params->client_cert_blob ||
125+
params->private_key ||
126+
params->private_key_blob;
127+
122128
return 0;
123129
}
124130

@@ -196,7 +202,7 @@ int eap_peer_tls_ssl_init(struct eap_sm *sm, struct eap_ssl_data *data,
196202
data->eap = sm;
197203
data->eap_type = eap_type;
198204
data->ssl_ctx = sm->ssl_ctx;
199-
if (eap_tls_params_from_conf(sm, data, &params, config) < 0) /* no phase2 */
205+
if (eap_tls_params_from_conf(sm, data, &params, config, data->phase2) < 0) /* no phase2 */
200206
return -1;
201207

202208
if (eap_tls_init_connection(sm, data, config, &params) < 0)

Diff for: components/wpa_supplicant/src/eap_peer/eap_tls_common.h

+5
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ struct eap_ssl_data {
7373
* eap_type - EAP method used in Phase 1 (EAP_TYPE_TLS/PEAP/TTLS/FAST)
7474
*/
7575
u8 eap_type;
76+
77+
/**
78+
* client_cert_conf: Whether client certificate has been configured
79+
*/
80+
bool client_cert_conf;
7681
};
7782

7883

0 commit comments

Comments
 (0)