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:
One common defense is to double up any single quotation marks appearing within user input before incorporating that input into a SQL query. This defense is designed to prevent malformed data from terminating the string in which it is inserted. However, if the data being incorporated into queries is numeric, then the defense may fail, because numeric data may not be encapsulated within quotes, in which case only a space is required to break out of the data context and interfere with the query. Further, in second-order SQL injection attacks, data that has been safely escaped when initially inserted into the database is subsequently read from the database and then passed back to it again. Quotation marks that have been doubled up initially will return to their original form when the data is reused, allowing the defense to be bypassed.
Another often cited defense is to use stored procedures for database access. While stored procedures can provide security benefits, they are not guaranteed to prevent SQL injection attacks. The same kinds of vulnerabilities that arise within standard dynamic SQL queries can arise if any SQL is dynamically constructed within stored procedures. Further, even if the procedure is sound, SQL injection can arise if the procedure is invoked in an unsafe manner using user-controllable data.
The REST URL parameter 1 appears to be vulnerable to SQL injection attacks. A single quote was submitted in the REST URL parameter 1, and a general error message was returned. Two single quotes were then submitted and the error message disappeared. 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 application attempts to block SQL injection attacks but this can be circumvented by double URL-encoding the blocked characters - for example, by submitting %2527 instead of the ' character.
Remediation detail
There is probably no need to perform a second URL-decode of the value of REST URL parameter 1 as the web server will have already carried out one decode. In any case, the application should perform its input validation after any custom canonicalisation has been carried out.
HTTP/1.1 404 Not Found Server: None Content-Type: text/html Content-Length: 7602 Vary: Accept-Encoding Date: Sat, 20 Nov 2010 04:11:26 GMT Connection: close
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-us" xml:lang="en-us"> <head> <ti ...[SNIP]... hu, 01-Jan-70 00:00:01 GMT"; } } strLowcase=getCookie('lowcase'); if (strLowcase!=null) // If the cookie exists, the adress has been converted to lowercase and still results in a 404-error { //document.write("<a href='/' target='_top'> ...[SNIP]...
HTTP/1.1 404 Not Found Server: Sun-Java-System-Web-Server/7.0 Content-Type: text/html Content-Length: 386 Vary: Accept-Encoding Date: Sat, 20 Nov 2010 04:11:26 GMT Connection: close
<HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=ISO-8859-1"><TITLE>Not Found</TITLE></HEAD> <H1>Not Found</H1> The requested object does not exist on this server. The link you followe ...[SNIP]...
The REST URL parameter 2 appears to be vulnerable to SQL injection attacks. A single quote was submitted in the REST URL parameter 2, and a general error message was returned. Two single quotes were then submitted and the error message disappeared. 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 application attempts to block SQL injection attacks but this can be circumvented by double URL-encoding the blocked characters - for example, by submitting %2527 instead of the ' character.
Remediation detail
There is probably no need to perform a second URL-decode of the value of REST URL parameter 2 as the web server will have already carried out one decode. In any case, the application should perform its input validation after any custom canonicalisation has been carried out.
HTTP/1.1 404 Not Found Server: None Content-Type: text/html Content-Length: 7602 Vary: Accept-Encoding Date: Sat, 20 Nov 2010 04:11:28 GMT Connection: close
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-us" xml:lang="en-us"> <head> <ti ...[SNIP]... hu, 01-Jan-70 00:00:01 GMT"; } } strLowcase=getCookie('lowcase'); if (strLowcase!=null) // If the cookie exists, the adress has been converted to lowercase and still results in a 404-error { //document.write("<a href='/' target='_top'> ...[SNIP]...
HTTP/1.1 404 Not Found Server: Sun-Java-System-Web-Server/7.0 Content-Type: text/html Content-Length: 386 Vary: Accept-Encoding Date: Sat, 20 Nov 2010 04:11:29 GMT Connection: close
<HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=ISO-8859-1"><TITLE>Not Found</TITLE></HEAD> <H1>Not Found</H1> The requested object does not exist on this server. The link you followe ...[SNIP]...
The REST URL parameter 3 appears to be vulnerable to SQL injection attacks. A single quote was submitted in the REST URL parameter 3, and a general error message was returned. Two single quotes were then submitted and the error message disappeared. 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 application attempts to block SQL injection attacks but this can be circumvented by double URL-encoding the blocked characters - for example, by submitting %2527 instead of the ' character.
Remediation detail
There is probably no need to perform a second URL-decode of the value of REST URL parameter 3 as the web server will have already carried out one decode. In any case, the application should perform its input validation after any custom canonicalisation has been carried out.
HTTP/1.1 404 Not Found Server: None Content-Type: text/html Content-Length: 7602 Vary: Accept-Encoding Date: Sat, 20 Nov 2010 04:11:32 GMT Connection: close
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-us" xml:lang="en-us"> <head> <ti ...[SNIP]... hu, 01-Jan-70 00:00:01 GMT"; } } strLowcase=getCookie('lowcase'); if (strLowcase!=null) // If the cookie exists, the adress has been converted to lowercase and still results in a 404-error { //document.write("<a href='/' target='_top'> ...[SNIP]...
HTTP/1.1 404 Not Found Server: Sun-Java-System-Web-Server/7.0 Content-Type: text/html Content-Length: 386 Vary: Accept-Encoding Date: Sat, 20 Nov 2010 04:11:32 GMT Connection: close
<HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=ISO-8859-1"><TITLE>Not Found</TITLE></HEAD> <H1>Not Found</H1> The requested object does not exist on this server. The link you followe ...[SNIP]...
The REST URL parameter 1 appears to be vulnerable to SQL injection attacks. A single quote was submitted in the REST URL parameter 1, and a general error message was returned. Two single quotes were then submitted and the error message disappeared. 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 application attempts to block SQL injection attacks but this can be circumvented by double URL-encoding the blocked characters - for example, by submitting %2527 instead of the ' character.
Remediation detail
There is probably no need to perform a second URL-decode of the value of REST URL parameter 1 as the web server will have already carried out one decode. In any case, the application should perform its input validation after any custom canonicalisation has been carried out.
HTTP/1.1 404 Not Found Server: None Content-Type: text/html Content-Length: 7602 Vary: Accept-Encoding Date: Sat, 20 Nov 2010 04:13:08 GMT Connection: close
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-us" xml:lang="en-us"> <head> <ti ...[SNIP]... hu, 01-Jan-70 00:00:01 GMT"; } } strLowcase=getCookie('lowcase'); if (strLowcase!=null) // If the cookie exists, the adress has been converted to lowercase and still results in a 404-error { //document.write("<a href='/' target='_top'> ...[SNIP]...
HTTP/1.1 404 Not Found Server: Sun-Java-System-Web-Server/7.0 Content-Type: text/html Content-Length: 386 Vary: Accept-Encoding Date: Sat, 20 Nov 2010 04:13:09 GMT Connection: close
<HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=ISO-8859-1"><TITLE>Not Found</TITLE></HEAD> <H1>Not Found</H1> The requested object does not exist on this server. The link you followe ...[SNIP]...
The REST URL parameter 2 appears to be vulnerable to SQL injection attacks. A single quote was submitted in the REST URL parameter 2, and a general error message was returned. Two single quotes were then submitted and the error message disappeared. 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 application attempts to block SQL injection attacks but this can be circumvented by double URL-encoding the blocked characters - for example, by submitting %2527 instead of the ' character.
Remediation detail
There is probably no need to perform a second URL-decode of the value of REST URL parameter 2 as the web server will have already carried out one decode. In any case, the application should perform its input validation after any custom canonicalisation has been carried out.
HTTP/1.1 404 Not Found Server: None Content-Type: text/html Content-Length: 7602 Vary: Accept-Encoding Date: Sat, 20 Nov 2010 04:13:13 GMT Connection: close
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-us" xml:lang="en-us"> <head> <ti ...[SNIP]... hu, 01-Jan-70 00:00:01 GMT"; } } strLowcase=getCookie('lowcase'); if (strLowcase!=null) // If the cookie exists, the adress has been converted to lowercase and still results in a 404-error { //document.write("<a href='/' target='_top'> ...[SNIP]...
HTTP/1.1 404 Not Found Server: Sun-Java-System-Web-Server/7.0 Content-Type: text/html Content-Length: 386 Vary: Accept-Encoding Date: Sat, 20 Nov 2010 04:13:13 GMT Connection: close
<HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=ISO-8859-1"><TITLE>Not Found</TITLE></HEAD> <H1>Not Found</H1> The requested object does not exist on this server. The link you followe ...[SNIP]...
If a web response states that it contains HTML content but does not specify a character set, then the browser may analyse the HTML and attempt to determine which character set it appears to be using. Even if the majority of the HTML actually employs a standard character set such as UTF-8, the presence of non-standard characters anywhere in the response may cause the browser to interpret the content using a different character set. This can have unexpected results, and can lead to cross-site scripting vulnerabilities in which non-standard encodings like UTF-7 can be used to bypass the application's defensive filters.
In most cases, the absence of a charset directive does not constitute a security flaw, particularly if the response contains static content. You should review the contents of the response and the context in which it appears to determine whether any vulnerability exists.
Issue remediation
For every response containing HTML content, the application should include within the Content-type header a directive specifying a standard recognised character set, for example charset=ISO-8859-1.
Request
GET /scripts/globalnav/blank.html HTTP/1.1 Host: cache.vzw.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close Cookie: V1Z2=CT;
Response
HTTP/1.1 200 OK Server: None Content-Type: text/html Last-Modified: Sun, 26 Aug 2007 03:18:13 GMT ETag: "f-46d0f0f5" Date: Sat, 20 Nov 2010 04:10:41 GMT Content-Length: 15 Connection: close
<html></html>
Report generated by Hoyt LLC Research
at Fri Nov 19 22:59:29 CST 2010.