Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Suppose a system authenticates users by issuing the following query to a SQL database. If the query returns any results, authentication succeeds; otherwise, authentication fails.

Code Block
languagesql
SELECT * FROM db_user WHERE username='<USERNAME>' AND 
                            password='<PASSWORD>'

Suppose an attacker can substitute arbitrary strings for <USERNAME> and <PASSWORD>. In that case, the authentication mechanism can be bypassed by supplying the following <USERNAME> with an arbitrary password:

Code Block
languagesql
validuser' OR '1'='1

The authentication routine dynamically constructs the following query:

Code Block
languagesql
SELECT * FROM db_user WHERE username='validuser' OR '1'='1' AND password='<PASSWORD>'

...

Similarly, an attacker could supply the following string for <PASSWORD> with an arbitrary username:

Code Block
languagesql
' OR '1'='1

producing the following query:

Code Block
languagesql
SELECT * FROM db_user WHERE username='<USERNAME>' AND password='' OR '1'='1'

...

ToolVersionCheckerDescription
The Checker Framework

Include Page
The Checker Framework_V
The Checker Framework_V

Tainting CheckerTrust and security errors (see Chapter 8)
CodeSonar
Include Page
CodeSonar_V
CodeSonar_V

JAVA.IO.INJ.SQL

SQL Injection (Java)

Coverity7.5

SQLI
FB.SQL_PREPARED_STATEMENT_GENERATED_

FB.SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE

Implemented
Findbugs1.0SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTEImplemented
Fortify1.0

HTTP_Response_Splitting
SQL_Injection__Persistence
SQL_Injection

Implemented
Klocwork

SV.DATA.BOUND
SV.DATA.DB
SV.HTTP_SPLIT
SV.PATH
SV.PATH.INJ
SV.SQL

Implemented
Parasoft Jtest
Include Page
Parasoft_V
Parasoft_V
CERT.IDS00.TDSQLProtect against SQL injection
SonarQube
Include Page
SonarQube_V
SonarQube_V

S2077

S3649

Executing SQL queries is security-sensitive

SQL queries should not be vulnerable to injection attacks

SpotBugs

Include Page
SpotBugs_V
SpotBugs_V

SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE
SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING

Implemented

Related Vulnerabilities

...