0002-WPS-Fix-HTTP-chunked-transfer-encoding-parser.patch 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. From 5acd23f4581da58683f3cf5e36cb71bbe4070bd7 Mon Sep 17 00:00:00 2001
  2. From: Jouni Malinen <j@w1.fi>
  3. Date: Tue, 28 Apr 2015 17:08:33 +0300
  4. Subject: [PATCH] WPS: Fix HTTP chunked transfer encoding parser
  5. strtoul() return value may end up overflowing the int h->chunk_size and
  6. resulting in a negative value to be stored as the chunk_size. This could
  7. result in the following memcpy operation using a very large length
  8. argument which would result in a buffer overflow and segmentation fault.
  9. This could have been used to cause a denial service by any device that
  10. has been authorized for network access (either wireless or wired). This
  11. would affect both the WPS UPnP functionality in a WPS AP (hostapd with
  12. upnp_iface parameter set in the configuration) and WPS ER
  13. (wpa_supplicant with WPS_ER_START control interface command used).
  14. Validate the parsed chunk length value to avoid this. In addition to
  15. rejecting negative values, we can also reject chunk size that would be
  16. larger than the maximum configured body length.
  17. Thanks to Kostya Kortchinsky of Google security team for discovering and
  18. reporting this issue.
  19. Signed-off-by: Jouni Malinen <j@w1.fi>
  20. Signed-off-by: Baruch Siach <baruch@tkos.co.il>
  21. ---
  22. src/wps/httpread.c | 7 +++++++
  23. 1 file changed, 7 insertions(+)
  24. diff --git a/src/wps/httpread.c b/src/wps/httpread.c
  25. index 2f08f37275c0..d2855e32fd0f 100644
  26. --- a/src/wps/httpread.c
  27. +++ b/src/wps/httpread.c
  28. @@ -533,6 +533,13 @@ static void httpread_read_handler(int sd, void *eloop_ctx, void *sock_ctx)
  29. if (!isxdigit(*cbp))
  30. goto bad;
  31. h->chunk_size = strtoul(cbp, NULL, 16);
  32. + if (h->chunk_size < 0 ||
  33. + h->chunk_size > h->max_bytes) {
  34. + wpa_printf(MSG_DEBUG,
  35. + "httpread: Invalid chunk size %d",
  36. + h->chunk_size);
  37. + goto bad;
  38. + }
  39. /* throw away chunk header
  40. * so we have only real data
  41. */
  42. --
  43. 2.1.4