Skip to content
Server Security Center
KEVcritical9.8

CVE-2022-46169: Cacti Command Injection

Cacti · listed in the CISA catalog of actively exploited vulnerabilities since 2023-02-16.

CVSS v3.1 (CVE record)
9.8
critical
EPSS (exploit probability, 30 days)
99.8%
among the highest 0.1% of all CVEs
Added to CISA KEV
2023-02-16
US federal due date 2023-03-09
Ubuntu priority
high

CVE-2022-46169 explained

CVE-2022-46169 is a command injection flaw in Cacti, an open source monitoring and fault management platform. An unauthenticated attacker can bypass the authorization check in the remote agent script and run arbitrary commands on the Cacti server. It is listed in the CISA Known Exploited Vulnerabilities catalog, so it should be patched without delay.

Impact

A remote attacker needs no credentials and no user interaction. Over the network, they can execute arbitrary commands on the server running Cacti, with full impact on confidentiality, integrity and availability. The condition is that a data source using a PHP script poller action is configured for some monitored device. This is likely on production systems because predefined templates such as Device - Uptime or Device - Polling Time add such actions.

Who is affected

The cacti source package is affected on Ubuntu 18.04 LTS, Ubuntu 20.04 LTS and Ubuntu 22.04 LTS. Fixed versions exist for all three, and all are delivered through Ubuntu Pro (ESM): 1.1.38+ds1-1ubuntu0.1~esm4 for 18.04, 1.2.10+ds1-1ubuntu1.1+esm2 for 20.04 and 1.2.19+ds1-2ubuntu1.1+esm2 for 22.04. Standard support has ended for 18.04 and 20.04. Upstream, the fix landed in the 1.2.x and 1.3.x branches, starting with release 1.2.23.

Written with AI from the data on this page and checked against it automatically.

Official description

Cacti is an open source platform which provides a robust and extensible operational monitoring and fault management framework for users. In affected versions a command injection vulnerability allows an unauthenticated user to execute arbitrary code on a server running Cacti, if a specific data source was selected for any monitored device.

The vulnerability resides in the remote_agent.php file. This file can be accessed without authentication. This function retrieves the IP address of the client via get_client_addr and resolves this IP address to the corresponding hostname via gethostbyaddr.

After this, it is verified that an entry within the poller table exists, where the hostname corresponds to the resolved hostname. If such an entry was found, the function returns true and the client is authorized. This authorization can be bypassed due to the implementation of the get_client_addr function.

The function is defined in the file lib/functions.php and checks serval $_SERVER variables to determine the IP address of the client. The variables beginning with HTTP_ can be arbitrarily set by an attacker. Since there is a default entry in the poller table with the hostname of the server running Cacti, an attacker can bypass the authentication e.g. by providing the header Forwarded-For: <TARGETIP>.

This way the function get_client_addr returns the IP address of the server running Cacti. The following call to gethostbyaddr will resolve this IP address to the hostname of the server, which will pass the poller hostname check because of the default entry. After the authorization of the remote_agent.php file is bypassed, an attacker can trigger different actions.

One of these actions is called polldata. The called function poll_for_data retrieves a few request parameters and loads the corresponding poller_item entries from the database. If the action of a poller_item equals POLLER_ACTION_SCRIPT_PHP, the function proc_open is used to execute a PHP script.

The attacker-controlled parameter $poller_id is retrieved via the function get_nfilter_request_var, which allows arbitrary strings. This variable is later inserted into the string passed to proc_open, which leads to a command injection vulnerability. By e.g. providing the poller_id=;id the id command is executed.

In order to reach the vulnerable call, the attacker must provide a host_id and local_data_id, where the action of the corresponding poller_item is set to POLLER_ACTION_SCRIPT_PHP. Both of these ids (host_id and local_data_id) can easily be bruteforced. The only requirement is that a poller_item with an POLLER_ACTION_SCRIPT_PHP action exists.

This is very likely on a productive instance because this action is added by some predefined templates like Device - Uptime or Device - Polling Time. This command injection vulnerability allows an unauthenticated user to execute arbitrary commands if a poller_item with the action type POLLER_ACTION_SCRIPT_PHP (2) is configured.

The authorization bypass should be prevented by not allowing an attacker to make get_client_addr (file lib/functions.php) return an arbitrary IP address. This could be done by not honoring the HTTP_... $_SERVER variables. If these should be kept for compatibility reasons it should at least be prevented to fake the IP address of the server running Cacti.

This vulnerability has been addressed in both the 1.2.x and 1.3.x release branches with 1.2.23 being the first release containing the patch.

CISA required action: Apply updates per vendor instructions.

CISA notes

Upstream versions (CVE record)

From the CVE record published by the vendor or CVE numbering authority.

  • cacti
    Affected
    • < 1.2.23
    Fixed in
    not stated

Ubuntu and Debian releases

A server is vulnerable if it has a package built from the listed source package installed in a version lower than the fixed version for its release.

What to do

  1. Identify every host that has the cacti package installed.
  2. Enable Ubuntu Pro (ESM) on those hosts, as the fixed packages are only published there.
  3. Update cacti to the fixed version for your release.
  4. Restart the web server or PHP service so Cacti runs the patched code.
  5. Until patched, restrict network access to the Cacti web interface to trusted administrators only.
  6. Review the Cacti server for signs of compromise, since this flaw is known to be exploited.

Written with AI from the data on this page and checked against it automatically.

Check and fix on a server

Run on each Ubuntu or Debian server. Replace cacti with the source package from the table above.

1. Show installed packages built from the source package, with their versions

dpkg-query -W -f='${binary:Package} ${Version} ${source:Package}\n' | awk '$3=="cacti"'

2. Compare each installed version with the fixed version for your release from the table

I=INSTALLED_VERSION; F=FIXED_VERSION   # replace both
dpkg --compare-versions "$I" lt "$F"; case $? in 0) echo vulnerable ;; 1) echo "fixed or newer" ;; *) echo "check the versions" ;; esac

3. Install the fix

sudo apt update && sudo apt install --only-upgrade $(dpkg-query -W -f='${binary:Package} ${source:Package}\n' | awk '$2=="cacti"{print $1}')

Services keep running the old code until they are restarted – restart the affected service or check with needrestart.

Rows marked “fix via Ubuntu Pro”: these fixes are only installable with an Ubuntu Pro subscription (ESM). Attach the machine first (sudo pro attach, then sudo pro enable esm-infra esm-apps), then run the commands above.

CISA's assessment (SSVC)

Exploitation
Exploited in the wild
Automatable
No – each attack needs manual steps
Technical impact
Total – full control of the component or total information disclosure

Weakness: CWE-74 Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')

Questions about CVE-2022-46169

Does an attacker need a Cacti account?
No. The flaw is exploitable without authentication over the network. The only condition is that a data source using a PHP script poller action exists, which is common on production instances.
Why do I need Ubuntu Pro to get the fix?
For Ubuntu 18.04 LTS, 20.04 LTS and 22.04 LTS, the fixed cacti packages are published only through the Ubuntu Pro (ESM) channel. Without a Pro subscription these updates are not available.
Is this vulnerability being exploited?
Yes. CISA added it to its Known Exploited Vulnerabilities catalog on 2023-02-16, with a required action to apply updates per vendor instructions. Ransomware use is listed as unknown.

Written with AI from the data on this page and checked against it automatically.

References

Data: CISA Known Exploited Vulnerabilities (public domain) · CVE Program records incl. CISA ADP enrichment · OSV.dev (CC BY 4.0) incl. Ubuntu and Debian security data · FIRST EPSS · endoflife.date. Updated automatically – facts last changed 2026-11-21. Always confirm with the vendor's or distribution's advisory before patching.