Skip to content
RCE Write-up Intermediate

Cacti: Unauthenticated Remote Code Execution

Cacti versions up to 1.2.22 contain an authentication bypass in remote_agent.php that lets an unauthenticated attacker access its functionality, and a command injection in the poller_id parameter that allows arbitrary command execution when a specific poller action exists.

Stefan Schiller Follow

Published on sonarsource.com

Cacti is an open-source, web-based monitoring solution with a long-standing history dating back to its first release in 2001. Nowadays, it is well established, actively maintained, and deployed worldwide.

Stefan Schiller (@scryh_), on sonarsource.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

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

How it worked

Root cause

Likely the authentication check trusts attacker-controlled HTTP headers to determine the client IP, and the poller_id parameter is not validated or escaped before being used in a shell command.

Impact

An unauthenticated attacker could run arbitrary commands as the web server user, potentially leading to full infrastructure compromise.

What the attacker needed

Cacti version 1.2.22 or below; A poller item with POLLER_ACTION_SCRIPT_PHP action; No reverse proxy filtering headers (for bypass)

The fix

The authentication bypass was fixed by using only REMOTE_ADDR by default and allowing administrators to configure trusted proxy headers; the command injection was fixed by validating poller_id as an integer and escaping it before use in proc_open.

How it was found

  1. Send a request to remote_agent.php with a spoofed header to bypass authentication.
  2. Set the action parameter to polldata to trigger the vulnerable function.
  3. Provide a poller_id value containing a command injection payload.
  4. Ensure a poller item with the POLLER_ACTION_SCRIPT_PHP action exists (common via default templates).
  5. Brute-force or enumerate host_id values (e.g., by sending an array) to find a valid one that triggers the vulnerable call.

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 write-up has not been written yet. The Original tab links to the source.

Cacti is a tool for monitoring networks. Two mistakes combine here: a login check can be fooled by a fake header, and a user-supplied value is passed to a system command without cleaning, letting an attacker run their own commands on the server.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by Stefan Schiller

View all

10 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.