How To Block Cookies From Unwanted Websites With SafeSquid Proxy Server

Submitted by Sean (Contact Author) (Forums) on Tue, 2008-07-01 12:40. :: Security

How To Block Cookies From Unwanted Websites With SafeSquid Proxy Server

Basically, cookies are pieces of information, usually personal preferences, that are stored into a visitors system, when they visit a website. The next time the visitor accesses the same website, the cookie is transferred from the visitors system to the website, and his preferred content is displayed to him. Cookies are also used to allow a visitor to log into his personal account on a website. Although, not always dangerous, many advertising and marketing websites gather personal information, without the users knowledge, and use this information to display especially targeted marketing ads and banners. See this interesting article about cookies - http://www.cookiecentral.com/c_concept.htm

SafeSquid's Cookie Filter Section, allows you to control exchange of cookies between users and websites. You can define what websites are allowed / denied to exchange cookies with users, either to enhance security, or to disable the users from logging into their personal accounts. For example, you can block cookies from advertising websites like tribalfusion.com and doubleclick.net to prevent private information from being transferred to them; or search engines like Google and Yahoo, so that users are able to query the search engines, but not log into their personal accounts to use their personal email and other applications.

To block cookies from specific host, first create a profile under the Profiles section, and specify the hosts that you would like to block exchange of cookies with.
Open the SafeSquid web interface, and go to Config => Profiles.
Click on Add under profile subsection, and add the following two profiles, one for Ad Servers, and the other for Search Engines:

Option Value
Enabled true
Comment Add profile 'deny-cookie' to requests from Accounts & Finance for the specified Ad Servers
Profiles Accounts,Finance
Host (tribalfusion.com|atdmt.com|hitbox.com|doubleclick.net|valueclick.net|mediaplex.net|zedo.com)
Time match mode absolutetime
Added profiles deny-cookie

The above rule will add a profile deny-cookie to requests made specifically by the Accounts and Finance groups, to the specified Ad Servers. If you would like to apply the rule to all users, then just leave the Profiles field blank.

Option Value
Enabled true
Comment Add profile 'deny-cookie' to requests  from Accounts & Finance to the specified Search Engines
Profiles Accounts,Finance
Host (google|yahoo)\..*
Time match mode absolutetime
Added profiles deny-cookie

Note that the regex used in the Host field in the above rule is (google|yahoo)\..* which means a host with either the word google or yahoo ((google|yahoo)), followed by a dot (\.), followed by any character (.), any number of times (*). This covers all domains like google. or yahoo. followed by com, co.in, co.uk, etc.

Now, we can use the profile deny-cookie in the Cookie filter section.
To configure the Cookie filtering section, go to Config => Cookie filter.
Verify that the section is enabled (Enabled = Yes) and the Policy is Allow.
When the Policy is Allow, all cookies will be allowed, except the one defined in the Deny subsection.

cookie-filtering section

This section allows you to control which hosts client browsers are allowed to send and receive cookies to and from.
Option Value
Enabled Yes:  No:
Policy Allow:  Deny:

Allow
Add
Deny
Add

To define a rule to deny cookies, click on Add under Deny subsection, and create the rule as shown below:

Option Value
Enabled true
Comment Block cookies to deny-cookie profile.
Profile deny-cookie
Direction Both
Time match mode absolutetime

Now, in the browser, open google or yahoo page, and check whether you are able to run queries. Next, try logging into your personal google or yahoo account, or logging into your personal mail account on google or yahoo. Your password will not be accepted, and an error will be displayed. This is because SafeSquid blocked cookie exchange between the browser and the website.

To verify if the cookies are getting blocked, click on View log entries from the Top Menu in the web interface. You should see entries similar to these:

2008 06 21 13:43:31 [597] cookie filter: blocked incoming from us.f362.mail.yahoo.com
2008 06 21 13:43:31 [597] request: GET http://us.f362.mail.yahoo.com:80/ym/login?.rand=fjao5ijaa5cgc
2008 06 21 13:43:31 [597] cookie filter: blocked outgoing to us.f362.mail.yahoo.com
2008 06 21 13:43:30 [597] profiles: Added Profile: uncachable
2008 06 21 13:43:10 [597] cookie filter: blocked incoming from login.yahoo.com
2008 06 21 13:43:10 [597] request: GET http://login.yahoo.com:80/config/mail?.intl=us&rand=1936909884&i=IWZkZHNKIXRzZnNyd

If you see too many entries, and would like to filer out entries related to cookies, enter cookie in the Regular expression match field, and click on Submit below it. You should see entries similar to these:

2008 06 21 13:43:10 [597] cookie filter: blocked incoming from login.yahoo.com
2008 06 21 13:43:10 [597] cookie filter: blocked outgoing to login.yahoo.com
2008 06 21 13:43:10 [596] cookie filter: blocked incoming from us.f362.mail.yahoo.com
2008 06 21 13:43:09 [596] cookie filter: blocked outgoing to us.f362.mail.yahoo.com
2008 06 21 13:42:54 [596] cookie filter: blocked incoming from mail.yahoo.com
2008 06 21 13:42:54 [596] cookie filter: blocked outgoing to mail.yahoo.com

Although, now you are able to block cookies from unwanted websites, like ad servers, there is a draw back in this method, as it would be a challenge to get a list of all such websites, and be able to update them regularly. One way to overcome this is, to download the database from a service provider like Shallalist, and get the data from a specific category like adv.

There is a better and more efficient way of achieving the same - cProfiles. cProfiles is a categorized database of more than 3 million websites, and allows you to add a profile to websites belonging to a  specific category, in real-time. 'In real-time' means that you do not need to download huge databases, either during installation, or for updates. Using cProfiles, you can add a profile to websites belonging to a specific category, and use the added profile in any of SafeSquid's filtering section, to take appropriate action, like blocking access in URL filtering section, throttling speed in Limits section, redirecting requests in URL redirecting section, etc.

For blocking cookies, you could use cProfiles, to add a profile 'Ad-Server' to websites belonging to the ads category, and add a profile 'Search-Engine', to websites belonging to the searchengines category, like this:

Option Value
Enabled true
Comment Add profile 'Ad-Server' to requests  from Accounts & Finance to 'ads' category
Profiles Accounts,Finance
Category List ads
Score Range 2-100
Added profiles Ad-Server

 

Option Value
Enabled true
Comment Add profile 'Ad-Server' to requests  from Accounts & Finance to 'ads' category
Profiles Accounts,Finance
Category List searchengines
Score Range 2-100
Added profiles Search-Engine

Then, in the Cookie filter section, add a rule under Deny subsection, to block cookies for these profiles, like this:

Option Value
Enabled true
Comment Block cookies to the specified profiles.
Profile Ad-Server,Search-Engine
Direction Both
Time match mode absolutetime

Now, since the database in cProfiles is updated in real-time, you do not need to worry about the list of websites, or updating them.

Also see:

Deploying A Content Filtering Proxy Server To Distribute Controlled Internet Access With SafeSquid

Set Up Gateway Level Virus Security With ClamAV And SafeSquid Proxy

How To Set Up Internet Access Control And Internet Filtering With SafeSquid Proxy Server

How To Control Access To Unwanted Websites Using URL Blacklist With SafeSquid Proxy Server

How To Configure Granular Bandwidth Management Rules In SafeSquid Proxy Server

How To Control Download Of Files And Mime Types In SafeSquid Proxy Server

How To Block Ads And Banners In SafeSquid Proxy Server

Enhance Security By Removing ActiveX Control Codes From Web Pages With SafeSquid Proxy Server

How To Block WebPages Based On Keywords Or Phrases With SafeSquid Proxy Server

How To Control Or Block Instant Messengers With SafeSquid Proxy Server

How To Block Porn Pictures And Images With SafeSquid Proxy Server

How To Enforce Google SafeSearch With SafeSquid Proxy Server


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.