aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2015-04-28 17:08:33 +0300
committerMichael Bestas <mikeioannina@gmail.com>2015-11-11 19:39:15 +0200
commita549bf5c2dd9578a0b737dc6e74d65897cf4aa80 (patch)
treeb3b7ab867c682700d9dac2e6a2b1a9e5843130fb
parentb9922eaf796f4b7c9b6a314f4c18679fc14a11d8 (diff)
downloadandroid_external_wpa_supplicant_8-a549bf5c2dd9578a0b737dc6e74d65897cf4aa80.tar.gz
android_external_wpa_supplicant_8-a549bf5c2dd9578a0b737dc6e74d65897cf4aa80.tar.bz2
android_external_wpa_supplicant_8-a549bf5c2dd9578a0b737dc6e74d65897cf4aa80.zip
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. Change-Id: Ie9a6d41f2f7dea0010a24147257547fc6479b499 Signed-off-by: Jouni Malinen <j@w1.fi>
-rw-r--r--src/wps/httpread.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/wps/httpread.c b/src/wps/httpread.c
index ad4f4a1d..c40ca7a4 100644
--- a/src/wps/httpread.c
+++ b/src/wps/httpread.c
@@ -554,6 +554,13 @@ static void httpread_read_handler(int sd, void *eloop_ctx, void *sock_ctx)
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
*/