]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Re-enable revno11514. Host: verification now done
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 3 Aug 2011 12:52:39 +0000 (06:52 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 3 Aug 2011 12:52:39 +0000 (06:52 -0600)
doc/release-notes/release-3.2.sgml
src/acl/DestinationIp.cc
src/cf.data.pre
src/forward.cc
src/hier_code.h
src/structs.h

index c995e1709a44a097fdafd8cbda1cd89f2048005f..e67f54a51b185884a4ac057021896a005bbdfc65 100644 (file)
@@ -392,6 +392,10 @@ This section gives a thorough account of those changes in three categories:
        <p>New setting for client bandwith limits to determines the 
          client-side delay pool for the request.
 
+       <tag>client_dst_passthru</tag>
+       <p>New setting to disable Host: header security on interception proxies.
+          Impacts cache integrity/reliability and client browser security.
+
        <tag>cpu_affinity_map</tag>
        <p>New setting for SMP support to map Squid processes onto specific CPU cores.
 
index 35d3b8186e7a8f62fe6e2ac76190aff0bb0f513e..0de76f0537007fd62cb21342e37d288521bb449e 100644 (file)
 #include "squid.h"
 #include "acl/DestinationIp.h"
 #include "acl/FilledChecklist.h"
+#include "comm/Connection.h"
 #include "HttpRequest.h"
+// for Config.*
+#include "structs.h"
 
 char const *
 ACLDestinationIP::typeString() const
@@ -48,6 +51,17 @@ int
 ACLDestinationIP::match(ACLChecklist *cl)
 {
     ACLFilledChecklist *checklist = Filled(cl);
+
+    // Bug 3243: CVE 2009-0801
+    // Bypass of browser same-origin access control in intercepted communication
+    // To resolve this we will force DIRECT and only to the original client destination.
+    // In which case, we also need this ACL to accurately match the destination
+    if (Config.onoff.client_dst_passthru && checklist->request &&
+            (checklist->request->flags.intercepted || checklist->request->flags.spoof_client_ip)) {
+        assert(checklist->conn() && checklist->conn()->clientConnection != NULL);
+        return ACLIP::match(checklist->conn()->clientConnection->local);
+    }
+
     const ipcache_addrs *ia = ipcache_gethostbyname(checklist->request->GetHost(), IP_LOOKUP_IF_MISS);
 
     if (ia) {
index 84e44a4052ccad2fe20c8dcf1bf14481f1df6954..72936bd2f743cc8faed9c1ad5b5877d6a6d15fd7 100644 (file)
@@ -1771,6 +1771,36 @@ DOC_START
 
 DOC_END
 
+NAME: client_dst_passthru
+TYPE: onoff
+DEFAULT: on
+LOC: Config.onoff.client_dst_passthru
+DOC_START
+       With NAT or TPROXY intercepted traffic Squid may pass the request
+       directly to the original client destination IP or seek a faster
+       source.
+       
+       This option (on by default) prevents cache_peer and alternative DNS
+       entries being used on intercepted traffic. Both of which lead to
+       the security vulnerability outlined below.
+       
+       SECURITY WARNING:
+       
+       This directive should only be disabled if cache_peer are required.
+       
+       As described in CVE-2009-0801 when the Host: header alone is used
+       to determine the destination of a request it becomes trivial for
+       malicious scripts on remote websites to bypass browser same-origin
+       security policy and sandboxing protections.
+       
+       The cause of this is that such applets are allowed to perform their
+       own HTTP stack, in which case the same-origin policy of the browser
+       sandbox only verifies that the applet tries to contact the same IP
+       as from where it was loaded at the IP level. The Host: header may
+       be different from the connected IP and approved origin.
+
+DOC_END
+
 COMMENT_START
  SSL OPTIONS
  -----------------------------------------------------------------------------
index 53be5cb97c0e6457889111c38fb3d08e3d4dda9d..87bf1fd83427afe11117a18e18b03d84818a71f4 100644 (file)
@@ -116,7 +116,24 @@ void FwdState::start(Pointer aSelf)
     // Otherwise we are going to leak our object.
 
     entry->registerAbort(FwdState::abort, this);
-    peerSelect(&serverDestinations, request, entry, fwdPeerSelectionCompleteWrapper, this);
+
+    // Bug 3243: CVE 2009-0801
+    // Bypass of browser same-origin access control in intercepted communication
+    // To resolve this we must force DIRECT and only to the original client destination.
+    if (Config.onoff.client_dst_passthru && request &&
+            (request->flags.intercepted || request->flags.spoof_client_ip)) {
+        Comm::ConnectionPointer p = new Comm::Connection();
+        p->remote = clientConn->local;
+        p->peerType = ORIGINAL_DST;
+        getOutgoingAddress(request, p);
+        serverDestinations.push_back(p);
+
+        // destination "found". continue with the forwarding.
+        startConnectionOrFail();
+    } else {
+        // do full route options selection
+        peerSelect(&serverDestinations, request, entry, fwdPeerSelectionCompleteWrapper, this);
+    }
 }
 
 void
index 23225c376047e4fdaf8e43d0ee15f1c367f9651b..678cb593fa1dbc9ae3a48cb855fed363093a0085 100644 (file)
@@ -25,6 +25,7 @@ typedef enum {
     USERHASH_PARENT,
     SOURCEHASH_PARENT,
     PINNED,
+    ORIGINAL_DST,
     HIER_MAX
 } hier_code;
 
index 3cfda1027777c5ab9117e1c909ee21bf87d35b57..8598d080567b122cd78d0efed4357adc319f0424 100644 (file)
@@ -436,6 +436,7 @@ struct SquidConfig {
         int WIN32_IpAddrChangeMonitor;
         int memory_cache_first;
         int memory_cache_disk;
+        int client_dst_passthru;
     } onoff;
 
     int forward_max_tries;