Skip to content

Commit 355b291

Browse files
CVE-2020-12638 workaround for WPA downgrade attack (#7486)
* CVE-2020-12638 workaround for WPA downgrade attack When connected to an encrypted (WEP/WPA) router, a rogue packet can cause the ESP8266 WiFi stack to drop to an unecrypted rogue network of the same SSID. Handle this by dropping the WiFi connection immediately and reconnecting to the stored WPA/WEP network requested by the application, whenever the AUTHMODE changes to OPEN from a secured mode. https://lbsfilm.at/blog/wpa2-authenticationmode-downgrade-in-espressif-microprocessors for more details.
1 parent e815b92 commit 355b291

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,16 @@ void ESP8266WiFiGenericClass::_eventCallback(void* arg)
228228
WiFiClient::stopAll();
229229
}
230230

231+
if (event->event == EVENT_STAMODE_AUTHMODE_CHANGE) {
232+
auto& src = event->event_info.auth_change;
233+
if ((src.old_mode != AUTH_OPEN) && (src.new_mode == AUTH_OPEN)) {
234+
// CVE-2020-12638 workaround. When we get a change to AUTH_OPEN from any other mode, drop the WiFi link because it's a downgrade attack
235+
// TODO - When upgrading to 3.x.x with fix, remove this code
236+
DEBUG_WIFI("WIFI_EVENT_STAMODE_AUTHMODE_CHANGE from encrypted(%d) to AUTH_OPEN, potential downgrade attack. Reconnecting WiFi. See CVE-2020-12638 for more details\n", src.old_mode);
237+
WiFi.reconnect(); // Disconnects from STA and then reconnects
238+
}
239+
}
240+
231241
for(auto it = std::begin(sCbEventList); it != std::end(sCbEventList); ) {
232242
WiFiEventHandler &handler = *it;
233243
if (handler->canExpire() && handler.unique()) {

0 commit comments

Comments
 (0)