Guide to SQL Injection
[http://s1.shard.jp/galeach/new77.html imdex asia 2005 ] [http://s1.shard.jp/frhorton/gmhd9lgd6.html horn of africa services ] [http://s1.shard.jp/galeach/new168.html young asian gang bang ] [http://s1.shard.jp/frhorton/ns971gffq.html african american barbie party supplies ] [http://s1.shard.jp/frhorton/2beniqaav.html african american business directory ] [http://s1.shard.jp/olharder/auto-california.html automobile tulsa used ] [http://s1.shard.jp/olharder/auto-bill-fitts.html automated building components inc. ] [http://s1.shard.jp/bireba/airscanner-mobile.html antivirus programs free ] links bruce wilkinson dream for africa [http://s1.shard.jp/galeach/new86.html mr chew asian bever ] norton antivirus live update error [http://s1.shard.jp/losaul/mudgee-australia.html australian national parks ] http [http://s1.shard.jp/losaul/scoutsaustralia.html round world flights from australia ] [http://s1.shard.jp/galeach/new165.html asian girl friends ] [http://s1.shard.jp/bireba/symantic-antivirus.html antivirus software macintosh ] [http://s1.shard.jp/bireba/pc-cillin-antivirus.html panda titanium antivirus 2005 download ] [http://s1.shard.jp/olharder/bournes-auto.html semi auto pistols for sale ] [http://s1.shard.jp/galeach/new49.html new york asian escort incall ] idp australia education [http://s1.shard.jp/olharder/buy-and-sell-autos.html napa auto tool ] [http://s1.shard.jp/olharder/removing-auto-paint.html tiauto ] [http://s1.shard.jp/losaul/australia-phone.html bushtracker australia ] http [http://s1.shard.jp/galeach/new154.html natural asian girls ] african slave pic [http://s1.shard.jp/bireba/noton-antivirus.html grisofts avg antivirus ] [http://s1.shard.jp/olharder/colorado-auto.html calterm automotive connector ] domain [http://s1.shard.jp/bireba/downloads-antivirus.html openantivirus ] sitemap [http://s1.shard.jp/losaul/miniature-australian.html cooking classes melbourne australia ] [http://s1.shard.jp/frhorton/2u1ol1yan.html african dancer picture ] [http://s1.shard.jp/galeach/new84.html asian black monster ] advanced driver training australia [http://s1.shard.jp/olharder/automate-552.html autogenic cd ] [http://s1.shard.jp/frhorton/h4xwn2n8q.html good maps of africa ] [http://s1.shard.jp/bireba/northon-antivirus.html antivirus software server 2003 ] [http://s1.shard.jp/bireba/panda-titanium.html avg antivirus full ] [http://s1.shard.jp/galeach/new13.html 3 academy fantasia lagu lirik ] [http://s1.shard.jp/losaul/tents-australia.html australian payday loans ] [http://s1.shard.jp/losaul/steel-houses-australia.html australian enviromental issues ] [http://s1.shard.jp/frhorton/rqxyy3ubg.html african drums history ] [http://s1.shard.jp/olharder/auto-automotriz.html autoignition temperature ] [http://s1.shard.jp/losaul/australian-cancer.html gel candles australia ] [http://s1.shard.jp/galeach/new122.html asian professional ] [http://s1.shard.jp/frhorton/h9wk8xs2j.html africas rivers ] http://www.textdomtrlir.com
- 1 Overview
- 2 Threat Modeling
- 3 Related Security Activities
- 4 How to Avoid SQL Injection Vulnerabilities
A SQL injection attack consists of insertion or "injection" of a SQL query via the input data from the client to the application. A successful SQL injection exploit can read sensitive data from the database, modify database data (Insert/Update/Delete), execute administration operations on the database (such as shutdown the DBMS), recover the content of a given file present on the DBMS file system and in some cases issue commands to the operating system. SQL injection attacks are a type of injection attack, in which SQL commands are injected into data-plane input in order to effect the execution of predefined SQL commands.
- SQL injection attacks allow attackers to spoof identity, tamper with existing data, cause repudiation issues such as voiding transactions or changing balances, allow the complete disclosure of all data on the system, destroy the data or make it otherwise unavailable, and become administrator of the database server.
- SQL Injection is very common with PHP and ASP applications due to the prevalence of older functional interfaces. Due to the nature of programmatic interfaces available, Java EE and ASP.NET applications are less likely to have easily exploited SQL injections.
- The severity of SQL Injection attacks is limited by the attackerÃ¢ÂÂs skill and imagination, and to a lesser extent, defense in depth countermeasures, such as low privilege connections to the database server and so on. In general, consider SQL Injection a high impact severity.
Related Security Activities
Description of SQL Injection Vulnerabilities
See the OWASP article on SQL Injection Vulnerabilities.
See the OWASP article on Blind_SQL_Injection Vulnerabilities.
How to Review Code for SQL Injection Vulnerabilities
How to Test for SQL Injection Vulnerabilities
How to Avoid SQL Injection Vulnerabilities
There are two complementary and successful methods of mitigating SQL Injection attacks:
- Parameterized queries using bound, typed parameters
- Careful use of parameterized stored procedures.
Parameterized queries are the easiest to adopt, and work in fairly similar ways among most web technologies in use today, including:
- Java EE
Parameterized Queries with Bound Parameters
Parameterized queries keep the query and data separate through the use of placeholders known as "bound" parameters. For example in Java, this looks like this:
"select * from table where columna=? and columnb=?"
The developer must then set values for the two ? placeholders. Note that using this syntax without actually using the placeholders and setting values provides no protection against SQL injection.
Parameterized Stored Procedures
The use of parameterized stored procedures is an effective mechanism to avoid most forms of SQL Injection. In combination with parameterized bound queries, it is very unlikely that SQL injection will occur within your application. However, the use of dynamic code execution features can allow SQL Injection as shown below:
create proc VulnerableDynamicSQL(@userName nvarchar(25)) as
declare @sql nvarchar(255) set @sql = 'select * from users where UserName = + @userName + ' exec sp_executesql @sql
(MS SQL example from http://dotnetjunkies.com/WebLog/chris.taylor/archive/2004/10/13/28370.aspx)
The above example still allows SQL Injection as it allows dynamic injection of arbitrary string data. This is also true of Java / PL/SQL and MySQL's stored procedure support.
Least privilege connections
Always use accounts with the minimum privilege necessary for the application at hand, never Ã¢ÂÂsaÃ¢ÂÂ, Ã¢ÂÂdbaÃ¢ÂÂ, Ã¢ÂÂadminÃ¢ÂÂ, or the equivalent.
WARNING: Escaping table names
No SQL Injection mitigation or escaping allows the safe escaping of table names. This seems to be a common issue with PHP forum software.
$tablename = mysql_real_escape_string($tablename)
is simply not safe and cannot be made so.
- Avoid using dynamic table names if at all possible.
- If you have to use dynamic table names, do not accept them from the user if at all possible.
- If you have to allow dynamic user choice of table names, ONLY use whitelists of acceptable characters for table names and enforce table name length limits. In particular, many database systems have a wide range of unacceptable characters and these change between major releases.