Skip to content
SQL injection Disclosed report Intermediate

SQL Injection through /include/findusers.php

The 'groups' POST parameter in /include/findusers.php is not sanitised before being used to build a SQL query, allowing boolean-based SQL injection. An attacker could read sensitive data from the users table, including email addresses and password hashes.

egix Follow

Originally disclosed on HackerOne

Critical View original
  • Triaged in 11 days
  • Fixed in 19 months
  • Disclosed after 21 months

Summary by the researcher

Here you can find a full technical write-up for this vulnerability and its exploitation: https://karmainsecurity.com/impresscms-from-unauthenticated-sqli-to-rce

The report

Summary:

The vulnerability is located in the /include/findusers.php script:

281.			$total = $user_handler->getUserCountByGroupLink(@$_POST["groups"], $criteria);
282.	
283.			$validsort = array("uname", "email", "last_login", "user_regdate", "posts");
284.			$sort = (!in_array($_POST['user_sort'], $validsort)) ? "uname" : $_POST['user_sort'];
285.			$order = "ASC";
286.			if (isset($_POST['user_order']) && $_POST['user_order'] == "DESC") {
287.				$order = "DESC";
288.			}
289.	
290.			$criteria->setSort($sort);
291.			$criteria->setOrder($order);
292.			$criteria->setLimit($limit);
293.			$criteria->setStart($start);
294.			$foundusers = $user_handler->getUsersByGroupLink(@$_POST["groups"], $criteria, TRUE);

User input passed through the "groups" POST parameter is not properly sanitized before being passed to the icms_member_Handler::getUserCountByGroupLink() and icms_member_Handler::getUsersByGroupLink() methods at lines 281 and 294. These methods use the first argument to construct a SQL query without proper validation:

461.		public function getUsersByGroupLink($groups, $criteria = null, $asobject = false, $id_as_key = false) {
462.			$ret = array();
463.	
464.			$select = $asobject ? "u.*" : "u.uid";
465.			$sql[] = "	SELECT DISTINCT {$select} "
466.					. "	FROM " . icms::$xoopsDB->prefix("users") . " AS u"
467.					. " LEFT JOIN " . icms::$xoopsDB->prefix("groups_users_link") . " AS m ON m.uid = u.uid"
468.					. "	WHERE 1 = '1'";
469.			if (! empty($groups)) {
470.				$sql[] = "m.groupid IN (" . implode(", ", $groups) . ")";
471.			}

This can be exploited by remote attackers to e.g. read sensitive data from the "users" database table through boolean-based SQL Injection attacks.

ImpressCMS branch :

The vulnerability has been tested and confirmed on ImpressCMS version 1.4.2 (the latest at the time of writing).

Steps To Reproduce:

Use the attached Proof of Concept (PoC) script to reproduce this vulnerability. It's a PHP script supposed to be used from the command-line (CLI). You should see an output like the following:

$ php sqli.php http://localhost/impresscms/
[-] Retrieving security token...
[-] Starting SQL Injection attack...
[-] Admin's email: [email protected]

The PoC leverages both this vulnerability and the one reported at #1081137 to achieve unauthenticated exploitation.

Impact

This vulnerability might allow unauthenticated attackers to disclose any field of the "users" database table, including the users' email addresses and password hashes, potentially leading to full account takeovers.

NOTE: normally, successful exploitation of this vulnerability should require an admin user session. However, due to the vulnerability described in report #1081137, this could be exploited by unauthenticated attackers as well.

The original report as published on HackerOne, by egix. 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

The 'groups' POST parameter is passed directly into a SQL query without validation or parameterisation.

Impact

An attacker could read any field from the users table, including email addresses and password hashes, potentially leading to full account takeovers; normally an admin session is required, but a separate vulnerability allows unauthenticated exploitation.

What the attacker needed

Admin session normally required; unauthenticated via separate bug #1081137

How it was found

  1. Send a POST request to /include/findusers.php with a crafted 'groups' parameter.
  2. The application passes the unsanitised 'groups' value to getUserCountByGroupLink() and getUsersByGroupLink().
  3. These methods build a SQL query that includes the raw input, enabling boolean-based SQL injection.
  4. Use the injection to extract data from the users table, such as email addresses and password hashes.

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 into a database command without being cleaned, so an attacker can change the command's meaning. Here, the 'groups' field from a form is placed directly into a database query, letting an attacker ask the database yes/no questions to extract secret information like email addresses and password hashes.

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 egix

View all

13 more disclosed reports, best first.

More from ImpressCMS

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.