Please wait while the page is being loaded Skip this advertisement >
Thursday | 4 December, 2008
Anatomy of a SQL injection attack
This vendor-written tech primer has been edited to eliminate product promotion, but readers should note it will likely favor the submitter's approach.
Ryan Barnett (Network World) 10/10/2008 09:49:00

While there are a number of security risks in the world of electronic commerce, SQL injection is one of the most common Web site attack techniques used to steal customer data such as credit card numbers, hold customer data hostage by encrypting it or destroy data outright.

Where a Web server only understands and speaks the HTTP protocol, a database's native tongue is Structured Query Language (SQL), which is essentially a set of command statements that instruct a database to execute specific actions. Every database server has a similar series of commands to query its tables, narrow down results to a few specific entries, and combine information from one table to another.

Here is an example SQL query:

SELECT -- FROM users WHERE Email = '" + Email + "' AND Password = '" + Password + "';

The WHERE specifies a condition, that an e-mail address and password combination match data present in the "users" table. When this command is given to the database server, it returns true if a match is found and a false if there is no match.

When clients send data on the Web, they use URLs and forms to assemble the database query statements. The following URL represents an example login page for a Web application:

GET /shopping_cart/login.asp?Email=jdoe@example.com&Password=$ecret123 HTTP/1.1

This URL shows that the destination application is a Microsoft ASP page and it is accepting two parameters, one called "Email" and the other called "Password." If the user credentials are correct then the result of this query will provide response data that represents a successful authentication and will be used to allow the client to proceed to the corresponding Web page.

Developers of traditional application code generally trust user input. They believe that database queries are coming from a trusted source, namely the database server itself, rather than from an untrusted user's Web browser. SQL injection is an attack technique where an untrusted user inserts SQL query data into input fields sent to back-end databases in an attempt to trick the database into executing the commands.

The Web application firewall in the example was configured in a "detection only" mode where it was logging alerts and events but not blocking any inbound attacks or outbound data leakages. Due to this configuration, the inbound SQL injection attack from the previous section was allowed to continue on to the vulnerable Web application when it would have been blocked.

The Web page returned indicates that the SQL injection reconnaissance probe was successful, giving the hacker valuable information, including the exact version of the database and the database user. Armed with this information, the attacker can fine tune the attack and execute further reconnaissance probes to enumerate more information about the database itself, such as the table and column names. After a number of intermediary reconnaissance probes, the attacker has the information needed to send a complex SQL injection attack, attempting to extract customer record details. By targeting specific customer data such as credit card name, expiration data and security code, the attacker can extract a vast amount of sensitive customer data.

Additional Resources
Executive Guides
Whitepapers
Zones
Zone logoZones provide focussed content from Computerworld and leading technology partners.
Newsletter Subscription
Sign up for our Computerworld newsletters!
RSS Feeds
Market Place

 
CA Knowledge Centre

Security Management

Protect your critical IT assets, achieve sustainable regulatory compliance, reduce IT administration costs and enable new business opportunities with our IT security solutions.

IT Security as a business enabler?
Download Whitepaper

CA Knowledge Centre

Success Stories


Australian Unity minimises costs and maximises productivity with single sign-on for 1,400 users
Australian Unity needed to address its business and security risks including user management and application security management. The company chose an enterprise single sign-on (ESSO) solution and discovered increased employee productivity, reduced help desk costs and elevated data protection.
Download the full Success Story


BT saves more than £15 million and improves customer services with comprehensive Identity & Access Management
To enable future growth and ensure its services remain competitive, BT needed to build closer relationships with its customers and suppliers. Discover how the company is now performing over 36 million transactions a day with their improved Identity & Access Management Solution.
Download the full Success Story


Identity & Access Management


Simplify and Secure: Managing User Identities Throughout their Lifecycles
Organisations are constantly challenged to keep pace with ongoing changes to users and their roles, responsibilities and requirements. Discover how CA can help you create a unified approach for managing users identities, providing them with timely and appropriate access to applications and information.
Download Whitepaper


Simplify, Integrate and Safeguard Your Business with Secure Web Business Enablement
Modern organisations are required to aggressively expand the number and type of Web applications and services provided to customers, partners and employees. Discover how to automate, delegate and centralise your key processes and services including user administration, access policies, auditing and compliance by reading on.
Download Whitepaper


Simplify, Integrate and Secure: Providing Secure Access to Server-based Information and Resources Across Platforms
Distributed servers are a powerful asset in any company’s infrastructure. Over time, most organisations have acquired a variety of different platforms and are relying on them to house an increased amount of critical applications, processes and data. Read on to discover how you can achieve a consistently higher level of server access security across multiple platforms including virtual hosts and guest operating systems.
Download Whitepaper

Enterprise IT Buyer's Guide
Find Technology Vendors Fast
 
Find vendors by name | Find by category
Sponsored Links