[pkg-wpa-devel] r1946 - in /wpa/trunk/debian: ./ patches/ patches/2015-01/ patches/2015-02/ patches/2015-03/ patches/2015-04/

slh-guest at users.alioth.debian.org slh-guest at users.alioth.debian.org
Thu May 7 23:04:36 UTC 2015


Author: slh-guest
Date: Thu May  7 23:04:33 2015
New Revision: 1946

URL: http://svn.debian.org/wsvn/pkg-wpa/?sc=1&rev=1946
Log:
* import upstream security fixes for wpa (no CVEs yet):
  - WPS UPnP vulnerability with HTTP chunked transfer encoding (2015-2)
    +  WPS: Fix HTTP chunked transfer encoding parser
  - Integer underflow in AP mode WMM Action frame processing (2015-3)
    + AP WMM: Fix integer underflow in WMM Action frame parser
  - EAP-pwd missing payload length validation (2015-4)
    + EAP-pwd peer: Fix payload length validation for Commit and Confirm
    + EAP-pwd server: Fix payload length validation for Commit and Confirm
    + EAP-pwd peer: Fix Total-Length parsing for fragment reassembly
    + EAP-pwd server: Fix Total-Length parsing for fragment reassembly
    + EAP-pwd peer: Fix asymmetric fragmentation behavior
* move previous patch for CVE-2015-1863 into a new subdirectory,
  debian/patches/2015-1/ and add the upstream advisory.

Added:
    wpa/trunk/debian/patches/2015-01/
    wpa/trunk/debian/patches/2015-01/0001-P2P-Validate-SSID-element-length-before-copying-it-C.patch
      - copied unchanged from r1945, wpa/trunk/debian/patches/wpasupplicant_P2P-Validate-SSID-element-length-before-copying-it-C.patch
    wpa/trunk/debian/patches/2015-01/wpa_supplicant-p2p-ssid-overflow.txt
    wpa/trunk/debian/patches/2015-02/
    wpa/trunk/debian/patches/2015-02/0001-WPS-Fix-HTTP-chunked-transfer-encoding-parser.patch
    wpa/trunk/debian/patches/2015-02/wps-upnp-http-chunked-transfer-encoding.txt
    wpa/trunk/debian/patches/2015-03/
    wpa/trunk/debian/patches/2015-03/0001-AP-WMM-Fix-integer-underflow-in-WMM-Action-frame-par.patch
    wpa/trunk/debian/patches/2015-03/integer-underflow-in-ap-mode-wmm-action-frame.txt
    wpa/trunk/debian/patches/2015-04/
    wpa/trunk/debian/patches/2015-04/0001-EAP-pwd-peer-Fix-payload-length-validation-for-Commi.patch
    wpa/trunk/debian/patches/2015-04/0002-EAP-pwd-server-Fix-payload-length-validation-for-Com.patch
    wpa/trunk/debian/patches/2015-04/0003-EAP-pwd-peer-Fix-Total-Length-parsing-for-fragment-r.patch
    wpa/trunk/debian/patches/2015-04/0004-EAP-pwd-server-Fix-Total-Length-parsing-for-fragment.patch
    wpa/trunk/debian/patches/2015-04/0005-EAP-pwd-peer-Fix-asymmetric-fragmentation-behavior.patch
    wpa/trunk/debian/patches/2015-04/eap-pwd-missing-payload-length-validation.txt
Removed:
    wpa/trunk/debian/patches/wpasupplicant_P2P-Validate-SSID-element-length-before-copying-it-C.patch
Modified:
    wpa/trunk/debian/changelog
    wpa/trunk/debian/patches/series

Modified: wpa/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-wpa/wpa/trunk/debian/changelog?rev=1946&op=diff
==============================================================================
--- wpa/trunk/debian/changelog	(original)
+++ wpa/trunk/debian/changelog	Thu May  7 23:04:33 2015
@@ -1,11 +1,23 @@
-wpa (2.3-3) UNRELEASED; urgency=medium
-
-  * NOT RELEASED YET
+wpa (2.3-3) unstable; urgency=medium
+
   * wpasupplicant: install systemd unit (Closes: #766746).
   * wpasupplicant: configure driver fallback for networkd.
   * import changelogs from the security queues.
-
- -- Stefan Lippers-Hollmann <s.l-h at gmx.de>  Thu, 23 Apr 2015 05:52:57 +0200
+  * import upstream security fixes for wpa (no CVEs yet):
+    - WPS UPnP vulnerability with HTTP chunked transfer encoding (2015-2)
+      +  WPS: Fix HTTP chunked transfer encoding parser
+    - Integer underflow in AP mode WMM Action frame processing (2015-3)
+      + AP WMM: Fix integer underflow in WMM Action frame parser
+    - EAP-pwd missing payload length validation (2015-4)
+      + EAP-pwd peer: Fix payload length validation for Commit and Confirm
+      + EAP-pwd server: Fix payload length validation for Commit and Confirm
+      + EAP-pwd peer: Fix Total-Length parsing for fragment reassembly
+      + EAP-pwd server: Fix Total-Length parsing for fragment reassembly
+      + EAP-pwd peer: Fix asymmetric fragmentation behavior
+  * move previous patch for CVE-2015-1863 into a new subdirectory,
+    debian/patches/2015-1/ and add the upstream advisory.
+
+ -- Stefan Lippers-Hollmann <s.l-h at gmx.de>  Fri, 08 May 2015 00:50:57 +0200
 
 wpa (2.3-2) unstable; urgency=high
 

Added: wpa/trunk/debian/patches/2015-01/wpa_supplicant-p2p-ssid-overflow.txt
URL: http://svn.debian.org/wsvn/pkg-wpa/wpa/trunk/debian/patches/2015-01/wpa_supplicant-p2p-ssid-overflow.txt?rev=1946&op=file
==============================================================================
--- wpa/trunk/debian/patches/2015-01/wpa_supplicant-p2p-ssid-overflow.txt	(added)
+++ wpa/trunk/debian/patches/2015-01/wpa_supplicant-p2p-ssid-overflow.txt	Thu May  7 23:04:33 2015
@@ -0,0 +1,68 @@
+wpa_supplicant P2P SSID processing vulnerability
+
+Published: April 22, 2015
+Identifier: CVE-2015-1863
+Latest version available from: http://w1.fi/security/2015-1/
+
+
+Vulnerability
+
+A vulnerability was found in how wpa_supplicant uses SSID information
+parsed from management frames that create or update P2P peer entries
+(e.g., Probe Response frame or number of P2P Public Action frames). SSID
+field has valid length range of 0-32 octets. However, it is transmitted
+in an element that has a 8-bit length field and potential maximum
+payload length of 255 octets. wpa_supplicant was not sufficiently
+verifying the payload length on one of the code paths using the SSID
+received from a peer device.
+
+This can result in copying arbitrary data from an attacker to a fixed
+length buffer of 32 bytes (i.e., a possible overflow of up to 223
+bytes). The SSID buffer is within struct p2p_device that is allocated
+from heap. The overflow can override couple of variables in the struct,
+including a pointer that gets freed. In addition about 150 bytes (the
+exact length depending on architecture) can be written beyond the end of
+the heap allocation.
+
+This could result in corrupted state in heap, unexpected program
+behavior due to corrupted P2P peer device information, denial of service
+due to wpa_supplicant process crash, exposure of memory contents during
+GO Negotiation, and potentially arbitrary code execution.
+
+Vulnerable versions/configurations
+
+wpa_supplicant v1.0-v2.4 with CONFIG_P2P build option enabled
+
+Attacker (or a system controlled by the attacker) needs to be within
+radio range of the vulnerable system to send a suitably constructed
+management frame that triggers a P2P peer device information to be
+created or updated.
+
+The vulnerability is easiest to exploit while the device has started an
+active P2P operation (e.g., has ongoing P2P_FIND or P2P_LISTEN control
+interface command in progress). However, it may be possible, though
+significantly more difficult, to trigger this even without any active
+P2P operation in progress.
+
+
+Acknowledgments
+
+Thanks to Google security team for reporting this issue and smart
+hardware research group of Alibaba security team for discovering it.
+
+
+Possible mitigation steps
+
+- Merge the following commits to wpa_supplicant and rebuild it:
+
+  P2P: Validate SSID element length before copying it (CVE-2015-1863)
+
+  This patch is available from http://w1.fi/security/2015-1/
+
+- Update to wpa_supplicant v2.5 or newer, once available
+
+- Disable P2P (control interface command "P2P_SET disabled 1" or
+  "p2p_disabled=1" in (each, if multiple interfaces used) wpa_supplicant
+  configuration file)
+
+- Disable P2P from the build (remove CONFIG_P2P=y)

Added: wpa/trunk/debian/patches/2015-02/0001-WPS-Fix-HTTP-chunked-transfer-encoding-parser.patch
URL: http://svn.debian.org/wsvn/pkg-wpa/wpa/trunk/debian/patches/2015-02/0001-WPS-Fix-HTTP-chunked-transfer-encoding-parser.patch?rev=1946&op=file
==============================================================================
--- wpa/trunk/debian/patches/2015-02/0001-WPS-Fix-HTTP-chunked-transfer-encoding-parser.patch	(added)
+++ wpa/trunk/debian/patches/2015-02/0001-WPS-Fix-HTTP-chunked-transfer-encoding-parser.patch	Thu May  7 23:04:33 2015
@@ -0,0 +1,44 @@
+From 5acd23f4581da58683f3cf5e36cb71bbe4070bd7 Mon Sep 17 00:00:00 2001
+From: Jouni Malinen <j at w1.fi>
+Date: Tue, 28 Apr 2015 17:08:33 +0300
+Subject: [PATCH] WPS: Fix HTTP chunked transfer encoding parser
+
+strtoul() return value may end up overflowing the int h->chunk_size and
+resulting in a negative value to be stored as the chunk_size. This could
+result in the following memcpy operation using a very large length
+argument which would result in a buffer overflow and segmentation fault.
+
+This could have been used to cause a denial service by any device that
+has been authorized for network access (either wireless or wired). This
+would affect both the WPS UPnP functionality in a WPS AP (hostapd with
+upnp_iface parameter set in the configuration) and WPS ER
+(wpa_supplicant with WPS_ER_START control interface command used).
+
+Validate the parsed chunk length value to avoid this. In addition to
+rejecting negative values, we can also reject chunk size that would be
+larger than the maximum configured body length.
+
+Thanks to Kostya Kortchinsky of Google security team for discovering and
+reporting this issue.
+
+Signed-off-by: Jouni Malinen <j at w1.fi>
+---
+ src/wps/httpread.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+--- a/src/wps/httpread.c
++++ b/src/wps/httpread.c
+@@ -533,6 +533,13 @@ static void httpread_read_handler(int sd
+ 					if (!isxdigit(*cbp))
+ 						goto bad;
+ 					h->chunk_size = strtoul(cbp, NULL, 16);
++					if (h->chunk_size < 0 ||
++					    h->chunk_size > h->max_bytes) {
++						wpa_printf(MSG_DEBUG,
++							   "httpread: Invalid chunk size %d",
++							   h->chunk_size);
++						goto bad;
++					}
+ 					/* throw away chunk header
+ 					 * so we have only real data
+ 					 */

Added: wpa/trunk/debian/patches/2015-02/wps-upnp-http-chunked-transfer-encoding.txt
URL: http://svn.debian.org/wsvn/pkg-wpa/wpa/trunk/debian/patches/2015-02/wps-upnp-http-chunked-transfer-encoding.txt?rev=1946&op=file
==============================================================================
--- wpa/trunk/debian/patches/2015-02/wps-upnp-http-chunked-transfer-encoding.txt	(added)
+++ wpa/trunk/debian/patches/2015-02/wps-upnp-http-chunked-transfer-encoding.txt	Thu May  7 23:04:33 2015
@@ -0,0 +1,73 @@
+WPS UPnP vulnerability with HTTP chunked transfer encoding
+
+Published: May 4, 2015
+Latest version available from: http://w1.fi/security/2015-2/
+
+
+Vulnerability
+
+A vulnerability was found in the WPS UPnP function shared by hostapd
+(WPS AP) and wpa_supplicant (WPS external registrar). The HTTP
+implementation used for the UPnP operations uses a signed integer for
+storing the length of a HTTP chunk when the chunked transfer encoding
+and may end up using a negative value when the chunk length is indicated
+as 0x8000000 or longer. The length validation steps do not handle the
+negative value properly and may end up accepting the length and passing
+a negative value to the memcpy when copying the received data from a
+stack buffer to a heap buffer allocated for the full request. This
+results in stack buffer read overflow and heap buffer write overflow.
+
+Taken into account both hostapd and wpa_supplicant use only a single
+thread, the memcpy call with a negative length value results in heap
+corruption, but due to the negative parameter being interpreted as a
+huge positive integer, process execution terminates in practice before
+being able to run any following operations with the corrupted heap. This
+may allow a possible denial of service attack through
+hostapd/wpa_supplicant process termination under certain conditions.
+
+WPS UPnP operations are performed over a trusted IP network connection,
+i.e., an attack against this vulnerability requires the attacker to have
+access to the IP network. In addition, this requires the WPS UPnP
+functionality to be enabled at runtime. For WPS AP (hostapd) with a
+wired network connectivity, this is commonly enabled. For WPS station
+(wpa_supplicant) WPS UPnP functionality is used only when WPS ER
+functionality has been enabled at runtime (WPS_ER_START command issued
+over the control interface). The vulnerable functionality is not
+reachable without that command having been issued.
+
+
+Vulnerable versions/configurations
+
+hostapd v0.7.0-v2.4 with CONFIG_WPS_UPNP=y in the build configuration
+(hostapd/.config) and upnp_iface parameter included in the runtime
+configuration.
+
+wpa_supplicant v0.7.0-v2.4 with CONFIG_WPS_ER=y in the build
+configuration (wpa_supplicant/.config) and WPS ER functionality enabled
+at runtime with WPS_ER_START control interface command.
+
+
+Acknowledgments
+
+Thanks to Kostya Kortchinsky of Google Security Team for discovering and
+reporting this issue.
+
+
+Possible mitigation steps
+
+- Merge the following commit and rebuild hostapd/wpa_supplicant:
+
+  WPS: Fix HTTP chunked transfer encoding parser
+
+  This patch is available from http://w1.fi/security/2015-2/
+
+- Update to hostapd/wpa_supplicant v2.5 or newer, once available
+
+- Disable WPS UPnP in hostapd runtime configuration (remove the
+  upnp_iface parameter from the configuration file)
+
+- Do not enable WPS ER at runtime in wpa_supplicant (WPS_ER_START
+  control interface command)
+
+- Disable WPS UPnP/ER from the build (remove CONFIG_WPS_UPNP=y from
+  hostapd/.config and CONFIG_WPS_ER=y from wpa_supplicant/.config)

Added: wpa/trunk/debian/patches/2015-03/0001-AP-WMM-Fix-integer-underflow-in-WMM-Action-frame-par.patch
URL: http://svn.debian.org/wsvn/pkg-wpa/wpa/trunk/debian/patches/2015-03/0001-AP-WMM-Fix-integer-underflow-in-WMM-Action-frame-par.patch?rev=1946&op=file
==============================================================================
--- wpa/trunk/debian/patches/2015-03/0001-AP-WMM-Fix-integer-underflow-in-WMM-Action-frame-par.patch	(added)
+++ wpa/trunk/debian/patches/2015-03/0001-AP-WMM-Fix-integer-underflow-in-WMM-Action-frame-par.patch	Thu May  7 23:04:33 2015
@@ -0,0 +1,36 @@
+From ef566a4d4f74022e1fdb0a2addfe81e6de9f4aae Mon Sep 17 00:00:00 2001
+From: Jouni Malinen <j at w1.fi>
+Date: Wed, 29 Apr 2015 02:21:53 +0300
+Subject: [PATCH] AP WMM: Fix integer underflow in WMM Action frame parser
+
+The length of the WMM Action frame was not properly validated and the
+length of the information elements (int left) could end up being
+negative. This would result in reading significantly past the stack
+buffer while parsing the IEs in ieee802_11_parse_elems() and while doing
+so, resulting in segmentation fault.
+
+This can result in an invalid frame being used for a denial of service
+attack (hostapd process killed) against an AP with a driver that uses
+hostapd for management frame processing (e.g., all mac80211-based
+drivers).
+
+Thanks to Kostya Kortchinsky of Google security team for discovering and
+reporting this issue.
+
+Signed-off-by: Jouni Malinen <j at w1.fi>
+---
+ src/ap/wmm.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/src/ap/wmm.c
++++ b/src/ap/wmm.c
+@@ -274,6 +274,9 @@ void hostapd_wmm_action(struct hostapd_d
+ 		return;
+ 	}
+ 
++	if (left < 0)
++		return; /* not a valid WMM Action frame */
++
+ 	/* extract the tspec info element */
+ 	if (ieee802_11_parse_elems(pos, left, &elems, 1) == ParseFailed) {
+ 		hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211,

Added: wpa/trunk/debian/patches/2015-03/integer-underflow-in-ap-mode-wmm-action-frame.txt
URL: http://svn.debian.org/wsvn/pkg-wpa/wpa/trunk/debian/patches/2015-03/integer-underflow-in-ap-mode-wmm-action-frame.txt?rev=1946&op=file
==============================================================================
--- wpa/trunk/debian/patches/2015-03/integer-underflow-in-ap-mode-wmm-action-frame.txt	(added)
+++ wpa/trunk/debian/patches/2015-03/integer-underflow-in-ap-mode-wmm-action-frame.txt	Thu May  7 23:04:33 2015
@@ -0,0 +1,58 @@
+Integer underflow in AP mode WMM Action frame processing
+
+Published: May 4, 2015
+Latest version available from: http://w1.fi/security/2015-3/
+
+
+Vulnerability
+
+A vulnerability was found in WMM Action frame processing in a case where
+hostapd or wpa_supplicant is used to implement AP mode MLME/SME
+functionality (i.e., Host AP driver of a mac80211-based driver on
+Linux).
+
+The AP mode WMM Action frame parser in hostapd/wpa_supplicant goes
+through the variable length information element part with the length of
+this area calculated by removing the header length from the total length
+of the frame. The frame length is previously verified to be large enough
+to include the IEEE 802.11 header, but the couple of additional bytes
+after this header are not explicitly verified and as a result of this,
+there may be an integer underflow that results in the signed integer
+variable storing the length becoming negative. This negative value is
+then interpreted as a very large unsigned integer length when parsing
+the information elements. This results in a buffer read overflow and
+process termination.
+
+This vulnerability can be used to perform denial of service attacks by
+an attacker that is within radio range of the AP that uses hostapd of
+wpa_supplicant for MLME/SME operations.
+
+
+Vulnerable versions/configurations
+
+hostapd v0.5.5-v2.4 with CONFIG_DRIVER_HOSTAP=y or
+CONFIG_DRIVER_NL80211=y in the build configuration (hostapd/.config).
+
+wpa_supplicant v0.7.0-v2.4 with CONFIG_AP=y or CONFIG_P2P=y and
+CONFIG_DRIVER_HOSTAP=y or CONFIG_DRIVER_NL80211=y in the build
+configuration (wpa_supplicant/.config) and AP (including P2P GO) mode
+used at runtime.
+
+
+Acknowledgments
+
+Thanks to Kostya Kortchinsky of Google Security Team for discovering and
+reporting this issue.
+
+
+Possible mitigation steps
+
+- Merge the following commit and rebuild hostapd/wpa_supplicant:
+
+  AP WMM: Fix integer underflow in WMM Action frame parser
+
+  This patch is available from http://w1.fi/security/2015-3/
+
+- Update to hostapd/wpa_supplicant v2.5 or newer, once available
+
+- wpa_supplicant: Do not enable AP mode or P2P GO operation at runtime

Added: wpa/trunk/debian/patches/2015-04/0001-EAP-pwd-peer-Fix-payload-length-validation-for-Commi.patch
URL: http://svn.debian.org/wsvn/pkg-wpa/wpa/trunk/debian/patches/2015-04/0001-EAP-pwd-peer-Fix-payload-length-validation-for-Commi.patch?rev=1946&op=file
==============================================================================
--- wpa/trunk/debian/patches/2015-04/0001-EAP-pwd-peer-Fix-payload-length-validation-for-Commi.patch	(added)
+++ wpa/trunk/debian/patches/2015-04/0001-EAP-pwd-peer-Fix-payload-length-validation-for-Commi.patch	Thu May  7 23:04:33 2015
@@ -0,0 +1,68 @@
+From dd2f043c9c43d156494e33d7ce22db96e6ef42c7 Mon Sep 17 00:00:00 2001
+From: Jouni Malinen <j at w1.fi>
+Date: Fri, 1 May 2015 16:37:45 +0300
+Subject: [PATCH 1/5] EAP-pwd peer: Fix payload length validation for Commit
+ and Confirm
+
+The length of the received Commit and Confirm message payloads was not
+checked before reading them. This could result in a buffer read
+overflow when processing an invalid message.
+
+Fix this by verifying that the payload is of expected length before
+processing it. In addition, enforce correct state transition sequence to
+make sure there is no unexpected behavior if receiving a Commit/Confirm
+message before the previous exchanges have been completed.
+
+Thanks to Kostya Kortchinsky of Google security team for discovering and
+reporting this issue.
+
+Signed-off-by: Jouni Malinen <j at w1.fi>
+---
+ src/eap_peer/eap_pwd.c | 29 +++++++++++++++++++++++++++++
+ 1 file changed, 29 insertions(+)
+
+--- a/src/eap_peer/eap_pwd.c
++++ b/src/eap_peer/eap_pwd.c
+@@ -301,6 +301,23 @@ eap_pwd_perform_commit_exchange(struct e
+ 	BIGNUM *mask = NULL, *x = NULL, *y = NULL, *cofactor = NULL;
+ 	u16 offset;
+ 	u8 *ptr, *scalar = NULL, *element = NULL;
++	size_t prime_len, order_len;
++
++	if (data->state != PWD_Commit_Req) {
++		ret->ignore = TRUE;
++		goto fin;
++	}
++
++	prime_len = BN_num_bytes(data->grp->prime);
++	order_len = BN_num_bytes(data->grp->order);
++
++	if (payload_len != 2 * prime_len + order_len) {
++		wpa_printf(MSG_INFO,
++			   "EAP-pwd: Unexpected Commit payload length %u (expected %u)",
++			   (unsigned int) payload_len,
++			   (unsigned int) (2 * prime_len + order_len));
++		goto fin;
++	}
+ 
+ 	if (((data->private_value = BN_new()) == NULL) ||
+ 	    ((data->my_element = EC_POINT_new(data->grp->group)) == NULL) ||
+@@ -500,6 +517,18 @@ eap_pwd_perform_confirm_exchange(struct
+ 	u8 conf[SHA256_MAC_LEN], *cruft = NULL, *ptr;
+ 	int offset;
+ 
++	if (data->state != PWD_Confirm_Req) {
++		ret->ignore = TRUE;
++		goto fin;
++	}
++
++	if (payload_len != SHA256_MAC_LEN) {
++		wpa_printf(MSG_INFO,
++			   "EAP-pwd: Unexpected Confirm payload length %u (expected %u)",
++			   (unsigned int) payload_len, SHA256_MAC_LEN);
++		goto fin;
++	}
++
+ 	/*
+ 	 * first build up the ciphersuite which is group | random_function |
+ 	 *	prf

Added: wpa/trunk/debian/patches/2015-04/0002-EAP-pwd-server-Fix-payload-length-validation-for-Com.patch
URL: http://svn.debian.org/wsvn/pkg-wpa/wpa/trunk/debian/patches/2015-04/0002-EAP-pwd-server-Fix-payload-length-validation-for-Com.patch?rev=1946&op=file
==============================================================================
--- wpa/trunk/debian/patches/2015-04/0002-EAP-pwd-server-Fix-payload-length-validation-for-Com.patch	(added)
+++ wpa/trunk/debian/patches/2015-04/0002-EAP-pwd-server-Fix-payload-length-validation-for-Com.patch	Thu May  7 23:04:33 2015
@@ -0,0 +1,61 @@
+From e28a58be26184c2a23f80b410e0997ef1bd5d578 Mon Sep 17 00:00:00 2001
+From: Jouni Malinen <j at w1.fi>
+Date: Fri, 1 May 2015 16:40:44 +0300
+Subject: [PATCH 2/5] EAP-pwd server: Fix payload length validation for Commit
+ and Confirm
+
+The length of the received Commit and Confirm message payloads was not
+checked before reading them. This could result in a buffer read
+overflow when processing an invalid message.
+
+Fix this by verifying that the payload is of expected length before
+processing it. In addition, enforce correct state transition sequence to
+make sure there is no unexpected behavior if receiving a Commit/Confirm
+message before the previous exchanges have been completed.
+
+Thanks to Kostya Kortchinsky of Google security team for discovering and
+reporting this issue.
+
+Signed-off-by: Jouni Malinen <j at w1.fi>
+---
+ src/eap_server/eap_server_pwd.c | 19 +++++++++++++++++++
+ 1 file changed, 19 insertions(+)
+
+--- a/src/eap_server/eap_server_pwd.c
++++ b/src/eap_server/eap_server_pwd.c
+@@ -634,9 +634,21 @@ eap_pwd_process_commit_resp(struct eap_s
+ 	BIGNUM *x = NULL, *y = NULL, *cofactor = NULL;
+ 	EC_POINT *K = NULL, *point = NULL;
+ 	int res = 0;
++	size_t prime_len, order_len;
+ 
+ 	wpa_printf(MSG_DEBUG, "EAP-pwd: Received commit response");
+ 
++	prime_len = BN_num_bytes(data->grp->prime);
++	order_len = BN_num_bytes(data->grp->order);
++
++	if (payload_len != 2 * prime_len + order_len) {
++		wpa_printf(MSG_INFO,
++			   "EAP-pwd: Unexpected Commit payload length %u (expected %u)",
++			   (unsigned int) payload_len,
++			   (unsigned int) (2 * prime_len + order_len));
++		goto fin;
++	}
++
+ 	if (((data->peer_scalar = BN_new()) == NULL) ||
+ 	    ((data->k = BN_new()) == NULL) ||
+ 	    ((cofactor = BN_new()) == NULL) ||
+@@ -752,6 +764,13 @@ eap_pwd_process_confirm_resp(struct eap_
+ 	u8 conf[SHA256_MAC_LEN], *cruft = NULL, *ptr;
+ 	int offset;
+ 
++	if (payload_len != SHA256_MAC_LEN) {
++		wpa_printf(MSG_INFO,
++			   "EAP-pwd: Unexpected Confirm payload length %u (expected %u)",
++			   (unsigned int) payload_len, SHA256_MAC_LEN);
++		goto fin;
++	}
++
+ 	/* build up the ciphersuite: group | random_function | prf */
+ 	grp = htons(data->group_num);
+ 	ptr = (u8 *) &cs;

Added: wpa/trunk/debian/patches/2015-04/0003-EAP-pwd-peer-Fix-Total-Length-parsing-for-fragment-r.patch
URL: http://svn.debian.org/wsvn/pkg-wpa/wpa/trunk/debian/patches/2015-04/0003-EAP-pwd-peer-Fix-Total-Length-parsing-for-fragment-r.patch?rev=1946&op=file
==============================================================================
--- wpa/trunk/debian/patches/2015-04/0003-EAP-pwd-peer-Fix-Total-Length-parsing-for-fragment-r.patch	(added)
+++ wpa/trunk/debian/patches/2015-04/0003-EAP-pwd-peer-Fix-Total-Length-parsing-for-fragment-r.patch	Thu May  7 23:04:33 2015
@@ -0,0 +1,47 @@
+From 477c74395acd0123340457ba6f15ab345d42016e Mon Sep 17 00:00:00 2001
+From: Jouni Malinen <j at w1.fi>
+Date: Sat, 2 May 2015 19:23:04 +0300
+Subject: [PATCH 3/5] EAP-pwd peer: Fix Total-Length parsing for fragment
+ reassembly
+
+The remaining number of bytes in the message could be smaller than the
+Total-Length field size, so the length needs to be explicitly checked
+prior to reading the field and decrementing the len variable. This could
+have resulted in the remaining length becoming negative and interpreted
+as a huge positive integer.
+
+In addition, check that there is no already started fragment in progress
+before allocating a new buffer for reassembling fragments. This avoid a
+potential memory leak when processing invalid message.
+
+Signed-off-by: Jouni Malinen <j at w1.fi>
+---
+ src/eap_peer/eap_pwd.c | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+--- a/src/eap_peer/eap_pwd.c
++++ b/src/eap_peer/eap_pwd.c
+@@ -812,11 +812,23 @@ eap_pwd_process(struct eap_sm *sm, void
+ 	 * if it's the first fragment there'll be a length field
+ 	 */
+ 	if (EAP_PWD_GET_LENGTH_BIT(lm_exch)) {
++		if (len < 2) {
++			wpa_printf(MSG_DEBUG,
++				   "EAP-pwd: Frame too short to contain Total-Length field");
++			ret->ignore = TRUE;
++			return NULL;
++		}
+ 		tot_len = WPA_GET_BE16(pos);
+ 		wpa_printf(MSG_DEBUG, "EAP-pwd: Incoming fragments whose "
+ 			   "total length = %d", tot_len);
+ 		if (tot_len > 15000)
+ 			return NULL;
++		if (data->inbuf) {
++			wpa_printf(MSG_DEBUG,
++				   "EAP-pwd: Unexpected new fragment start when previous fragment is still in use");
++			ret->ignore = TRUE;
++			return NULL;
++		}
+ 		data->inbuf = wpabuf_alloc(tot_len);
+ 		if (data->inbuf == NULL) {
+ 			wpa_printf(MSG_INFO, "Out of memory to buffer "

Added: wpa/trunk/debian/patches/2015-04/0004-EAP-pwd-server-Fix-Total-Length-parsing-for-fragment.patch
URL: http://svn.debian.org/wsvn/pkg-wpa/wpa/trunk/debian/patches/2015-04/0004-EAP-pwd-server-Fix-Total-Length-parsing-for-fragment.patch?rev=1946&op=file
==============================================================================
--- wpa/trunk/debian/patches/2015-04/0004-EAP-pwd-server-Fix-Total-Length-parsing-for-fragment.patch	(added)
+++ wpa/trunk/debian/patches/2015-04/0004-EAP-pwd-server-Fix-Total-Length-parsing-for-fragment.patch	Thu May  7 23:04:33 2015
@@ -0,0 +1,45 @@
+From 3035cc2894e08319b905bd6561e8bddc8c2db9fa Mon Sep 17 00:00:00 2001
+From: Jouni Malinen <j at w1.fi>
+Date: Sat, 2 May 2015 19:26:06 +0300
+Subject: [PATCH 4/5] EAP-pwd server: Fix Total-Length parsing for fragment
+ reassembly
+
+The remaining number of bytes in the message could be smaller than the
+Total-Length field size, so the length needs to be explicitly checked
+prior to reading the field and decrementing the len variable. This could
+have resulted in the remaining length becoming negative and interpreted
+as a huge positive integer.
+
+In addition, check that there is no already started fragment in progress
+before allocating a new buffer for reassembling fragments. This avoid a
+potential memory leak when processing invalid message.
+
+Signed-off-by: Jouni Malinen <j at w1.fi>
+---
+ src/eap_server/eap_server_pwd.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+--- a/src/eap_server/eap_server_pwd.c
++++ b/src/eap_server/eap_server_pwd.c
+@@ -920,11 +920,21 @@ static void eap_pwd_process(struct eap_s
+ 	 * the first fragment has a total length
+ 	 */
+ 	if (EAP_PWD_GET_LENGTH_BIT(lm_exch)) {
++		if (len < 2) {
++			wpa_printf(MSG_DEBUG,
++				   "EAP-pwd: Frame too short to contain Total-Length field");
++			return;
++		}
+ 		tot_len = WPA_GET_BE16(pos);
+ 		wpa_printf(MSG_DEBUG, "EAP-pwd: Incoming fragments, total "
+ 			   "length = %d", tot_len);
+ 		if (tot_len > 15000)
+ 			return;
++		if (data->inbuf) {
++			wpa_printf(MSG_DEBUG,
++				   "EAP-pwd: Unexpected new fragment start when previous fragment is still in use");
++			return;
++		}
+ 		data->inbuf = wpabuf_alloc(tot_len);
+ 		if (data->inbuf == NULL) {
+ 			wpa_printf(MSG_INFO, "EAP-pwd: Out of memory to "

Added: wpa/trunk/debian/patches/2015-04/0005-EAP-pwd-peer-Fix-asymmetric-fragmentation-behavior.patch
URL: http://svn.debian.org/wsvn/pkg-wpa/wpa/trunk/debian/patches/2015-04/0005-EAP-pwd-peer-Fix-asymmetric-fragmentation-behavior.patch?rev=1946&op=file
==============================================================================
--- wpa/trunk/debian/patches/2015-04/0005-EAP-pwd-peer-Fix-asymmetric-fragmentation-behavior.patch	(added)
+++ wpa/trunk/debian/patches/2015-04/0005-EAP-pwd-peer-Fix-asymmetric-fragmentation-behavior.patch	Thu May  7 23:04:33 2015
@@ -0,0 +1,27 @@
+From 28a069a545b06b99eb55ad53f63f2c99e65a98f6 Mon Sep 17 00:00:00 2001
+From: Jouni Malinen <j at w1.fi>
+Date: Sat, 2 May 2015 19:26:28 +0300
+Subject: [PATCH 5/5] EAP-pwd peer: Fix asymmetric fragmentation behavior
+
+The L (Length) and M (More) flags needs to be cleared before deciding
+whether the locally generated response requires fragmentation. This
+fixes an issue where these flags from the server could have been invalid
+for the following message. In some cases, this could have resulted in
+triggering the wpabuf security check that would terminate the process
+due to invalid buffer allocation.
+
+Signed-off-by: Jouni Malinen <j at w1.fi>
+---
+ src/eap_peer/eap_pwd.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/src/eap_peer/eap_pwd.c
++++ b/src/eap_peer/eap_pwd.c
+@@ -914,6 +914,7 @@ eap_pwd_process(struct eap_sm *sm, void
+ 	/*
+ 	 * we have output! Do we need to fragment it?
+ 	 */
++	lm_exch = EAP_PWD_GET_EXCHANGE(lm_exch);
+ 	len = wpabuf_len(data->outbuf);
+ 	if ((len + EAP_PWD_HDR_SIZE) > data->mtu) {
+ 		resp = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_PWD, data->mtu,

Added: wpa/trunk/debian/patches/2015-04/eap-pwd-missing-payload-length-validation.txt
URL: http://svn.debian.org/wsvn/pkg-wpa/wpa/trunk/debian/patches/2015-04/eap-pwd-missing-payload-length-validation.txt?rev=1946&op=file
==============================================================================
--- wpa/trunk/debian/patches/2015-04/eap-pwd-missing-payload-length-validation.txt	(added)
+++ wpa/trunk/debian/patches/2015-04/eap-pwd-missing-payload-length-validation.txt	Thu May  7 23:04:33 2015
@@ -0,0 +1,64 @@
+EAP-pwd missing payload length validation
+
+Published: May 4, 2015
+Latest version available from: http://w1.fi/security/2015-4/
+
+
+Vulnerability
+
+A vulnerability was found in EAP-pwd server and peer implementation used
+in hostapd and wpa_supplicant, respectively. The EAP-pwd/Commit and
+EAP-pwd/Confirm message payload is processed without verifying that the
+received frame is long enough to include all the fields. This results in
+buffer read overflow of up to couple of hundred bytes.
+
+The exact result of this buffer overflow depends on the platform and may
+be either not noticeable (i.e., authentication fails due to invalid data
+without any additional side effects) or process termination due to the
+buffer read overflow being detected and stopped. The latter case could
+potentially result in denial of service when EAP-pwd authentication is
+used.
+
+Further research into this issue found that the fragment reassembly
+processing is also missing a check for the Total-Length field and this
+could result in the payload length becoming negative. This itself would
+not add more to the vulnerability due to the payload length not being
+verified anyway. However, it is possible that a related reassembly step
+would result in hitting an internal security check on buffer use and
+result in the processing being terminated.
+
+
+Vulnerable versions/configurations
+
+hostapd v1.0-v2.4 with CONFIG_EAP_PWD=y in the build configuration
+(hostapd/.config) and EAP-pwd authentication server enabled in runtime
+configuration.
+
+wpa_supplicant v1.0-v2.4 with CONFIG_EAP_PWD=y in the build
+configuration (wpa_supplicant/.config) and EAP-pwd enabled in a network
+profile at runtime.
+
+
+Acknowledgments
+
+Thanks to Kostya Kortchinsky of Google Security Team for discovering and
+reporting this issue.
+
+
+Possible mitigation steps
+
+- Merge the following commits and rebuild hostapd/wpa_supplicant:
+
+  EAP-pwd peer: Fix payload length validation for Commit and Confirm
+  EAP-pwd server: Fix payload length validation for Commit and Confirm
+  EAP-pwd peer: Fix Total-Length parsing for fragment reassembly
+  EAP-pwd server: Fix Total-Length parsing for fragment reassembly
+  EAP-pwd peer: Fix asymmetric fragmentation behavior
+
+  These patches are available from http://w1.fi/security/2015-4/
+
+- Update to hostapd/wpa_supplicant v2.5 or newer, once available
+
+- Remove CONFIG_EAP_PWD=y from build configuration
+
+- Disable EAP-pwd in runtime configuration

Modified: wpa/trunk/debian/patches/series
URL: http://svn.debian.org/wsvn/pkg-wpa/wpa/trunk/debian/patches/series?rev=1946&op=diff
==============================================================================
--- wpa/trunk/debian/patches/series	(original)
+++ wpa/trunk/debian/patches/series	Thu May  7 23:04:33 2015
@@ -9,4 +9,11 @@
 hostapd_fix-hostapd-operation-without-hw_mode-driver-data.patch
 networkd-driver-fallback.patch
 wpasupplicant_fix-systemd-unit-dependencies.patch
-wpasupplicant_P2P-Validate-SSID-element-length-before-copying-it-C.patch
+2015-01/0001-P2P-Validate-SSID-element-length-before-copying-it-C.patch
+2015-02/0001-WPS-Fix-HTTP-chunked-transfer-encoding-parser.patch
+2015-03/0001-AP-WMM-Fix-integer-underflow-in-WMM-Action-frame-par.patch
+2015-04/0001-EAP-pwd-peer-Fix-payload-length-validation-for-Commi.patch
+2015-04/0002-EAP-pwd-server-Fix-payload-length-validation-for-Com.patch
+2015-04/0003-EAP-pwd-peer-Fix-Total-Length-parsing-for-fragment-r.patch
+2015-04/0004-EAP-pwd-server-Fix-Total-Length-parsing-for-fragment.patch
+2015-04/0005-EAP-pwd-peer-Fix-asymmetric-fragmentation-behavior.patch




More information about the Pkg-wpa-devel mailing list