libsoup-CVE-2011-2054.patch 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. From 4617b6ef6dd21931a0153070c5b5ff7ef21b46f8 Mon Sep 17 00:00:00 2001
  2. From: Dan Winship <danw@gnome.org>
  3. Date: Wed, 29 Jun 2011 10:04:06 -0400
  4. Subject: [PATCH] SoupServer: fix to not allow smuggling ".." into path
  5. When SoupServer:raw-paths was set (the default), it was possible to
  6. sneak ".." segments into the path passed to the SoupServerHandler,
  7. which could then end up tricking some handlers into retrieving
  8. arbitrary files from the filesystem. Fix that.
  9. https://bugzilla.gnome.org/show_bug.cgi?id=653258
  10. diff --git a/libsoup/soup-server.c b/libsoup/soup-server.c
  11. index d56efd1..7225337 100644
  12. --- a/libsoup/soup-server.c
  13. +++ b/libsoup/soup-server.c
  14. @@ -779,6 +779,15 @@ got_headers (SoupMessage *req, SoupClientContext *client)
  15. uri = soup_message_get_uri (req);
  16. decoded_path = soup_uri_decode (uri->path);
  17. +
  18. + if (strstr (decoded_path, "/../") ||
  19. + g_str_has_suffix (decoded_path, "/..")) {
  20. + /* Introducing new ".." segments is not allowed */
  21. + g_free (decoded_path);
  22. + soup_message_set_status (req, SOUP_STATUS_BAD_REQUEST);
  23. + return;
  24. + }
  25. +
  26. soup_uri_set_path (uri, decoded_path);
  27. g_free (decoded_path);
  28. }