Recently a client of ours, who hosts their own ecommerce solution on our servers, called and asked us to take a look at their web site. They said odd things seemed to be happening up there: pages were distorted, dropdown lists had incorrect information in them and some parts of pages just weren't showing up. The first thing that came to mind was that their site might have been hacked. We took a look at the site and what we saw pretty much aligned with our hunch: we saw some stray HTML for some javascript script tags showing up in unusual places, which was skewing the layout and preventing some functionality. It looked like most of the places where those were appearing were probably content that came from their ecommerce database.
We pulled the site offline so we could analyze what we saw and prevent things from getting potentially worse. A quick search on google, using some words from the stray HTML we saw on the site's pages, resulted in us finding that hundreds of thousands of other sites also had the same issue. So many sites had the issue that it was actually hard to find information about the root cause of the issue, since all the searches brough up 'infected' sites.
We analyzed the web and database server logs, looking for signs of a
"SQL Injection" attack, which is a kind of attack that forces it's way into a database and modifies records with malicious intent. We found a few partially encrypted web server requests in the web logs and decrypted them to see what they contained. What we found was indeed a SQL injection attack. The injection attack located "text fields" in the database and wrote the HTML script tags that we saw on the site into every single text field. It also truncated (shortened) the text in each field, basically mangling the data.
A pretty bad attack.
We then commenced a recovery effort, using the decrypted injection attack as a model for identifying all of the affected data. We created some data recovery scripts, using a combination of the reverse-engineered injection attack and a recent backup of the system's database. Our script was able to scrub the injected text out of the affected database tables and restore the data from before the injection attack back to the state it was in before the attack. Our client fortunately also had a secondary database replicating some data to the web database. Using the replication we were able to add another layer of recovery for the affected data.
In the end the bulk of the data was recovered and the injection attack was scrubbed out of the database.
Before we turned the system back on, we also put in place a custom asp.net module that we developed in-house to prevent these kinds of injection attacks. It provides additional protection for sites that need it, specifically targeting these kinds of SQL injection attacks. The module works for asp.net 1.x through 3.5 (latest version) web sites and can be applied as a simple add-on without having to touch the original site. For more information about this module, please feel free to
contact us.
As seen from the hundreds of thousands of sites that we found via google that were also affected by this attack, there are many vulnerable sites out there. As a general practice we build sites using techniques that prevent these kinds of attacks, but it's clear that the 'attack area' on the net is very large. We hope that a hard lesson learned by the affected sites will lead to closing of many of these holes. If you have any concerns that your web site may have a vulnerability like this, please
contact us. We can help you assess your site and consult with you about how to protect yourself from this kind of attack.
48ce993e-1f7b-4026-bd7c-211a00b7b8b7|2|4.0