The Virtues of WAF Egress
Friday, June 8th, 2007I’ve been thinking about this for a long time, and I haven’t seen anyone else talk about it, so here goes. As anyone who’s read this site for any length of time knows, I’ve never had much of a soft spot in my heart for web application firewalls for various reasons: cost, false positives, false negatives, can fail to fix the problem completely, etc…. However, recently I’ve been asked to look at more and more people’s technology (as part of our consulting practice) and decide what I do and don’t like. I was talking to a new startup a week or two ago about their new WAF appliance that they are building and all the virtues, blah blah. Of course I had to start punching holes in it the second I heard the concept, “What about DOM based XSS?” The CEO replies, “No idea.” Hurray, I win! Or did I?
The problem with DOM based XSS is that it isn’t actually sent to the server (in most cases - and those are the cases I’m interested in for this problem). Generally those fall into anchor tags like, http://example.com#exploit-goes-here The anchor tag is not sent to the server (as we found during the UXSS in Adobe reader in Firefox). Try as they might, all the King’s horses and all the King’s WAFs couldn’t write rules to block it inbound, all they could do is modify the mime types to deliver the payload more securely. There were lessons learned there, but let’s focus on DOM based XSS in JavaScript, rather than in client side technologies for a moment.
Knowing that we can’t stop DOM based XSS at the server level because it can’t see it, nor can it be seen at the network level, short of auditing the code, all we really can do is wait for someone to exploit it and then re-write the code. But therein lies a problem with all patching. In many cases it’s deathly slow. So why not set up an egress filter on a WAF to programmatically change the JavaScript in transit to be safe? Think about it, if you know you have an insecure function on a page, but it will take 6 weeks of building tickets, fixing the bug, testing, deploying, or a ten minute change on a WAF, that’s a huge value in time savings.
There’s one more advantage to this - if you can set the egress filter to deliver specific content to specific IP addresses, you can actually use the WAF filter to test the changes you are suggesting to your developers ahead of time. Often security guys know how to make the changes better than anyone, so if they can deploy the change in the WAF, test it themselves before it rolls out to anyone else, they’ve reduced the risk of a global deployment of code that failed the fix the problem, or worse yet, code that completely breaks the functionality of the site in some way.
There are other virtues, like if you see database strings that clearly shouldn’t ever appear, like ODBC errors, you could completely block the output, etc… Don’t get too excited, I’m still not on the WAF bandwagon, but I’m starting to see more interesting applications for it, above and beyond a simple short term inbound patching mechanism.


