SQL Injection occurs when data input for example by a user is interpreted as a SQL command rather than normal data by the backend database. This is an extremely common vulnerability and its successful exploitation can have critical implications. Even though Netsparker believes that there is a SQL Injection in here it could not confirm it. There can be numerous reasons for Netsparker not being able to confirm this. We strongly recommend investigating the issue manually to ensure that it is an SQL Injection and that it needs to be addressed. You can also consider sending the details of this issue to us, in order that we can address this issue for the next time and give you a more precise result.
Impact
Depending on the backend database, database connection settings and the operating system, an attacker can mount one or more of the following type of attacks successfully:
Reading, Updating and Deleting arbitrary data from the database
Executing commands on the underlying operating system
Reading, Updating and Deleting arbitrary tables from the database
Actions to Take
See the remedy for solution.
If you are not using a database access layer (DAL) within the architecture consider its benefits and implement if appropriate. As a minimum the use of s DAL will help centralize the issue and its resolution. You can also use an ORM (object relational mapping). Most ORM systems use parameterized queries and this can solve many if not all SQL Injection based problems.
Locate all of the dynamically generated SQL queries and convert them to parameterised queries. (If you decide to use a DAL/ORM, change all legacy code to use these new libraries)
Monitor and review weblogs and application logs in order to uncover active or previous exploitation attempts.
Remedy
A very robust method for mitigating the threat of SQL Injection based vulnerabilities is to use parameterized queries (prepared statements). Almost all modern languages provide built in libraries for this. Wherever possible do not create dynamic SQL queries or SQL queries with string concatenation.
Required Skills for Successful Exploitation
There are numerous freely available tools to test for SQL Injection vulnerabilities. This is a complex area with many dependencies, however it should be noted that the numerous resources available in this area have raised both attacker awareness of the issues and their ability to discover and leverage them. SQL Injection is one of the most common web application vulnerabilities.
'+ (select convert(int,CHAR(95)+CHAR(33)+CHAR(64)+CHAR(50)+CHAR(100)+CHAR(105)+CHAR(108)+CHAR(101)+CHAR(109)+CHAR(109)+CHAR(97)) FROM syscolumns) +'
Request
GET /?id='%2B%20(select+convert(int,CHAR(95)%2BCHAR(33)%2BCHAR(64)%2BCHAR(50)%2BCHAR(100)%2BCHAR(105)%2BCHAR(108)%2BCHAR(101)%2BCHAR(109)%2BCHAR(109)%2BCHAR(97))+FROM+syscolumns)%20%2B' HTTP/1.1 User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322) Cache-Control: no-cache Host: www.truewoman.com Cookie: SN47d74a4a4b1bb=89dc6d38a0fe3a30da4776f0de44a5b4 Accept-Encoding: gzip, deflate
Response
HTTP/1.1 200 OK Server: nginx/0.7.65 Date: Wed, 04 May 2011 01:15:48 GMT Content-Type: text/html Connection: keep-alive X-Powered-By: PHP/5.2.10-2ubuntu6 P3P: CP="NOI NID ADMa OUR IND UNI COM NAV" Cache-Control: private, must-revalidate Set-Cookie: SN47d74a4a4b1bb=89dc6d38a0fe3a30da4776f0de44a5b4; path=/ Vary: Accept-Encoding Content-Encoding: Content-Length: 979
<html><head><title>MODx Content Manager » </title> <style>TD, BODY { font-size: 11px; font-family:verdana; }</style> <script type='text/javascript'> function copyToClip() { holdtext.innerText = sqlHolder.innerText; Copied = holdtext.createTextRange(); Copied.execCommand('Copy'); } </script> </head><body> <h3 style='color:red'>« MODx Parse Error »</h3> <table border='0' cellpadding='1' cellspacing='0'> <tr><td colspan='3'>MODx encountered the following error while attempting to parse the requested resource:</td></tr> <tr><td colspan='3'><b style='color:red;'>« Execution of a query to the database failed - 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 '(select+convert(int,CHAR(95)%2BCHAR(33)%2BCHAR(64)%2BCHAR(50)%2BCHAR(100)%2BCHAR' at line 1 »</b></td></tr><tr><td colspan='3'><b style='color:#999;font-size: 9px;'> SQL: <span id='sqlHolder'>INSERT INTO `truewoman`.`truewoman_error_404_logger` (url, ip, host, referer, createdon) VALUES ('/?id='%2B%20(select+convert(int,CHAR(95)%2BCHAR(33)%2BCHAR(64)%2BCHAR(50)%2BCHAR(100)%2BCHAR(105)%2BCHAR(108)%2BCHAR(101)%2BCHAR(109)%2BCHAR(109)%2BCHAR(97))+FROM+syscolumns)%20%2B'','173.193.214.243', '173.193.214.243-static.reverse.softlayer.com', '', '2011-05-03 21:15:48')</span></b> <br /> <a href='javascript:copyToClip();' style='color:#821517;font-size: 9px; text-decoration: none'>[Copy SQL to ClipBoard]</a><textarea id='holdtext' style='display:none;'></textarea></td></tr><tr><td> </td></tr><tr><td colspan='3'><b>Parser timing</b></td></tr><tr><td> MySQL: </td><td><i>0.0013 s</i></td><td>(<i>1 Requests</i>)</td></tr><tr><td> PHP: </td><td><i>0.2783 s</i></td><td> </td></tr><tr><td> Total: </td><td><i>0.2796 s</i></td><td> </td></tr></table></body></html>
Cookie was not marked as HTTPOnly. HTTPOnly cookies can not be read by client-side scripts therefore marking a cookie as HTTPOnly can provide an additional layer of protection against Cross-site Scripting attacks..
Impact
During a Cross-site Scripting attack an attacker might easily access cookies and hijack the victim's session.
Actions to Take
See the remedy for solution
Consider marking all of the cookies used by the application as HTTPOnly (After these changes javascript code will not able to read cookies.
Remedy
Mark the cookie as HTTPOnly. This will be an extra layer of defence against XSS. However this is not a silver bullet and will not protect the system against Cross-site Scripting attacks. An attacker can use a tool such as XSS Tunnel to bypass HTTPOnly protection.
Netsparker identified that the target web server is disclosing the PHP version in use through the HTTP response. This information can help an attacker to gain a greater understanding of the systems in use and potentially develop further attacks targeted at the specific version of PHP.
Impact
An attacker can look for specific security vulnerabilities for the version identified. Also the attacker can use this information in conjunction with the other vulnerabilities in the application or the web server.
The error message may disclose sensitive information and this information can be used by an attacker to mount new attacks or to enlarge the attack surface. In rare conditions this may be a clue for an SQL Injection vulnerability. Most of the time Netsparker will detect and report that problem separately.
Remedy
Do not provide any error messages on production environments. Save error messages with a reference number to a backend storage such as a text file or database, then show this number and a static user-friendly error message to the user.
'+ (select convert(int,CHAR(95)+CHAR(33)+CHAR(64)+CHAR(50)+CHAR(100)+CHAR(105)+CHAR(108)+CHAR(101)+CHAR(109)+CHAR(109)+CHAR(97)) FROM syscolumns) +'
Request
GET /?id='%2B%20(select+convert(int,CHAR(95)%2BCHAR(33)%2BCHAR(64)%2BCHAR(50)%2BCHAR(100)%2BCHAR(105)%2BCHAR(108)%2BCHAR(101)%2BCHAR(109)%2BCHAR(109)%2BCHAR(97))+FROM+syscolumns)%20%2B' HTTP/1.1 User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322) Cache-Control: no-cache Host: www.truewoman.com Cookie: SN47d74a4a4b1bb=89dc6d38a0fe3a30da4776f0de44a5b4 Accept-Encoding: gzip, deflate
Response
HTTP/1.1 200 OK Server: nginx/0.7.65 Date: Wed, 04 May 2011 01:15:48 GMT Content-Type: text/html Connection: keep-alive X-Powered-By: PHP/5.2.10-2ubuntu6 P3P: CP="NOI NID ADMa OUR IND UNI COM NAV" Cache-Control: private, must-revalidate Set-Cookie: SN47d74a4a4b1bb=89dc6d38a0fe3a30da4776f0de44a5b4; path=/ Vary: Accept-Encoding Content-Encoding: Content-Length: 979
<html><head><title>MODx Content Manager » </title> <style>TD, BODY { font-size: 11px; font-family:verdana; }</style> <script type='text/javascript'> function copyToClip() { holdtext.innerText = sqlHolder.innerText; Copied = holdtext.createTextRange(); Copied.execCommand('Copy'); } </script> </head><body> <h3 style='color:red'>« MODx Parse Error »</h3> <table border='0' cellpadding='1' cellspacing='0'> <tr><td colspan='3'>MODx encountered the following error while attempting to parse the requested resource:</td></tr> <tr><td colspan='3'><b style='color:red;'>« Execution of a query to the database failed - 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 '(select+convert(int,CHAR(95)%2BCHAR(33)%2BCHAR(64)%2BCHAR(50)%2BCHAR(100)%2BCHAR' at line 1 »</b></td></tr><tr><td colspan='3'><b style='color:#999;font-size: 9px;'> SQL: <span id='sqlHolder'>INSERT INTO `truewoman`.`truewoman_error_404_logger` (url, ip, host, referer, createdon) VALUES ('/?id='%2B%20(select+convert(int,CHAR(95)%2BCHAR(33)%2BCHAR(64)%2BCHAR(50)%2BCHAR(100)%2BCHAR(105)%2BCHAR(108)%2BCHAR(101)%2BCHAR(109)%2BCHAR(109)%2BCHAR(97))+FROM+syscolumns)%20%2B'','173.193.214.243', '173.193.214.243-static.reverse.softlayer.com', '', '2011-05-03 21:15:48')</span></b> <br /> <a href='javascript:copyToClip();' style='color:#821517;font-size: 9px; text-decoration: none'>[Copy SQL to ClipBoard]</a><textarea id='holdtext' style='display:none;'></textarea></td></tr><tr><td> </td></tr><tr><td colspan='3'><b>Parser timing</b></td></tr><tr><td> MySQL: </td><td><i>0.0013 s</i></td><td>(<i>1 Requests</i>)</td></tr><tr><td> PHP: </td><td><i>0.2783 s</i></td><td> </td></tr><tr><td> Total: </td><td><i>0.2796 s</i></td><td> </td></tr></table></body></html>