Paranoid Penguin - Building a Secure Squid Web Proxy, Part III
We've been building a secure Squid Web Proxy the past few months, and we'll continue to do so for a couple more. Last time [May 2009], we got Squid installed, running and restricted to serve only local clients (based on their IP addresses). This month, we delve deeper into Squid's Access Control List (ACL) capabilities and other built-in security features.
As you may recall from my last column, all we had to do to get Squid running on a standard Ubuntu 8.04 system was add two lines to the file /etc/squid/squid.conf:
acl mick_network src 10.0.2.0/24 http_access allow mick_network
We inserted those two lines, which allow outbound proxy connections from clients whose IP addresses fall within the network 10.0.2.0/24 (that is, addresses 10.0.2.1 through 10.0.2.254), right above Squid's default “deny all” ACL, which looks like this:
http_access deny all
You can correctly infer from this that, by default, Squid denies proxy connections from all clients. This is a refreshing change in default server application configurations during the past few years. Whereas in the past, many applications had default configurations that would “just work”, which is a very user-friendly but also excessively open stance, nowadays few network applications will do much of anything without some administrative intervention. This is only sensible. Connecting things to the Internet that you don't even know how to configure is the way of pain.
Getting back to our example ACL, the acl statement itself is fairly self-explanatory: acl tells Squid we're defining an ACL; mick_network is its name; src indicates it matches the client's source IP address or network address; and 10.0.2.0/24 is the network address in CIDR notation that will match this ACL.
This is the simplest type of ACL and still one of the most useful. In February 2002, if the New York Times had had a simple source-IP/network ACL correctly configured on its Internet-facing corporate Web proxies, the rogue hacker Adrian Lamos couldn't have gained access quite so easily to its editorial-page contributor database or its Lexus-Nexus portal.
Besides clients' (source) IP addresses, Squid also can match a great deal of other proxy transaction characteristics. Note that some of these deal with arcane HTTP headers and parameters, many of which are minimally useful for most Squid users anyhow.
Table 1. Complete List of ACL Types Supported in Squid 2.6
| ACL Type | Description |
|---|---|
| src | Client (transaction source) IP address or network address. |
| dst | Server (transaction destination) IP address or network address. |
| myip | Local IP address on which Squid is listening for connections. |
| arp | Client's Ethernet (MAC) address (matches local LAN clients only). |
| srcdomain | Client's domain name as determined by reverse DNS lookup. |
| dstdomain | Domain portion of URL requested by client. |
| srcdom_regex | Regular expression matching client's domain name. |
| dstdom_regex | Regular expression matching domain in requested URL. |
| time | Period of time in which transaction falls. |
| url_regex | Regular expression matching entire requested URL (not just domain). |
| urlpath_regex | Regular expression matching path portion of requested URL. |
| urllogin | Regular expression matching requested URL's “login” field. |
| port | Requested site's (destination) TCP port. |
| myport | Local TCP port on which Squid is listening for connections. |
| proto | Application-layer protocol of request (HTTP, HTTPS, FTP, WHOIS or GOPHER). |
| method | Request's HTTP method (GET, POST or CONNECT). |
| browser | Matches the client's browser, per HTTP “User-Agent” header. |
| referer_regex | Regular expression matching the unreliable HTTP “Referer” header (that is, the supposed URL of some page on which the user clicked a link to the requested site). |
| ident | Matches specified user name(s) of user(s) running client browser, per an “ident” lookup. Note that ident replies, which often can be spoofed, should not be used in lieu of proper authentication. |
| ident_regex | Regular expression defining which client user names to match per ident lookup. |
| src_as | Matches client IP addresses associated with the specified Autonomous System (AS) number, usually an ISP or other large IP registrant. |
| dst_as | Matches destination-server IP addresses associated with the specified AS number. |
| proxy_auth | Matches the specified user name, list of user names or the wild card REQUIRED (which signifies any valid user name). |
| proxy_auth_regex | Regular expression defining which user names to match. |
| snmp_community | For SNMP-enabled Squid proxies, matches client-provided SNMP community string. |
| maxconn | Matches when client's IP address has established more than the specified number of HTTP connections. |
| max_user_ip | Matches the number of IP addresses from which a single user attempts to log in. |
| req_mime_type | Matches a regular expression describing the MIME type of the client's request (not the server's response). |
| req_header | Matches a regular expression applied to all known request headers (browser, referer and mime-type) in the client's request. |
| rep_mime_type | Matches a regular expression describing the MIME type of the server's response. |
| rep_header | Matches a regular expression applied to all known request headers (browser, referer and mime-type) in the server's response. |
| external | Performs an external ACL lookup by querying the specified helper class defined in the external_acl_type tag. |
| urlgroup | Matches a urlgroup name, as defined in redirector setups. |
| user_cert | Matches specified attribute (DN, C, O, CN, L or ST) and values against client's SSL certificate. |
| ca_cert | Matches specified attribute (DN, C, O, CN, L or ST) and values against client certificate's issuing Certificate Authority certificate. |
| ext_user | Matches specified user name(s) against that returned by an external ACL/authentication helper (configured elsewhere in squid.conf). |
| ext_user_regex | Matches a regular expression describing user names to be matched against that returned by an external ACL/authentication helper. |
I've presented the full range of possible ACL types to give you a taste for how rich Squid's ACL functionality is. Needless to say, however, I can't cover usage scenarios for (or even adequately explain) all of these. ViServe's “Squid 2.6 Configuration Manual” (see Resources) gives complete syntax and usage examples for all.
Many, if not most, Squid installations don't go much beyond a few src ACLs, along with perhaps a few simple dstdomain blacklist entries thrown in for good measure. Many of the other most useful ACL types, such as myip, time, port, proto, method, dst_mime_type and rep_mime_type, should be reasonably self-explanatory (or at least easy enough to understand from the examples shown in squid.conf's comments).
One category of less-intuitive ACL types is particularly powerful and useful: the ones that enable Squid to authenticate client users via external authentication authorities. Before we tackle authentication, however, we should give a little more attention to ACL operators, the tags that perform some action (most commonly, to allow or deny a request) based on a matched ACL.
By far, the most important ACL operator is http_access, which specifies whether Squid should allow the transaction matching the specified ACL to proceed. Going back to the example ACL/operator pair from the beginning of this section, after we defined the ACL mick_network as all transactions involving client/source IP addresses within 10.0.2.0/24, we operated on it with this line:
http_access allow mick_network
This is simple enough to understand: “allow HTTP requests matching the ACL named mick_network.”
The most common use of ACLs is to specify a list of ACLs and http_access statements, ending (as we've seen) with a “drop by default” line, like this:
http_access deny all
This has the effect of creating a “whitelist”— a list of types of transactions that are allowed, with all others being denied.
Squid recognizes a number of additional ACL operators besides http_allow, including no_cache, ident_lookup_access, always_direct, never_direct and snmp_access. Because most of these concern cache performance, HTTP redirects and communications with other Squid servers rather than security per se, I'll leave it to you to explore those (or not) as your particular needs dictate. The Squid User's Guide referenced in the Resources section is a good source of information about Squid's various ACL operators.
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
| Dart: a New Web Programming Experience | May 07, 2013 |
- RSS Feeds
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- New Products
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Home, My Backup Data Center
- Validate an E-Mail Address with PHP, the Right Way
- Trying to Tame the Tablet
- New Products
- Tech Tip: Really Simple HTTP Server with Python
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.




2 hours 1 min ago
2 hours 24 min ago
2 hours 34 min ago
2 hours 38 min ago
3 hours 8 min ago
5 hours 59 min ago
6 hours 35 min ago
6 hours 36 min ago
6 hours 37 min ago
6 hours 38 min ago