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.
Issue remediation
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. The payload 'waitfor%20delay'0%3a0%3a20'-- was submitted in the REST URL parameter 1. The application took 20343 milliseconds to respond to the request, compared with 31 milliseconds for the original request, indicating that the injected SQL command caused a time delay.
The database appears to be Microsoft SQL Server.
Request
GET /PR'waitfor%20delay'0%3a0%3a20'--/hyatt_menus.html HTTP/1.1 Host: cendyn.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close
Response (redirected)
HTTP/1.1 200 OK Cache-Control: private Content-Length: 15451 Content-Type: text/html Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET 2.0 X-Powered-By: ASP.NET Set-Cookie: ASPSESSIONIDCACRSTCA=LPJFAGHBPNMKOJHEBLOMHPEK; path=/ Date: Wed, 29 Sep 2010 15:31:35 GMT Connection: close
The REST URL parameter 2 appears to be vulnerable to SQL injection attacks. The payload 'waitfor%20delay'0%3a0%3a20'-- was submitted in the REST URL parameter 2. The application took 20282 milliseconds to respond to the request, compared with 31 milliseconds for the original request, indicating that the injected SQL command caused a time delay.
The database appears to be Microsoft SQL Server.
Request
GET /PR/hyatt_menus.html'waitfor%20delay'0%3a0%3a20'-- HTTP/1.1 Host: cendyn.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close
Response (redirected)
HTTP/1.1 200 OK Cache-Control: private Content-Length: 15451 Content-Type: text/html Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET 2.0 X-Powered-By: ASP.NET Set-Cookie: ASPSESSIONIDCACRSTCA=MDKFAGHBLGKLOFOIFFDCDALD; path=/ Date: Wed, 29 Sep 2010 15:33:05 GMT Connection: close
The cookie appears to contain a session token, which may increase the risk associated with this issue. You should review the contents of the cookie to determine its function.
Issue background
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.
Request
GET / HTTP/1.1 Host: cendyn.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close
Response
HTTP/1.1 301 moved permanently Connection: close Date: Wed, 29 Sep 2010 15:31:09 GMT Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET 2.0 X-Powered-By: ASP.NET Location: http://www.cendyn.com Content-Length: 7356 Content-Type: text/html Set-Cookie: ASPSESSIONIDCACRSTCA=HKJFAGHBAPNIGOMIGJLBLDDK; path=/ Cache-control: private
<!--include virtual="/javascript/FlashVer.asp"--> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head>
The following email address was disclosed in the response:
lori.alexander@hyatt.com
Issue background
The presence of email addresses within application responses does not necessarily constitute a security vulnerability. Email addresses may appear intentionally within contact information, and many applications (such as web mail) include arbitrary third-party email addresses within their core content.
However, email addresses of developers and other individuals (whether appearing on-screen or hidden within page source) may disclose information that is useful to an attacker; for example, they may represent usernames that can be used at the application's login, and they may be used in social engineering attacks against the organisation's personnel. Unnecessary or excessive disclosure of email addresses may also lead to an increase in the volume of spam email received.
Issue remediation
You should review the email addresses being disclosed by the application, and consider removing any that are unnecessary, or replacing personal addresses with anonymous mailbox addresses (such as helpdesk@example.com).
Request
GET /PR/hyatt_menus.html HTTP/1.1 Host: cendyn.com Accept: */* Accept-Language: en User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) Connection: close
Response
HTTP/1.1 200 OK Content-Length: 7198 Content-Type: text/html Last-Modified: Tue, 15 Jun 2010 22:33:14 GMT Accept-Ranges: bytes ETag: "dc9c48bedaccb1:3da" Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET 2.0 X-Powered-By: ASP.NET Date: Wed, 29 Sep 2010 15:31:11 GMT Connection: close
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <titl ...[SNIP]... <a href="mailto:lori.alexander@hyatt.com">lori.alexander@hyatt.com</a> ...[SNIP]...
The file robots.txt is used to give instructions to web robots, such as search engine crawlers, about locations within the web site which robots are allowed, or not allowed, to crawl and index.
The presence of the robots.txt does not in itself present any kind of security vulnerability. However, it is often used to identify restricted or private areas of a site's contents. The information in the file may therefore help an attacker to map out the site's contents, especially if some of the locations identified are not linked from elsewhere in the site. If the application relies on robots.txt to protect access to these areas, and does not enforce proper access control over them, then this presents a serious vulnerability.
Issue remediation
The robots.txt file is not itself a security threat, and its correct use can represent good practice for non-security reasons. You should not assume that all web robots will honour the file's instructions. Rather, assume that attackers will pay close attention to any locations identified in the file. Do not rely on robots.txt to provide any kind of protection over unauthorised access.
Request
GET /robots.txt HTTP/1.0 Host: cendyn.com
Response
HTTP/1.1 200 OK Content-Length: 2833 Content-Type: text/plain Last-Modified: Sat, 08 Apr 2006 16:59:01 GMT Accept-Ranges: bytes ETag: "b8d4f7bb2d5bc61:3da" Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET 2.0 X-Powered-By: ASP.NET Date: Wed, 29 Sep 2010 15:31:09 GMT Connection: close
# robots.txt
User-agent: * Disallow: /_common/ # This is a Common virtual URL Disallow: /images/ # Images Files Disallow: /_backOffice+/ # This is an Admin Area Disallow: /cendyn_newsletter/
...[SNIP]...
Report generated by Hoyt LLC Research
at Wed Sep 29 12:04:36 EDT 2010.