infra
4HTTP2ROOT Deep Dive: Why Stored Settings Bypass Request Validation in Cacti 1.2.31
Code-path anatomy of Cacti 4HTTP2ROOT / 4HTTP2SHELL: why prepared statements on auth_profile.php fail without type enforcement, how stored database defaults bypass graph_view.php FILTER_VALIDATE_INT into a PDO stacked-query LIMIT injection, and how graph_realtime.php turns poller_item.arg1 into popen() execution.
4HTTP2SHELL (publicly tracked as 4HTTP2ROOT and SZB-2d2e53b206) is an unpatched zero-day RCE chain against Cacti Core 1.2.31 disclosed on 26 November 2026 by ek0ms savi0r and independently confirmed in lab testing by watchTowr and Previdian (VULN-2026-0010). Its mechanics illustrate a classic architectural blind spot in legacy PHP monitoring tools: sanitizing HTTP request parameters while implicitly trusting values pulled back from database preference tables.
For urgent mitigations, guest-user disablement, and IOC queries, see our tracking card: Cacti 4HTTP2ROOT Unpatched Zero-Day Enables 4-Request Guest RCE.
The Trust Boundary Collapse Across Four Requests
Unauthenticated Client (when Guest User != No User)
|
+--> Req 1: GET /auth_profile.php?tab=general&header=false
| Sets guest session cookie + csrfMagicToken
|
+--> Req 2: POST /auth_profile.php?tab=general&action=update_data&header=false
| Prepared INSERT/REPLACE writes arbitrary string into
| settings_user (`preview_graphs_per_page` = numeric prefix + stacked SQL)
| (Prepared statement prevents SQLi on write -- but stores toxic string)
|
+--> Req 3: GET /graph_view.php?action=preview&page=1&clear=1
| clear=1 discards URL param; read_user_setting() loads stored string
| FILTER_VALIDATE_INT never sees it -> get_allowed_graphs() interpolates
| $sql_limit unescaped into the SELECT ... LIMIT clause;
| PDO multi-statement execution runs stacked poller_item UPDATE (PHP warning only)
|
+--> Req 4: GET /graph_realtime.php?action=init&local_graph_id=1&ds_step=10&size=90
-> poller_realtime.php -> cmd_realtime.php:221 -> lib/poller.php
-> popen($command, 'r') executes overwritten poller_item.arg1
Stage 1 & 2: Prepared Writes Without Domain Validation
Many developers equate "uses prepared statements" with "SQL-injection safe". In auth_profile.php, Cacti verifies that submitted form field names match expected settings keys and binds the string value safely through PDO prepared parameters before saving to settings_user.
Because settings_user.value is stored as a free-form varchar column supporting string, boolean, and integer user preferences alike, storing a non-numeric SQL-containing string into preview_graphs_per_page raises zero errors during the POST.
Stage 3: Stored Defaults Skip FILTER_VALIDATE_INT
The critical break occurs in graph_view.php (around line 657) and lib/auth.php (1574–1578). Request parameters passed directly on the query string undergo explicit integer validation—FILTER_VALIDATE_INT rejects non-integer input cleanly.
However, when clear=1 (or when no explicit override is supplied), graph_view.php falls back to read_user_setting('preview_graphs_per_page'), trusting the value already persisted in settings_user as a safe numeric default for $graphs:
$sql_limitis constructed via string interpolation (LIMIT 0,$graphs/$start,$rows), because MySQL/MariaDBLIMITclauses historically resisted bound parameters in dynamic query builders.- Cacti opens its PDO MySQL/MariaDB connection without disabling
PDO::MYSQL_ATTR_MULTI_STATEMENTS(which defaults to enabled in PHPpdo_mysql). - When the page evaluates
SELECT ... LIMIT 0,$sql_limit, a stored numeric prefix terminated by a semicolon triggers MariaDB/MySQL to execute theSELECTfollowed immediately by a stackedUPDATEtargetingpoller_item(host_id,action, and command columnarg1), while PHP logs only a non-fatal warning ("A non-numeric value encountered") and returns HTTP200with normal graph HTML.
Encoding command strings as SQL hex literals avoids single-quote escaping altogether inside the stacked query, while setting action to POLLER_ACTION_SCRIPT (1) ensures the modified poller_item row routes through the OS command poller path.
Stage 4: Realtime Polling Turns Data Rows Into popen()
Even on installations where the scheduled 5-minute poller.php cron job runs slowly or under separate schedules, Cacti's Realtime Graphs endpoint (graph_realtime.php?action=init) is immediately reachable by the same guest session:
graph_realtime.phpinvokespoller_realtime.php, which callscmd_realtime.php:221.- For
action=1,cmd_realtime.phppassespoller_item['arg1']down toexec_poll()inlib/poller.php(32–56), executingpopen($command, 'r')directly under the web or poller OS user (www-data,apache, orrootinside single-process Docker containers).
Why Standard Auditing Missed It (Defensive Takeaways)
- Second-order SQL injection hides behind prepared writes: Static taint rules that mark database reads (
read_user_setting(),db_fetch_cell()) as trusted sinks miss every second-order path into dynamic SQL likeORDER BY,LIMIT, table names, and column identifiers. - Disable
PDO::MYSQL_ATTR_MULTI_STATEMENTSat connection construction: Very few web applications legitimately need stacked statements in routine queries; turningMYSQL_ATTR_MULTI_STATEMENTS => falseon PDO connections breaks stackedUPDATE/INSERTescalation acrossLIMITandORDER BYinjection bugs at the driver layer. - Validate at the sink as well as the form: Numeric query parameters (
$rows,$offset,$page) should be coerced with explicit(int)orfilter_var(..., FILTER_VALIDATE_INT)after resolving defaults from the database—not only on incoming$_GET/$_POSTvalues. - Never leave monitoring guests active: Cacti ships with Guest access disabled by default, yet operational teams frequently enable it for NOC wallboards. If a wallboard needs read-only graphs, export static PNG/Grafana embeds behind authenticated reverse proxies rather than exposing interactive
auth_profile.phpandgraph_realtime.phpendpoints.