Anatomy Of A SQL Injection Attack

SQL injection has plagued databases for years. Here's a look at how the attacks work -- and what you can do about them

Brian Prince, Contributing Writer, Dark Reading

October 1, 2013

3 Min Read
Dark Reading logo in a gray background | Dark Reading

[The following is excerpted from "Anatomy Of A SQL Injection Attack," a new report posted this week on Dark Reading's Database Security Tech Center.]

It started with a vulnerability on a password reminder page and ended with a compromise of Nasdaq's computer network. Such is the life of a SQL injection vulnerability, one of the most prevalent and well-known classes of security flaws affecting organizations today.

A seemingly permanent fixture on the Open Web Application Security Project's list of top 10 Web application vulnerabilities, SQL injection has a long history as a weapon for the world's black hats to blast their way into corporate databases. In July, the U.S. Justice Department announced an indictment against five men accused of stealing more than 160 million credit card numbers and causing hundreds of millions of dollars in losses in attacks on more than a dozen organizations, including the one on Nasdaq.

The stakes cannot get much higher. According to Trustwave's "2013 Global Security Report," SQL injections accounted for 26 percent of the infiltration methods used by hackers in the data breaches it analyzed in 2012.

Fighting these attacks means more than just understanding where flaws lie in the code. It also means understanding the cyber kill chain -- the life cycle of the attacks targeting the corporate network. Armed with that knowledge, organizations can begin totake a smarter approach to defending their databases and making sure the Web applications that access them don't serve as unguarded gateways for attackers.

Put simply, SQL injection is a technique in which the attacker uses a vulnerability in the code to send malicious SQL statements to a database. This happens when user input that's not properly filtered and validated is utilized in SQL queries to databases accessible by vulnerable applications. There are multiple types of SQL injection attacks, with these two types being the most common categories:

In error-based SQL injection, the attacker forces the database to perform an operation that will result in an error, and then examines the error message for information that can be used to build a working exploit with the correct syntax. Organizations often seek to mitigate this by limiting the amount of information contained in error messages.

Blind SQL injection attacks are used when vulnerable applications are configured to show generic error messages. In this approach, the attacker asks the database a true or false question and examines the application's response. If the response is different, the attacker can determine whether or not the database has been successfully accessed.

Attackers have a number of different exploit methodologies at their disposal. For example, attackers sometimes use a method known as time-based blind SQL injection, which involves getting the database to pause for a specific period of time, and then comparing the response times between normal requests and injected requests to determine if a SQL statement was successfully executed.

To learn more about SQL injection attacks -- and how to prevent them -- download the free report.

Have a comment on this story? Please click "Add a Comment" below. If you'd like to contact Dark Reading's editors directly, send us a message.

About the Author

Brian Prince

Contributing Writer, Dark Reading

Brian Prince is a freelance writer for a number of IT security-focused publications. Prior to becoming a freelance reporter, he worked at eWEEK for five years covering not only security, but also a variety of other subjects in the tech industry. Before that, he worked as a news reporter for the Asbury Park Press, and reported on everything from environmental issues to politics. He has a B.A. in journalism from American University.

Keep up with the latest cybersecurity threats, newly discovered vulnerabilities, data breach information, and emerging trends. Delivered daily or weekly right to your email inbox.

You May Also Like


More Insights