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.
HTTP/1.1 500 Internal Server Error Date: Sun, 01 May 2011 02:29:05 GMT Server: Apache X-Powered-By: PHP/5.2.17 Content-Length: 1265 Connection: close Content-Type: text/html; charset=UTF-8
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;"><h4>A PHP Error was encountered</h4><p>Severity: Warning</p><p>Message: Invalid argument supplied for foreach()</p><p>Filename: controllers/careers.php</p><p>Line Number: 134</p></div><div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;"><h4>A PHP Error was encountered</h4><p>Severity: Notice</p><p>Message: Undefined variable: info</p><p>Filename: controllers/careers.php</p><p>Line Number: 146</p></div><html><head><title>Database Error</title><style type="text/css">body {background-color: #fff;margin: 40px;font-family: Lucida Grande, Verdana, Sans-serif;font-size: 12px;color: #000;}#content {border: #999 1px solid;background-color: #fff;padding: 20px 20px 12px 20px;}h1 {font-weight: normal;font-size: 14px;color: #990000;margin: 0 0 4px 0;}</style></head><body> <div id="content"> <h1>A Database Error Occurred</h1> <p>Error Number: 1064</p><p>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 'LIMIT 1' at line 1</p><p>SELECT StateName FROM States WHERE StateID = LIMIT 1</p> </div></body></html>
HTTP/1.1 500 Internal Server Error Date: Sun, 01 May 2011 02:29:09 GMT Server: Apache X-Powered-By: PHP/5.2.17 Content-Length: 1265 Connection: close Content-Type: text/html; charset=UTF-8
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;"><h4>A PHP Error was encountered</h4><p>Severity: Warning</p><p>Message: Invalid argument supplied for foreach()</p><p>Filename: controllers/careers.php</p><p>Line Number: 134</p></div><div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;"><h4>A PHP Error was encountered</h4><p>Severity: Notice</p><p>Message: Undefined variable: info</p><p>Filename: controllers/careers.php</p><p>Line Number: 146</p></div><html><head><title>Database Error</title><style type="text/css">body {background-color: #fff;margin: 40px;font-family: Lucida Grande, Verdana, Sans-serif;font-size: 12px;color: #000;}#content {border: #999 1px solid;background-color: #fff;padding: 20px 20px 12px 20px;}h1 {font-weight: normal;font-size: 14px;color: #990000;margin: 0 0 4px 0;}</style></head><body> <div id="content"> <h1>A Database Error Occurred</h1> <p>Error Number: 1064</p><p>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 'LIMIT 1' at line 1</p><p>SELECT StateName FROM States WHERE StateID = LIMIT 1</p> </div></body></html>
HTTP/1.1 500 Internal Server Error Date: Sun, 01 May 2011 02:29:14 GMT Server: Apache X-Powered-By: PHP/5.2.17 Content-Length: 1265 Connection: close Content-Type: text/html; charset=UTF-8
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;"><h4>A PHP Error was encountered</h4><p>Severity: Warning</p><p>Message: Invalid argument supplied for foreach()</p><p>Filename: controllers/careers.php</p><p>Line Number: 134</p></div><div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;"><h4>A PHP Error was encountered</h4><p>Severity: Notice</p><p>Message: Undefined variable: info</p><p>Filename: controllers/careers.php</p><p>Line Number: 146</p></div><html><head><title>Database Error</title><style type="text/css">body {background-color: #fff;margin: 40px;font-family: Lucida Grande, Verdana, Sans-serif;font-size: 12px;color: #000;}#content {border: #999 1px solid;background-color: #fff;padding: 20px 20px 12px 20px;}h1 {font-weight: normal;font-size: 14px;color: #990000;margin: 0 0 4px 0;}</style></head><body> <div id="content"> <h1>A Database Error Occurred</h1> <p>Error Number: 1064</p><p>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 'LIMIT 1' at line 1</p><p>SELECT StateName FROM States WHERE StateID = LIMIT 1</p> </div></body></html>
HTTP/1.1 500 Internal Server Error Date: Sun, 01 May 2011 02:29:18 GMT Server: Apache X-Powered-By: PHP/5.2.17 Content-Length: 1265 Connection: close Content-Type: text/html; charset=UTF-8
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;"><h4>A PHP Error was encountered</h4><p>Severity: Warning</p><p>Message: Invalid argument supplied for foreach()</p><p>Filename: controllers/careers.php</p><p>Line Number: 134</p></div><div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;"><h4>A PHP Error was encountered</h4><p>Severity: Notice</p><p>Message: Undefined variable: info</p><p>Filename: controllers/careers.php</p><p>Line Number: 146</p></div><html><head><title>Database Error</title><style type="text/css">body {background-color: #fff;margin: 40px;font-family: Lucida Grande, Verdana, Sans-serif;font-size: 12px;color: #000;}#content {border: #999 1px solid;background-color: #fff;padding: 20px 20px 12px 20px;}h1 {font-weight: normal;font-size: 14px;color: #990000;margin: 0 0 4px 0;}</style></head><body> <div id="content"> <h1>A Database Error Occurred</h1> <p>Error Number: 1064</p><p>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 'LIMIT 1' at line 1</p><p>SELECT StateName FROM States WHERE StateID = LIMIT 1</p> </div></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.