tags 787371 patch
Hi,
I attached a patch to fix these (and more) security issues for jessie.
For unstable I uploaded an updated package to [1], that fixes the
security issues and updates the package to upstream version 2.5.
Since I am no Debian Developer, I will not be able to upload these
updates to the archive.
Cheers,
Julian
[1] http://rbw.goe.net/jw/debian
diff -Nru wpa-2.3/debian/changelog wpa-2.3/debian/changelog
--- wpa-2.3/debian/changelog 2015-04-23 19:33:58.000000000 +0200
+++ wpa-2.3/debian/changelog 2015-10-24 16:56:08.000000000 +0200
@@ -1,3 +1,11 @@
+wpa (2.3-1+deb8u2) jessie-security; urgency=high
+
+ * Add fixes for http://w1.fi/security/2015-5/
+ * Add fixes for CVE-2015-4141, CVE-2015-4142, CVE-2015-4143, CVE-2015-4144,
+ CVE-2015-4145, CVE-2015-4146 (Closes: #787371).
+
+ -- Julian Wollrath <jwollr...@web.de> Sat, 24 Oct 2015 16:27:19 +0200
+
wpa (2.3-1+deb8u1) jessie-security; urgency=high
* import "P2P: Validate SSID element length before copying it
diff -Nru wpa-2.3/debian/patches/2015-01/0001-P2P-Validate-SSID-element-length-before-copying-it-C.patch wpa-2.3/debian/patches/2015-01/0001-P2P-Validate-SSID-element-length-before-copying-it-C.patch
--- wpa-2.3/debian/patches/2015-01/0001-P2P-Validate-SSID-element-length-before-copying-it-C.patch 1970-01-01 01:00:00.000000000 +0100
+++ wpa-2.3/debian/patches/2015-01/0001-P2P-Validate-SSID-element-length-before-copying-it-C.patch 2015-10-24 16:24:26.000000000 +0200
@@ -0,0 +1,37 @@
+From 9ed4eee345f85e3025c33c6e20aa25696e341ccd Mon Sep 17 00:00:00 2001
+From: Jouni Malinen <jo...@qca.qualcomm.com>
+Date: Tue, 7 Apr 2015 11:32:11 +0300
+Subject: [PATCH] P2P: Validate SSID element length before copying it
+ (CVE-2015-1863)
+
+This fixes a possible memcpy overflow for P2P dev->oper_ssid in
+p2p_add_device(). The length provided by the peer device (0..255 bytes)
+was used without proper bounds checking and that could have resulted in
+arbitrary data of up to 223 bytes being written beyond the end of the
+dev->oper_ssid[] array (of which about 150 bytes would be beyond the
+heap allocation) when processing a corrupted management frame for P2P
+peer discovery purposes.
+
+This could result in corrupted state in heap, unexpected program
+behavior due to corrupted P2P peer device information, denial of service
+due to process crash, exposure of memory contents during GO Negotiation,
+and potentially arbitrary code execution.
+
+Thanks to Google security team for reporting this issue and smart
+hardware research group of Alibaba security team for discovering it.
+
+Signed-off-by: Jouni Malinen <jo...@qca.qualcomm.com>
+---
+ src/p2p/p2p.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/src/p2p/p2p.c
++++ b/src/p2p/p2p.c
+@@ -736,6 +736,7 @@ int p2p_add_device(struct p2p_data *p2p,
+ if (os_memcmp(addr, p2p_dev_addr, ETH_ALEN) != 0)
+ os_memcpy(dev->interface_addr, addr, ETH_ALEN);
+ if (msg.ssid &&
++ msg.ssid[1] <= sizeof(dev->oper_ssid) &&
+ (msg.ssid[1] != P2P_WILDCARD_SSID_LEN ||
+ os_memcmp(msg.ssid + 2, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN)
+ != 0)) {
diff -Nru wpa-2.3/debian/patches/2015-01/wpa_supplicant-p2p-ssid-overflow.txt wpa-2.3/debian/patches/2015-01/wpa_supplicant-p2p-ssid-overflow.txt
--- wpa-2.3/debian/patches/2015-01/wpa_supplicant-p2p-ssid-overflow.txt 1970-01-01 01:00:00.000000000 +0100
+++ wpa-2.3/debian/patches/2015-01/wpa_supplicant-p2p-ssid-overflow.txt 2015-10-24 16:24:26.000000000 +0200
@@ -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)
diff -Nru wpa-2.3/debian/patches/2015-02/0001-WPS-Fix-HTTP-chunked-transfer-encoding-parser.patch wpa-2.3/debian/patches/2015-02/0001-WPS-Fix-HTTP-chunked-transfer-encoding-parser.patch
--- wpa-2.3/debian/patches/2015-02/0001-WPS-Fix-HTTP-chunked-transfer-encoding-parser.patch 1970-01-01 01:00:00.000000000 +0100
+++ wpa-2.3/debian/patches/2015-02/0001-WPS-Fix-HTTP-chunked-transfer-encoding-parser.patch 2015-10-24 16:24:26.000000000 +0200
@@ -0,0 +1,44 @@
+From 5acd23f4581da58683f3cf5e36cb71bbe4070bd7 Mon Sep 17 00:00:00 2001
+From: Jouni Malinen <j...@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...@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
+ */
diff -Nru wpa-2.3/debian/patches/2015-02/wps-upnp-http-chunked-transfer-encoding.txt wpa-2.3/debian/patches/2015-02/wps-upnp-http-chunked-transfer-encoding.txt
--- wpa-2.3/debian/patches/2015-02/wps-upnp-http-chunked-transfer-encoding.txt 1970-01-01 01:00:00.000000000 +0100
+++ wpa-2.3/debian/patches/2015-02/wps-upnp-http-chunked-transfer-encoding.txt 2015-10-24 16:24:26.000000000 +0200
@@ -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)
diff -Nru wpa-2.3/debian/patches/2015-03/0001-AP-WMM-Fix-integer-underflow-in-WMM-Action-frame-par.patch wpa-2.3/debian/patches/2015-03/0001-AP-WMM-Fix-integer-underflow-in-WMM-Action-frame-par.patch
--- wpa-2.3/debian/patches/2015-03/0001-AP-WMM-Fix-integer-underflow-in-WMM-Action-frame-par.patch 1970-01-01 01:00:00.000000000 +0100
+++ wpa-2.3/debian/patches/2015-03/0001-AP-WMM-Fix-integer-underflow-in-WMM-Action-frame-par.patch 2015-10-24 16:24:26.000000000 +0200
@@ -0,0 +1,36 @@
+From ef566a4d4f74022e1fdb0a2addfe81e6de9f4aae Mon Sep 17 00:00:00 2001
+From: Jouni Malinen <j...@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...@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,
diff -Nru wpa-2.3/debian/patches/2015-03/integer-underflow-in-ap-mode-wmm-action-frame.txt wpa-2.3/debian/patches/2015-03/integer-underflow-in-ap-mode-wmm-action-frame.txt
--- wpa-2.3/debian/patches/2015-03/integer-underflow-in-ap-mode-wmm-action-frame.txt 1970-01-01 01:00:00.000000000 +0100
+++ wpa-2.3/debian/patches/2015-03/integer-underflow-in-ap-mode-wmm-action-frame.txt 2015-10-24 16:24:26.000000000 +0200
@@ -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
diff -Nru wpa-2.3/debian/patches/2015-04/0001-EAP-pwd-peer-Fix-payload-length-validation-for-Commi.patch wpa-2.3/debian/patches/2015-04/0001-EAP-pwd-peer-Fix-payload-length-validation-for-Commi.patch
--- wpa-2.3/debian/patches/2015-04/0001-EAP-pwd-peer-Fix-payload-length-validation-for-Commi.patch 1970-01-01 01:00:00.000000000 +0100
+++ wpa-2.3/debian/patches/2015-04/0001-EAP-pwd-peer-Fix-payload-length-validation-for-Commi.patch 2015-10-24 16:24:26.000000000 +0200
@@ -0,0 +1,68 @@
+From dd2f043c9c43d156494e33d7ce22db96e6ef42c7 Mon Sep 17 00:00:00 2001
+From: Jouni Malinen <j...@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...@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
diff -Nru wpa-2.3/debian/patches/2015-04/0002-EAP-pwd-server-Fix-payload-length-validation-for-Com.patch wpa-2.3/debian/patches/2015-04/0002-EAP-pwd-server-Fix-payload-length-validation-for-Com.patch
--- wpa-2.3/debian/patches/2015-04/0002-EAP-pwd-server-Fix-payload-length-validation-for-Com.patch 1970-01-01 01:00:00.000000000 +0100
+++ wpa-2.3/debian/patches/2015-04/0002-EAP-pwd-server-Fix-payload-length-validation-for-Com.patch 2015-10-24 16:24:26.000000000 +0200
@@ -0,0 +1,61 @@
+From e28a58be26184c2a23f80b410e0997ef1bd5d578 Mon Sep 17 00:00:00 2001
+From: Jouni Malinen <j...@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...@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;
diff -Nru wpa-2.3/debian/patches/2015-04/0003-EAP-pwd-peer-Fix-Total-Length-parsing-for-fragment-r.patch wpa-2.3/debian/patches/2015-04/0003-EAP-pwd-peer-Fix-Total-Length-parsing-for-fragment-r.patch
--- wpa-2.3/debian/patches/2015-04/0003-EAP-pwd-peer-Fix-Total-Length-parsing-for-fragment-r.patch 1970-01-01 01:00:00.000000000 +0100
+++ wpa-2.3/debian/patches/2015-04/0003-EAP-pwd-peer-Fix-Total-Length-parsing-for-fragment-r.patch 2015-10-24 16:24:26.000000000 +0200
@@ -0,0 +1,47 @@
+From 477c74395acd0123340457ba6f15ab345d42016e Mon Sep 17 00:00:00 2001
+From: Jouni Malinen <j...@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...@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 "
diff -Nru wpa-2.3/debian/patches/2015-04/0004-EAP-pwd-server-Fix-Total-Length-parsing-for-fragment.patch wpa-2.3/debian/patches/2015-04/0004-EAP-pwd-server-Fix-Total-Length-parsing-for-fragment.patch
--- wpa-2.3/debian/patches/2015-04/0004-EAP-pwd-server-Fix-Total-Length-parsing-for-fragment.patch 1970-01-01 01:00:00.000000000 +0100
+++ wpa-2.3/debian/patches/2015-04/0004-EAP-pwd-server-Fix-Total-Length-parsing-for-fragment.patch 2015-10-24 16:24:26.000000000 +0200
@@ -0,0 +1,45 @@
+From 3035cc2894e08319b905bd6561e8bddc8c2db9fa Mon Sep 17 00:00:00 2001
+From: Jouni Malinen <j...@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...@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 "
diff -Nru wpa-2.3/debian/patches/2015-04/0005-EAP-pwd-peer-Fix-asymmetric-fragmentation-behavior.patch wpa-2.3/debian/patches/2015-04/0005-EAP-pwd-peer-Fix-asymmetric-fragmentation-behavior.patch
--- wpa-2.3/debian/patches/2015-04/0005-EAP-pwd-peer-Fix-asymmetric-fragmentation-behavior.patch 1970-01-01 01:00:00.000000000 +0100
+++ wpa-2.3/debian/patches/2015-04/0005-EAP-pwd-peer-Fix-asymmetric-fragmentation-behavior.patch 2015-10-24 16:24:26.000000000 +0200
@@ -0,0 +1,27 @@
+From 28a069a545b06b99eb55ad53f63f2c99e65a98f6 Mon Sep 17 00:00:00 2001
+From: Jouni Malinen <j...@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...@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,
diff -Nru wpa-2.3/debian/patches/2015-04/eap-pwd-missing-payload-length-validation.txt wpa-2.3/debian/patches/2015-04/eap-pwd-missing-payload-length-validation.txt
--- wpa-2.3/debian/patches/2015-04/eap-pwd-missing-payload-length-validation.txt 1970-01-01 01:00:00.000000000 +0100
+++ wpa-2.3/debian/patches/2015-04/eap-pwd-missing-payload-length-validation.txt 2015-10-24 16:24:26.000000000 +0200
@@ -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
diff -Nru wpa-2.3/debian/patches/2015-05/0001-NFC-Fix-payload-length-validation-in-NDEF-record-par.patch wpa-2.3/debian/patches/2015-05/0001-NFC-Fix-payload-length-validation-in-NDEF-record-par.patch
--- wpa-2.3/debian/patches/2015-05/0001-NFC-Fix-payload-length-validation-in-NDEF-record-par.patch 1970-01-01 01:00:00.000000000 +0100
+++ wpa-2.3/debian/patches/2015-05/0001-NFC-Fix-payload-length-validation-in-NDEF-record-par.patch 2015-10-24 16:31:39.000000000 +0200
@@ -0,0 +1,61 @@
+From df9079e72760ceb7ebe7fb11538200c516bdd886 Mon Sep 17 00:00:00 2001
+From: Jouni Malinen <j...@w1.fi>
+Date: Tue, 7 Jul 2015 21:57:28 +0300
+Subject: [PATCH] NFC: Fix payload length validation in NDEF record parser
+
+It was possible for the 32-bit record->total_length value to end up
+wrapping around due to integer overflow if the longer form of payload
+length field is used and record->payload_length gets a value close to
+2^32. This could result in ndef_parse_record() accepting a too large
+payload length value and the record type filter reading up to about 20
+bytes beyond the end of the buffer and potentially killing the process.
+This could also result in an attempt to allocate close to 2^32 bytes of
+heap memory and if that were to succeed, a buffer read overflow of the
+same length which would most likely result in the process termination.
+In case of record->total_length ending up getting the value 0, there
+would be no buffer read overflow, but record parsing would result in an
+infinite loop in ndef_parse_records().
+
+Any of these error cases could potentially be used for denial of service
+attacks over NFC by using a malformed NDEF record on an NFC Tag or
+sending them during NFC connection handover if the application providing
+the NDEF message to hostapd/wpa_supplicant did no validation of the
+received records. While such validation is likely done in the NFC stack
+that needs to parse the NFC messages before further processing,
+hostapd/wpa_supplicant better be prepared for any data being included
+here.
+
+Fix this by validating record->payload_length value in a way that
+detects integer overflow. (CID 122668)
+
+Signed-off-by: Jouni Malinen <j...@w1.fi>
+---
+ src/wps/ndef.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/src/wps/ndef.c b/src/wps/ndef.c
+index 5604b0a..50d018f 100644
+--- a/src/wps/ndef.c
++++ b/src/wps/ndef.c
+@@ -48,6 +48,8 @@ static int ndef_parse_record(const u8 *data, u32 size,
+ if (size < 6)
+ return -1;
+ record->payload_length = ntohl(*(u32 *)pos);
++ if (record->payload_length > size - 6)
++ return -1;
+ pos += sizeof(u32);
+ }
+
+@@ -68,7 +70,8 @@ static int ndef_parse_record(const u8 *data, u32 size,
+ pos += record->payload_length;
+
+ record->total_length = pos - data;
+- if (record->total_length > size)
++ if (record->total_length > size ||
++ record->total_length < record->payload_length)
+ return -1;
+ return 0;
+ }
+--
+1.9.1
+
diff -Nru wpa-2.3/debian/patches/2015-05/incomplete-wps-and-p2p-nfc-ndef-record-payload-length-validation.txt wpa-2.3/debian/patches/2015-05/incomplete-wps-and-p2p-nfc-ndef-record-payload-length-validation.txt
--- wpa-2.3/debian/patches/2015-05/incomplete-wps-and-p2p-nfc-ndef-record-payload-length-validation.txt 1970-01-01 01:00:00.000000000 +0100
+++ wpa-2.3/debian/patches/2015-05/incomplete-wps-and-p2p-nfc-ndef-record-payload-length-validation.txt 2015-07-08 16:49:25.000000000 +0200
@@ -0,0 +1,87 @@
+Incomplete WPS and P2P NFC NDEF record payload length validation
+
+Published: July 8, 2015
+The latest version available from: http://w1.fi/security/2015-5/
+
+
+Vulnerability
+
+A vulnerability was found in NDEF record parsing implementation in
+hostapd and wpa_supplicant. This code is used when an NFC Tag or NFC
+connection handover is used to trigger WPS or P2P operations. The parser
+did include bounds checking for the NDEF record payload length, but due
+to insufficient integer size, it was possible to trigger integer
+overflow that would result in bypassing the validation step with some
+malformed NDEF records.
+
+This could result in denial of service due to hostapd/wpa_supplicant
+process termination (buffer read overflow) or infinite loop. The issue
+can be triggered only if the NFC stack on the device does not perform
+required validation steps for received NFC messages before sending the
+received message to hostapd/wpa_supplicant for processing.
+
+It was possible for the 32-bit record->total_length value to end up
+wrapping around due to integer overflow if the longer form of payload
+length field is used and record->payload_length gets a value close to
+2^32. This could result in ndef_parse_record() accepting a too large
+payload length value and the record type filter reading up to about 20
+bytes beyond the end of the buffer and potentially killing the process.
+This could also result in an attempt to allocate close to 2^32 bytes of
+heap memory and if that were to succeed, a buffer read overflow of the
+same length which would most likely result in the process termination.
+In case of record->total_length ending up getting the value 0, there
+would be no buffer read overflow, but record parsing would result in an
+infinite loop in ndef_parse_records().
+
+Any of these error cases could potentially be used for denial of service
+attacks over NFC by using a malformed NDEF record on an NFC Tag or
+sending them during NFC connection handover if the application providing
+the NDEF message to hostapd/wpa_supplicant did no validation of the
+received NDEF records. While such validation is likely done in the NFC
+stack that needs to parse the NFC messages before further processing,
+hostapd/wpa_supplicant should have (re)confirmed NDEF message validity
+properly.
+
+
+Vulnerable versions/configurations
+
+hostapd v0.7.0-v2.4 with CONFIG_WPS_NFC=y in the build configuration
+(hostapd/.config) and NFC NDEF records passed to hostapd by the NFC
+stack without validation.
+
+wpa_supplicant v0.7.0-v2.4 with CONFIG_WPS_NFC=y in the build
+configuration (wpa_supplicant/.config) and NFC NDEF records passed to
+wpa_supplicant by the NFC stack without validation.
+
+Note: No NFC stack implementation has yet been identified with
+capability to pass the malformed NDEF record to
+hostapd/wpa_supplicant. As such, it is not known whether this issue can
+be triggered in practice.
+
+Alternatively to an actual NFC operation trigger, the malformed NDEF
+records could be provided by other applications running on the same
+device if access to the hostapd/wpa_supplicant control interface is
+available to untrusted components or users.
+
+
+Acknowledgments
+
+Coverity Scan discovered parts of this issue (insecure data
+handling/TAINTED_SCALAR) and was the trigger for further manual review
+of the parsing routine.
+
+
+Possible mitigation steps
+
+- Merge the following commit and rebuild hostapd/wpa_supplicant:
+
+ NFC: Fix payload length validation in NDEF record parser
+
+ This patch is available from http://w1.fi/security/2015-5/
+
+- Update to hostapd/wpa_supplicant v2.5 or newer, once available
+
+- Remove CONFIG_WPS_NFC=y from build configuration
+
+- Confirm that the NFC stack does sufficient validation of the received
+ NDEF records before passing them to hostapd/wpa_supplicant
diff -Nru wpa-2.3/debian/patches/series wpa-2.3/debian/patches/series
--- wpa-2.3/debian/patches/series 2015-04-23 19:32:18.000000000 +0200
+++ wpa-2.3/debian/patches/series 2015-10-24 16:29:07.000000000 +0200
@@ -6,4 +6,12 @@
wpa_gui_desktop_add-keywords-entry.patch
wpa_supplicant-MACsec-fix-build-failure-for-IEEE8021.patch
include-ieee802_11_common.c-in-wpa_supplicant-build-.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
+2015-05/0001-NFC-Fix-payload-length-validation-in-NDEF-record-par.patch
diff -Nru wpa-2.3/debian/patches/wpasupplicant_P2P-Validate-SSID-element-length-before-copying-it-C.patch wpa-2.3/debian/patches/wpasupplicant_P2P-Validate-SSID-element-length-before-copying-it-C.patch
--- wpa-2.3/debian/patches/wpasupplicant_P2P-Validate-SSID-element-length-before-copying-it-C.patch 2015-04-23 19:32:08.000000000 +0200
+++ wpa-2.3/debian/patches/wpasupplicant_P2P-Validate-SSID-element-length-before-copying-it-C.patch 1970-01-01 01:00:00.000000000 +0100
@@ -1,37 +0,0 @@
-From 9ed4eee345f85e3025c33c6e20aa25696e341ccd Mon Sep 17 00:00:00 2001
-From: Jouni Malinen <jo...@qca.qualcomm.com>
-Date: Tue, 7 Apr 2015 11:32:11 +0300
-Subject: [PATCH] P2P: Validate SSID element length before copying it
- (CVE-2015-1863)
-
-This fixes a possible memcpy overflow for P2P dev->oper_ssid in
-p2p_add_device(). The length provided by the peer device (0..255 bytes)
-was used without proper bounds checking and that could have resulted in
-arbitrary data of up to 223 bytes being written beyond the end of the
-dev->oper_ssid[] array (of which about 150 bytes would be beyond the
-heap allocation) when processing a corrupted management frame for P2P
-peer discovery purposes.
-
-This could result in corrupted state in heap, unexpected program
-behavior due to corrupted P2P peer device information, denial of service
-due to process crash, exposure of memory contents during GO Negotiation,
-and potentially arbitrary code execution.
-
-Thanks to Google security team for reporting this issue and smart
-hardware research group of Alibaba security team for discovering it.
-
-Signed-off-by: Jouni Malinen <jo...@qca.qualcomm.com>
----
- src/p2p/p2p.c | 1 +
- 1 file changed, 1 insertion(+)
-
---- a/src/p2p/p2p.c
-+++ b/src/p2p/p2p.c
-@@ -736,6 +736,7 @@ int p2p_add_device(struct p2p_data *p2p,
- if (os_memcmp(addr, p2p_dev_addr, ETH_ALEN) != 0)
- os_memcpy(dev->interface_addr, addr, ETH_ALEN);
- if (msg.ssid &&
-+ msg.ssid[1] <= sizeof(dev->oper_ssid) &&
- (msg.ssid[1] != P2P_WILDCARD_SSID_LEN ||
- os_memcmp(msg.ssid + 2, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN)
- != 0)) {