Single Quote, SQL Injection, MySQL Error Message, Information Exposure, CWE-89

CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')

Report generated by CloudScan Vulnerability Crawler at Sun Feb 27 16:35:25 CST 2011.

The DORK Report


1. SQL injection

1. SQL injection


Severity:   High
Confidence:   Firm
Path:   /Portfolio/Trades-and-Exhibits/id-24/page-1/

Issue detail

The REST URL parameter 3 appears to be vulnerable to SQL injection attacks. The payload ' was submitted in the REST URL parameter 3, and a database error message was returned. You should review the contents of the error message, and the application's handling of other input, to confirm whether a vulnerability is present.

The database appears to be MySQL.

Remediation detail

The application should handle errors gracefully and prevent SQL error messages from being returned in responses.

Issue background

SQL injection vulnerabilities arise when user-controllable data is incorporated into database SQL queries in an unsafe manner. An attacker can supply crafted input to break out of the data context in which their input appears and interfere with the structure of the surrounding query.

Various attacks can be delivered via SQL injection, including reading or modifying critical application data, interfering with application logic, escalating privileges within the database and executing operating system commands.

Remediation background

The most effective way to prevent SQL injection attacks is to use parameterised queries (also known as prepared statements) for all database access. This method uses two steps to incorporate potentially tainted data into SQL queries: first, the application specifies the structure of the query, leaving placeholders for each item of user input; second, the application specifies the contents of each placeholder. Because the structure of the query has already defined in the first step, it is not possible for malformed data in the second step to interfere with the query structure. You should review the documentation for your database and application platform to determine the appropriate APIs which you can use to perform parameterised queries. It is strongly recommended that you parameterise every variable data item that is incorporated into database queries, even if it is not obviously tainted, to prevent oversights occurring and avoid vulnerabilities being introduced by changes elsewhere within the code base of the application.

You should be aware that some commonly employed and recommended mitigations for SQL injection vulnerabilities are not always effective:


GET /Portfolio/Trades-and-Exhibits/id-24'/page-1/ HTTP/1.1
Accept: */*
Accept-Language: en
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)
Connection: close
Cookie:|utmccn=(referral)|utmcmd=referral|utmcct=/about-us/; __utma=249072581.1903656466.1298752883.1298752883.1298757236.2; __utmc=249072581; __utmb=249072581.1.10.1298757236;


HTTP/1.1 200 OK
Date: Sat, 26 Feb 2011 23:18:56 GMT
Server: Apache/2.2.14 (Unix) FrontPage/
X-Powered-By: PHP/5.2.13
Connection: close
Content-Type: text/html
Content-Length: 14497


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<title>Trades and Exhibits :: STI - Creative Services</title>

<script type="text/javascript" language="javascript
</b>: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in <b>

Report generated by CloudScan Vulnerability Crawler at Sun Feb 27 16:35:25 CST 2011.