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 mt_clk cookie appears to be vulnerable to SQL injection attacks. A single quote was submitted in the mt_clk cookie, and a database 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 database appears to be MySQL.
Remediation detail
The application should handle errors gracefully and prevent SQL error messages from being returned in responses.
Request 1
GET /mt/03745344/&subid1=MQExit&subid2=CD99&subid3=409&web_id=e99MQExit&orig=CD99&s=MQExit&c=409 HTTP/1.1 Host: www.pixeltrack66.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close Cookie: mt_clk=54267db83a49b89cd0644d669488302a'; mt_lds=54267db83a49b89cd0644d669488302a; PHPSESSID=vcnvs4i5j3pnkunpsl190rd6p6;
Response 1
HTTP/1.1 200 OK Date: Sun, 09 Jan 2011 05:13:51 GMT Server: Apache/2.2.3 (Red Hat) X-Powered-By: PHP/5.2.9 P3P: CP="ALL DSP COR CURa ADMa DEVa TAIa IVAi IVDi CONi HISi TELi OUR IND PHY ONL FIN COM NAV INT DEM GOV" Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Set-Cookie: mt_imp=54267db83a49b89cd0644d669488302a%27; path=/ Connection: close Content-Type: text/html; charset=UTF-8 Content-Length: 202
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''54267db83a49b89cd0644d669488302a'' and record_adjust2=1' at line 2
Request 2
GET /mt/03745344/&subid1=MQExit&subid2=CD99&subid3=409&web_id=e99MQExit&orig=CD99&s=MQExit&c=409 HTTP/1.1 Host: www.pixeltrack66.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close Cookie: mt_clk=54267db83a49b89cd0644d669488302a''; mt_lds=54267db83a49b89cd0644d669488302a; PHPSESSID=vcnvs4i5j3pnkunpsl190rd6p6;
Response 2
HTTP/1.1 302 Found Date: Sun, 09 Jan 2011 05:13:51 GMT Server: Apache/2.2.3 (Red Hat) X-Powered-By: PHP/5.2.9 P3P: CP="ALL DSP COR CURa ADMa DEVa TAIa IVAi IVDi CONi HISi TELi OUR IND PHY ONL FIN COM NAV INT DEM GOV" Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Set-Cookie: mt_imp=54267db83a49b89cd0644d669488302a%27%27; path=/ Location: http://www.yourpurecrushes.com/hv1/blender_redirect.php?web_id=CD1&&web_id=e99MQExit&orig=CD99&s=MQExit&c=409 Content-Length: 0 Connection: close Content-Type: text/html; charset=UTF-8
The mt_clk cookie appears to be vulnerable to SQL injection attacks. A single quote was submitted in the mt_clk cookie, and a database 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 database appears to be MySQL.
Remediation detail
The application should handle errors gracefully and prevent SQL error messages from being returned in responses.
Request 1
GET /mt/03745344/&subid1=MQExit&subid2=CD99&subid3=409&web_id=e99MQExitPop&orig=CD99&s=MQExit&c=409 HTTP/1.1 Host: www.pixeltrack66.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close Cookie: mt_clk=54267db83a49b89cd0644d669488302a'; mt_lds=54267db83a49b89cd0644d669488302a; PHPSESSID=vcnvs4i5j3pnkunpsl190rd6p6;
Response 1
HTTP/1.1 200 OK Date: Sun, 09 Jan 2011 05:14:02 GMT Server: Apache/2.2.3 (Red Hat) X-Powered-By: PHP/5.2.9 P3P: CP="ALL DSP COR CURa ADMa DEVa TAIa IVAi IVDi CONi HISi TELi OUR IND PHY ONL FIN COM NAV INT DEM GOV" Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Set-Cookie: mt_imp=54267db83a49b89cd0644d669488302a%27; path=/ Connection: close Content-Type: text/html; charset=UTF-8 Content-Length: 202
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''54267db83a49b89cd0644d669488302a'' and record_adjust2=1' at line 2
Request 2
GET /mt/03745344/&subid1=MQExit&subid2=CD99&subid3=409&web_id=e99MQExitPop&orig=CD99&s=MQExit&c=409 HTTP/1.1 Host: www.pixeltrack66.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close Cookie: mt_clk=54267db83a49b89cd0644d669488302a''; mt_lds=54267db83a49b89cd0644d669488302a; PHPSESSID=vcnvs4i5j3pnkunpsl190rd6p6;
Response 2
HTTP/1.1 302 Found Date: Sun, 09 Jan 2011 05:14:02 GMT Server: Apache/2.2.3 (Red Hat) X-Powered-By: PHP/5.2.9 P3P: CP="ALL DSP COR CURa ADMa DEVa TAIa IVAi IVDi CONi HISi TELi OUR IND PHY ONL FIN COM NAV INT DEM GOV" Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Set-Cookie: mt_imp=54267db83a49b89cd0644d669488302a%27%27; path=/ Location: http://www.yourpurecrushes.com/hv1/blender_redirect.php?web_id=CD1&&web_id=e99MQExitPop&orig=CD99&s=MQExit&c=409 Content-Length: 0 Connection: close Content-Type: text/html; charset=UTF-8
The mt_clk cookie appears to be vulnerable to SQL injection attacks. A single quote was submitted in the mt_clk cookie, and a database 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 database appears to be MySQL.
Remediation detail
The application should handle errors gracefully and prevent SQL error messages from being returned in responses.
Request 1
GET /mt/x2a40344g4q2/&subid1=MQThankYou&subid2=CD99&subid3=409&subid4= HTTP/1.1 Host: www.pixeltrack66.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close Cookie: mt_clk=54267db83a49b89cd0644d669488302a'; mt_lds=54267db83a49b89cd0644d669488302a; PHPSESSID=vcnvs4i5j3pnkunpsl190rd6p6;
Response 1
HTTP/1.1 200 OK Date: Sun, 09 Jan 2011 05:14:12 GMT Server: Apache/2.2.3 (Red Hat) X-Powered-By: PHP/5.2.9 P3P: CP="ALL DSP COR CURa ADMa DEVa TAIa IVAi IVDi CONi HISi TELi OUR IND PHY ONL FIN COM NAV INT DEM GOV" Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Set-Cookie: mt_imp=54267db83a49b89cd0644d669488302a%27; path=/ Connection: close Content-Type: text/html; charset=UTF-8 Content-Length: 202
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''54267db83a49b89cd0644d669488302a'' and record_adjust2=1' at line 2
Request 2
GET /mt/x2a40344g4q2/&subid1=MQThankYou&subid2=CD99&subid3=409&subid4= HTTP/1.1 Host: www.pixeltrack66.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close Cookie: mt_clk=54267db83a49b89cd0644d669488302a''; mt_lds=54267db83a49b89cd0644d669488302a; PHPSESSID=vcnvs4i5j3pnkunpsl190rd6p6;
Response 2
HTTP/1.1 302 Found Date: Sun, 09 Jan 2011 05:14:12 GMT Server: Apache/2.2.3 (Red Hat) X-Powered-By: PHP/5.2.9 P3P: CP="ALL DSP COR CURa ADMa DEVa TAIa IVAi IVDi CONi HISi TELi OUR IND PHY ONL FIN COM NAV INT DEM GOV" Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Set-Cookie: mt_imp=54267db83a49b89cd0644d669488302a%27%27; path=/ Location: http://www.socialtrack.net/click.track?CID=121402&AFID=73472&ADID=297792&SUBID=CD1 Content-Length: 0 Connection: close Content-Type: text/html; charset=UTF-8
2. Cookie without HttpOnly flag setprevious There are 4 instances of this issue:
If the HttpOnly attribute is set on a cookie, then the cookie's value cannot be read or set by client-side JavaScript. This measure can prevent certain client-side attacks, such as cross-site scripting, from trivially capturing the cookie's value via an injected script.
Issue remediation
There is usually no good reason not to set the HttpOnly flag on all cookies. Unless you specifically require legitimate client-side scripts within your application to read or set a cookie's value, you should set the HttpOnly flag by including this attribute within the relevant Set-cookie directive.
You should be aware that the restrictions imposed by the HttpOnly flag can potentially be circumvented in some circumstances, and that numerous other serious attacks can be delivered by client-side script injection, aside from simple cookie stealing.
The highlighted cookie appears to contain a session token, which may increase the risk associated with this issue. You should review the contents of the cookies to determine their function.
Request
GET /mt/w2643334g4y223/ HTTP/1.1 Host: www.pixeltrack66.com Proxy-Connection: keep-alive Referer: http://content.yieldmanager.edgesuite.net/atoms/4b/20/4f/fa/4b204ffa9cd07b1ada562ff40d59b324.swf?clickTag=http%3A%2F%2Fadserving%2Ecpxinteractive%2Ecom%2Fclk%3F2%2C13%253B0cb5d93d88c4bebb%253B12d6864c680%2C0%253B%253B%253B2580633203%2CiQIAAJ2WCQB3lU0AAAAAAHdEFQAAAAAAAgAEAAYAAAAAAP8AAAAHFB5%2DDwAAAAAA660cAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABk2wQAAAAAAAIAAgAAAAAAYsZkaC0BAAAAAAAAAGY0MDZhMzIwLTFiOGYtMTFlMC1hYjI1LTAwMWIyNDc4NGFhNABwAAAAAAA%3D%2C%2Chttp%253A%252F%252Fwww%2Epogo%2Ecom%252Fgames%252Fscrabble%253Fpagesection%253Dfree%5Fhome%5Fhot%5Fgames1%5Fpl%5Fscrabble%2C Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.224 Safari/534.10 Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Response
HTTP/1.1 302 Found Date: Sun, 09 Jan 2011 01:35:14 GMT Server: Apache/2.2.3 (Red Hat) X-Powered-By: PHP/5.2.9 P3P: CP="ALL DSP COR CURa ADMa DEVa TAIa IVAi IVDi CONi HISi TELi OUR IND PHY ONL FIN COM NAV INT DEM GOV" Set-Cookie: PHPSESSID=vcnvs4i5j3pnkunpsl190rd6p6; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Set-Cookie: mt_clk=54267db83a49b89cd0644d669488302a; path=/ Set-Cookie: mt_lds=54267db83a49b89cd0644d669488302a; expires=Tue, 08-Feb-2011 01:35:14 GMT; path=/ Location: http://www.theiq-quiz.com/hv1iqqz/blender_redirect.php?web_id=CD99&exitpops=9175 Content-Length: 0 Connection: close Content-Type: text/html; charset=UTF-8
The following cookie was issued by the application and does not have the HttpOnly flag set:
mt_imp=54267db83a49b89cd0644d669488302a; path=/
The cookie does not appear to contain a session token, which may reduce the risk associated with this issue. You should review the contents of the cookie to determine its function.
Request
GET /mt/03745344/&subid1=MQExit&subid2=CD99&subid3=409&web_id=e99MQExit&orig=CD99&s=MQExit&c=409 HTTP/1.1 Host: www.pixeltrack66.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close Cookie: mt_clk=54267db83a49b89cd0644d669488302a; mt_lds=54267db83a49b89cd0644d669488302a; PHPSESSID=vcnvs4i5j3pnkunpsl190rd6p6;
Response
HTTP/1.1 302 Found Date: Sun, 09 Jan 2011 05:13:49 GMT Server: Apache/2.2.3 (Red Hat) X-Powered-By: PHP/5.2.9 P3P: CP="ALL DSP COR CURa ADMa DEVa TAIa IVAi IVDi CONi HISi TELi OUR IND PHY ONL FIN COM NAV INT DEM GOV" Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Set-Cookie: mt_imp=54267db83a49b89cd0644d669488302a; path=/ Location: http://www.yourpurecrushes.com/hv1/blender_redirect.php?web_id=CD1&&web_id=e99MQExit&orig=CD99&s=MQExit&c=409 Content-Length: 0 Connection: close Content-Type: text/html; charset=UTF-8
The following cookie was issued by the application and does not have the HttpOnly flag set:
mt_imp=54267db83a49b89cd0644d669488302a; path=/
The cookie does not appear to contain a session token, which may reduce the risk associated with this issue. You should review the contents of the cookie to determine its function.
Request
GET /mt/03745344/&subid1=MQExit&subid2=CD99&subid3=409&web_id=e99MQExitPop&orig=CD99&s=MQExit&c=409 HTTP/1.1 Host: www.pixeltrack66.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close Cookie: mt_clk=54267db83a49b89cd0644d669488302a; mt_lds=54267db83a49b89cd0644d669488302a; PHPSESSID=vcnvs4i5j3pnkunpsl190rd6p6;
Response
HTTP/1.1 302 Found Date: Sun, 09 Jan 2011 05:13:59 GMT Server: Apache/2.2.3 (Red Hat) X-Powered-By: PHP/5.2.9 P3P: CP="ALL DSP COR CURa ADMa DEVa TAIa IVAi IVDi CONi HISi TELi OUR IND PHY ONL FIN COM NAV INT DEM GOV" Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Set-Cookie: mt_imp=54267db83a49b89cd0644d669488302a; path=/ Location: http://www.yourpurecrushes.com/hv1/blender_redirect.php?web_id=CD1&&web_id=e99MQExitPop&orig=CD99&s=MQExit&c=409 Content-Length: 0 Connection: close Content-Type: text/html; charset=UTF-8
The following cookie was issued by the application and does not have the HttpOnly flag set:
mt_imp=54267db83a49b89cd0644d669488302a; path=/
The cookie does not appear to contain a session token, which may reduce the risk associated with this issue. You should review the contents of the cookie to determine its function.
Request
GET /mt/x2a40344g4q2/&subid1=MQThankYou&subid2=CD99&subid3=409&subid4= HTTP/1.1 Host: www.pixeltrack66.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close Cookie: mt_clk=54267db83a49b89cd0644d669488302a; mt_lds=54267db83a49b89cd0644d669488302a; PHPSESSID=vcnvs4i5j3pnkunpsl190rd6p6;
Response
HTTP/1.1 302 Found Date: Sun, 09 Jan 2011 05:14:10 GMT Server: Apache/2.2.3 (Red Hat) X-Powered-By: PHP/5.2.9 P3P: CP="ALL DSP COR CURa ADMa DEVa TAIa IVAi IVDi CONi HISi TELi OUR IND PHY ONL FIN COM NAV INT DEM GOV" Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Set-Cookie: mt_imp=54267db83a49b89cd0644d669488302a; path=/ Location: http://www.socialtrack.net/click.track?CID=121402&AFID=73472&ADID=297792&SUBID=CD1 Content-Length: 0 Connection: close Content-Type: text/html; charset=UTF-8