RE: Squid URL Filtering Bypass



To be clear, the CONNECT request is a single request/response cycle between the client and the proxy. Any request body is nonsensical and should be ignored by the proxy (or the request can be rejected if the proxy wants to be pedantic). There is nothing that explicitly disallows inclusion of the host header in a CONNECT request. Granted, including the host header incurs some degree of ambiguity (the FQDN may resolve to the IP address, but the IP address is not guaranteed to resolve to the FQDN), but this is clearly a debatable choice on the developer's part as to whether it should be used to determine traffic policy applicability for this request.

The proxy should only ignore further data between the client and remote if the proxy successfully established a TCP connection between them on the specified destination port.
IOW, if the client sends a CONNECT request that the proxy policy allows, the proxy should either queue or reject further communication from the client until the TCP connection has been successfully established and the proxy has responded to the client with "HTTP 200".
If the connection attempt fails, the proxy should provide an HTTP error response to the client and close the client-to-proxy connection.

Likewise, while the proxy does establish the end-to-end TCP connection between the client and upstream server, it is not responsible for any part of the encryption that may be involved in that communication - unless it specifically offers a "trusted MitM" feature such as TMG HTTPS Inspection or Juniper SSL Forward Proxy (other vendors have similar features).

Also, whether the McAffee proxy allows translating normal HTTP methods to CONNECT, then tunneling them to the upstream proxy is irrelevant to the question of whether the local proxy actually uses the host header or the host portion of the CONNECT request to determine policy applicability.

Regardless - unless the proxy under test explicitly states that the host header information is used to determine policy application to a request, there is no vulnerability.

Jim

-----Original Message-----
From: Mario Vilas [mailto:mvilas@xxxxxxxxx]
Sent: Thursday, April 19, 2012 10:03 AM
To: Richard Barrett
Cc: Gabriel Menezes Nunes; bugtraq
Subject: Re: Squid URL Filtering Bypass

What I understand from the advisory is the Squid proxy is basing its filtering on the Host header when present, even for the CONNECT command which doesn't allow this header at all as it makes no sense. I haven't confirmed the bug but what's being described is definitely a vulnerability.

There's also a small misconception in what you said. The proxy will see the entire CONNECT request, headers and all - after the request headers there'll be a pair of newlines, and only *then* the remaining data is tunneled transparently. So it's the second request's headers that the proxy won't see.

On Wed, Apr 18, 2012 at 7:46 PM, Richard Barrett <r.barrett@xxxxxxxxxxxxxx> wrote:

A forward proxy server when presented with a CONNECT request is solely responsible for attempting to facilitate an end-to-end encrypted path between the requesting client and the far end server. The CONNECT method does no more than create a temporary hole in your firewall.

Only once that is done is a normal HTTP request, including headers such as the Host: header, passed over the encrypted path by the client. Most crucially, the proxy server cannot see the HTTP request or its headers due to the end-to-end encryption. You can use the encrypted path to carry any protocol or data you like and the proxy server is quite oblivious to it as it is opaque to the proxy.

The only access control that the proxy server can perform is based on the CONNECT method request and the server identified in it by either IP number or FQDN and port.

You do not say what the acl is that you have asked Squid to apply but it cannot involve any examination of the Host: header of a request if the CONNECT method is used; only the far end server can see that.

The same  conclusion also applies to your other post about a vulnerability with "McAfee Web Gateway URL Filtering Bypass"

On 16 Apr 2012, at 23:11, Gabriel Menezes Nunes wrote:

# Exploit Title: Squid URL Filtering Bypass # Date: 16/04/2012 #
Author: Gabriel Menezes Nunes # Version: Squid Proxy # Tested on:
Squid Proxy 3.1.19 # CVE: CVE-2012-2213


I found a vulnerability in Squid Proxy that allows access to filtered sites.
The software believes in the Host field of HTTP Header using CONNECT method.
Example

CONNECT 66.220.147.44:443 HTTP/1.1
Host: www.facebook.com


It is blocked.

CONNECT 66.220.147.44:443 HTTP/1.1 (without host field)

It is blocked.

But:

CONNECT 66.220.147.44:443 HTTP/1.1
Host: www.uol.com.br (allowed url)

The connection works.

From here, I can send SSL traffic without a problem. This way, I can
access any blocked site that allows SSL connections.


This vulnerability is different from the CONNECT Tunnel method. The
flaw is on the Host field processing. The software believes on this
field.

So, any sites can be accessed. URL filtering in this software is
irrelevant and useless.
One of the most important (if not the most important) feature of
this kind of device is to protect the network in accessing specific URLs.
So, this flaw is very dangerous, and it can be implemented even in
malwares, bypassing any protection.
I developed a python script that acts like a proxy and it uses this
flaw to access any site.
This tool is just a proof of concept.
<proxy_bypass.py>




--
"There's a reason we separate military and the police: one fights the enemy of the state, the other serves and protects the people. When the military becomes both, then the enemies of the state tend to become the people."



Relevant Pages

  • Re: Banana Republic (was Re: OpenVMS Book Wins award)
    ... The graphed 'events' are individually and asynchronously provided from the server to the client over a persistent connection and each respective graphical element is equally asynchronously updated. ... However it can emulate asynchronous, raw network streams via a Web Socket server / raw IP network proxy. ... If you mean Web Sockets can't through existing HTTP proxy then the ...
    (comp.os.vms)
  • Re: Banana Republic (was Re: OpenVMS Book Wins award)
    ... other requests while it's streaming its long-poll (or words to that effect ... If you mean Web Sockets can't through existing HTTP proxy then the ... Orbited is a service used to accept Web-style socket connection ...
    (comp.os.vms)
  • Re: Banana Republic (was Re: OpenVMS Book Wins award)
    ... Isn't asocket proxy that doesn't explicitly talk HTTP during setup a one-to-one NAT router? ... And if accepting external connection requests, a static port mapping NAT router, into/through the DMZ and onto internal services? ... Of course it's a bit more than that Until Web Sockets become commonplace it uses a number of approaches to *emulate* asynchronous comms with current browsers. ... Mandatory Upgrade ...
    (comp.os.vms)
  • Re: Squid URL Filtering Bypass
    ... the proxy will accept. ... The same  conclusion also applies to your other post about a vulnerability with "McAfee Web Gateway URL Filtering Bypass" ... The software believes in the Host field of HTTP Header using CONNECT method. ... The connection works. ...
    (Bugtraq)
  • Re: Banana Republic (was Re: OpenVMS Book Wins award)
    ... originated by the proxy. ... Mandatory Upgrade ... Connection: Upgrade ... I had the most success using GET without a Connection: Upgrade header. ...
    (comp.os.vms)