Skip to content

About

From anonymous visitor to OS command execution in Cacti ≤ 1.2.31 (GHSA-5x85-g4vc-gq53) — root cause analysis, reproducible Docker lab, and blind-shell PoC.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

CactiGuest2Shell — Cacti 1.2.31 Lab

Reproducible Docker environment for the CactiGuest2Shell vulnerability chain (GHSA-5x85-g4vc-gq53, affected ≤ 1.2.31) with an end-to-end proof-of-concept.

A single unauthenticated-as-guest HTTP conversation escalates to OS command execution as the poller user:

auth_profile.php (Guest)      writes preview_graphs_per_page unchecked
        ↓
graph_view.php (preview)      setting is used as the graphs filter default,
                              skips FILTER_VALIDATE_INT, reaches a raw LIMIT clause
        ↓
stacked SQL statements        PDO emulated prepares + multi-statements enabled
        ↓
poller_item.arg1              attacker-controlled poller command (TEXT column)
        ↓
graph_realtime.php (init)     realtime poller runs exec_poll(arg1) → popen()

The lab is intentionally vulnerable and is bound to loopback by default. Run it only on a machine you own.

Attack conditions

Every condition below is evaluated against a stock Cacti 1.2.31 install — nothing exotic is required to reproduce the chain.

# Condition Why it matters Stock default This lab
1 Built-in authentication enabled (auth_method=1) Activates the session path the chain rides on On after any standard install Seeded by the entrypoint
2 A session principal the attacker controls The settings write is authenticated — either a default Normal User (realms 7 + 20, per the advisory) or the Guest account Any registered user qualifies; Guest needs guest_user configured guest_user=guest seeded so no login is needed at all
3 Unvalidated profile-setting write (update_data) The attack's first stage — stores the poisoned preview_graphs_per_page value Present in ≤ 1.2.31 Preserved (pinned release tarball)
4 Graph preview uses stored settings as filter defaults Defaults skip FILTER_VALIDATE_INT — the poisoned value reaches SQL unfiltered Present in ≤ 1.2.31 Preserved
5 At least one script-type poller item (action 1/2) with a graph Provides the poller_item.arg1 command the SQL hijacks and the graph the realtime trigger fires Default install creates several for the Local Cacti Machine device (e.g. unix_processes.pl) Created by the automated installer
6 Realtime graph endpoint reachable by the same principal Executes exec_poll(arg1) → popen() — stage that turns SQL into a shell Guest-accessible in ≤ 1.2.31 Preserved
7 PDO emulated prepares (multi-statement queries) Lets the injected LIMIT carry stacked UPDATE statements PHP PDO default; Cacti never disables it PHP 8.2 defaults
8 Poller user can write a web-served directory PoC read-back channel (images/) — proves execution without an external listener www-data owns web-root subdirectories Verified in the image

Conditions 3–7 are the vulnerability itself, fixed on develop (PR #9015) but present in every release tag up to and including 1.2.31. Conditions 1–2 define who can reach it — with the advisory's default Normal User set, no non-default configuration is required; this lab goes one step further and reproduces the chain fully unauthenticated via the Guest account. Condition 8 is PoC ergonomics, not part of the vulnerability.

Requirements

  • Docker Engine with Compose v2 (docker compose version)
  • Python 3.10+ (PoC uses the standard library only)

Bring the lab up

docker compose up -d --build

First start downloads the pinned Cacti 1.2.31 release tarball, loads the base schema, and runs the automated installer. The cacti service turns healthy once the web tier answers; watch it with:

docker compose logs -f cacti      # "[cacti] running automated installer ..."
docker compose ps

The stack listens on http://localhost:8080 by default. Override the port or bind address without editing the file:

LAB_PORT=8082 LAB_BIND=0.0.0.0 docker compose up -d

Reproduce the proof

# 1. Blind execution proof via the time channel (no listener, no files)
python3 POC/cacti_blindshell.py --target http://localhost:8080 --probe

# 2. Interactive shell as the poller user
python3 POC/cacti_blindshell.py --target http://localhost:8080

#    cacti> id
#    uid=33(www-data) ...

# 3. One-shot commands; the session stays attached until you type exit
python3 POC/cacti_blindshell.py --target http://localhost:8080 --cmd 'id; hostname'

Session controls inside the shell:

Input Effect
exit kill the session, restore all modified state
Ctrl+C keep the session running
Ctrl+D detach — the session stays alive on the target

A detached session keeps its state on disk and can be resumed or torn down:

python3 POC/cacti_blindshell.py --attach <session-id> --cmd 'uptime'
python3 POC/cacti_blindshell.py --kill <session-id>

Every teardown path restores poller_item.arg1, the injected user setting, and the guest profile, and removes the output files the shell created.

Teardown

docker compose down -v   # remove containers and volumes

Layout

Path Purpose
POC/cacti_blindshell.py proof-of-concept (probe, shell, attach, kill)
docker-compose.yml two-service stack: Cacti web tier + MariaDB
docker/Dockerfile Cacti 1.2.31 image, tarball pinned by SHA-256
docker/entrypoint.sh schema bootstrap + automated installer
docker/php-overrides.ini runtime settings Cacti expects
LICENSE MIT

Reference

  • In-depth root cause analysis: ADVISORY.md
  • GitHub advisory: GHSA-5x85-g4vc-gq53 (CVSS 8.8, published 2026-11-29)
  • Fixed on the develop branch only at the time of writing; no release tag carried the fix when this lab was built.

About

From anonymous visitor to OS command execution in Cacti ≤ 1.2.31 (GHSA-5x85-g4vc-gq53) — root cause analysis, reproducible Docker lab, and blind-shell PoC.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages