Skip to content
SQL injection Disclosed report Intermediate

[Informational] Possible SQL Injection in inc/ajax-actions-frontend.php

The plugin fails to escape or validate user-supplied parameters before embedding them in SQL queries, which could allow SQL injection. However, WordPress's magic quotes currently neutralise the attack, so the issue is informational.

damian89 Follow

Originally disclosed on HackerOne

  • Fixed in under an hour
  • Paid in under an hour
  • Disclosed after 5 months

At first, I thought, that my finding is a valid sql injection but I was wrong because of WordPress currently adding magic slashes to COOKIE/POST/GET - this is a very special behaviour which may be remove in the future. There are tons of requests to remove this "old" technique.

Nevertheless I decided to report the issue, because similar code within the audited plugin is escaped - so this is more informational.

Line 49-50:

$multi_layer_map_list = isset($_POST['multi_layer_map_list']) ? ($_POST['multi_layer_map_list']) : (isset($_GET['multi_layer_map_list']) ? ($_GET['multi_layer_map_list']) : '');
$multi_layer_map_list_exploded = explode(',', $multi_layer_map_list);

As you can see $_GET['multi_layer_map_list']/$_POST['multi_layer_map_list'] are not escaped and exploded by "," in line 50.

This may result in a succesful sql injection on line 145 - depending on the use case of the shortcode:

$mlm_query = "SELECT ". $distance_query ." l.id as lid,l.name as lname,... FROM `" . $table_name_layers . "` as l INNER JOIN `" . $table_name_markers . "` AS m ON m.layer LIKE concat('%\"',l.id,'\"%') ". $search_query ." WHERE l.id='" . $multi_layer_map_list . "'  ORDER BY ...";

Fix: esc_sql()

A very similar behaviour can be found in line 149 and following:

$first_mlm_id = $multi_layer_map_list_exploded[0];
$other_mlm_ids = array_slice($multi_layer_map_list_exploded,1);
$mlm_query = "(SELECT ... WHERE l.id='" . $first_mlm_id . "'  )";
foreach ($other_mlm_ids as $row) {
    $mlm_query .= " UNION (SELECT ... FROM `" . $table_name_layers . "` ... WHERE l.id='" . $row . "' )";
}

Here $row and $first_mlm_id are controlled by a guestuser and are not escaped or validated.

Fix: intval()

The only reason the application is not vulnerable is because of wp-settings.php:

// Add magic quotes and set up $_REQUEST ( $_GET + $_POST )
wp_magic_quotes();

But the problem is: a lot of themes and/or plugins (which are loaded sometimes before your plugin is loaded) reset this setting like described hiere:

https://stackoverflow.com/questions/8949768/with-magic-quotes-disabled-why-does-php-wordpress-continue-to-auto-escape-my

I believe it may be a better solution to escaped mentioned parts, just to be sure!

Offtopic: the plugin has also a lot of interesting backend functions and calls - are vulnerabilities which can be triggered by admin/mod/author relevent? I'm not talking about xss, more execs and sqlinjections.

Impact

Under certain circumstances a SQL Injection is possible.

The original report as published on HackerOne, by damian89. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

User-controlled input from GET/POST parameters is concatenated directly into SQL queries without escaping or validation.

Impact

Under certain circumstances a SQL Injection is possible, but WordPress's magic quotes currently prevent exploitation.

What the attacker needed

Magic quotes disabled or bypassed; plugin shortcode in use

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

SQL injection is when user input is inserted directly into a database command, letting an attacker change the command's meaning. Here, the plugin takes a value from a web request and puts it into a database query without cleaning it, but WordPress automatically adds protective slashes to all request data, which currently blocks the attack.

What is SQL injection?

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.

More by damian89

View all

4 more disclosed reports, best first.

More from MapsMarker.com e.U.

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

SQL injection

The lesson behind this report.

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.