Skip navigation.

Prepare!

Lee Harvey's Zombie Hit Parade

Proxy Automatic Config (PAC) File Tips

, ,

I was recently involved in our corporate overhaul of our proxy automatic config (.pac) file. Below are some tips if you ever have to do the same. Since some older clients or custom apps may have poor JavaScript support, or may be considered non-standard, thus:

* Always check url and host parameters prior to using them.
* Validate all built-in JS functions exist prior to calling them.
* Keep the .pac file size as small as possible, to improve download speed.
* Keep comments to a minimum, per above.
* Since "return" is immediate, avoid using "else" for "if" statements, per above.
* Single-line if() statements do not require begin { and end } brackets, per above.
* Avoid calling isResolvable(), dnsResolve(), and isInNet() functions, due to DNS performance issues.
* Check simple rule exceptions first.
* Place high-probability checks early-on and nearest top.
* Avoid using any external or global vars/functions.
* Since .pac files are text and can be downloaded/viewed by anyone, avoid revealing secrets.
* For security reasons, avoid referencing clients by IP addresses.
* Use efficient regular expressions, and avoid capturing matches if you don't reference them later on.
* To avoid typos, only declare unique return strings once (near top for easy maintenance).
* When possible, sort lists of IP addresses and/or domains to ease future maintenance efforts.
* Try to group common return values into single conditional if() checks.
* For single proxy server environments, return the proxy's static IP address to bypass DNS lookup overhead.
* Ensure your text file encoding is proper for your hosting server environment.
* If checking IPs or domains, avoid protocol-specific string comparisons against the url parameter.
* Randomized proxy load-balancing via pac files is not recommended.
* Keep in mind that server access is either proxied or not. Thus, checking ports and protocols is typically not required.
* Be sure to check all conditions and exceptions listed in your .pac file prior to deployment.
* Obviously, ensure your JavaScript is error-free prior to deployment.

Hope this helps. Enjoy.

Funny: eWEEK.com Security Center Editor drops F-bomb on public mailing listTry..Catch..Finally in ... VBScript? Sure!

Comments

amg7 21. January 2009, 18:06

I am in the same position as you were. I have looked far and wide on opinions and security angles to writing .pac files. In fact i have signed up to this forum specifically to reply to this thread. Is this something you still keep up with?

I am new at this but very interested. Would you mind a few questions?

Lee Harvey 22. January 2009, 00:59

Sure, I don't mind.

Write a comment

You must be logged in to write a comment. If you're not a registered member, please sign up.