# CVE-2026-9558: A Server-Side Template Injection (SSTI) vulnerability exists in Mautic's theme engine.

The Markdown version of <https://upatch.dev/cve/CVE-2026-9558>. Last updated 25 Nov 2026.

## At a glance

CVE-2026-9558 is rated Critical 9.9 (CVSS 3.1, CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H). It affects Mautic and was published on 29 May 2026. It is not in CISA's Known Exploited Vulnerabilities catalog. Its EPSS score is 0.8%: the estimated chance it is exploited in the next 30 days, as of 25 Nov 2026. The upatch `cve-2026-9558-exec-block` mitigates it, and is vetted (merged into the registry).

A upatch is a signed BPF program that shirudo loads into a running Linux kernel to block the code path this CVE's exploit takes. It holds the line until the fix ships; it does not replace patching.

## The vulnerability

CVE-2026-9558 (GHSA-9fx4-7cmj-47vg), published on 29 May 2026, is a Server-Side Template Injection (SSTI) vulnerability in Mautic's theme engine affecting Mautic 1.3.0 before 4.4.20, 5.0.0 before 5.2.11, 6.0.0 before 6.0.9, and 7.0.0 before 7.1.2. Mautic renders uploaded Twig theme templates (`@themes/<theme>/html/*.html.twig`) in the global Twig environment without a `SandboxExtension` policy. An authenticated user with permissions to create or upload themes (`core:themes:create`) can upload a theme whose Twig template passes a PHP command-execution callable (`system`, `exec`, `passthru`, `shell_exec`) to Twig's `map`, `filter`, or `reduce` filter (for example `{{ ['id']|map('system')|join }}`) to execute arbitrary commands on the server, or invokes unrestricted Twig functions such as `configGetParameter` or `source`. Commit `21501f2e0e93c1babd247db48f49dc45d11569f3` fixes the bug by adding `ThemeHelper::renderThemeTemplate()` and `ThemeSandboxPolicy`, which sandboxes `@themes/` templates and denies `map`, `reduce`, `filter`, and dangerous Twig functions.

### Official description

A Server-Side Template Injection (SSTI) vulnerability exists in Mautic's theme engine. The platform renders uploaded Twig templates without a sandbox or strict function restrictions. Authenticated users with permissions to create or upload themes can abuse this to execute arbitrary code on the hosting server (Remote Code Execution) or access restricted system files and configuration settings.

## What the upatch does

The program attaches to `lsm/bprm_check_security` and returns `-EPERM` when the calling task's command name or executable dentry name starts with `php` (matching `php`, `php-fpm*`, `php-cgi*`, and versioned binaries such as `php8.2`, `php8.3`, or `php8.4`). When a rendered Twig theme template invokes `system()`, `exec()`, `passthru()`, `shell_exec()`, `popen()`, or `proc_open()`, PHP forks and calls `execve()`, which reaches `bprm_check_security` while the current task is still the PHP process. Returning `-EPERM` refuses the `execve()` before the child binary runs. A refusal from an earlier BPF LSM program on the same hook is passed on unchanged.

The policy: [`cve-2026-9558-exec-block.bpf.c`](https://github.com/copper-helm/upatch-registry/tree/main/upatches/cve-2026-9558), 54 lines of BPF C attached at `lsm/bprm_check_security`, licensed GPL-2.0 OR BSD-2-Clause.

## Side effects

- PHP worker processes (`php`, `php-fpm`, `php-cgi`) cannot execute external binaries via `execve()`.
- Mautic features that spawn external command-line binaries from web requests (such as sendmail command transport when configured instead of SMTP) fail while the upatch is loaded.
- Normal Mautic web requests, Twig template rendering, database queries, and HTTP responses continue to work.
- In-process Twig expressions that do not spawn a child process (such as `configGetParameter()`, `getEntity()`, or `source()`) stay inside PHP's address space and are not intercepted by `bprm_check_security`.
- Not covered: Mautic running inside `mod_php` under an `apache2` or `httpd` worker whose task command name and executable are not `php*`.

## Preemption model and cost

The program keeps no maps and no shared or per-CPU state, so it is safe under every kernel preemption model, including preemptible RCU (`PREEMPT_LAZY`, `PREEMPT_DYNAMIC`) and `PREEMPT_RT`. It runs only on `execve()` calls (`bprm_check_security`), checks the current task's 16-byte command name and executable dentry name, and returns `0` immediately for non-PHP processes.

## Affected versions

| Branch | Affected        | Fixed in |
| ------ | --------------- | -------- |
| 4.x    | 1.3.0 to 4.4.19 | 4.4.20   |
| 5.x    | 5.0.0 to 5.2.10 | 5.2.11   |
| 6.x    | 6.0.0 to 6.0.8  | 6.0.9    |
| 7.x    | 7.0.0 to 7.1.1  | 7.1.2    |

## How it was tested

On Mautic 7.1.1 serving a Twig theme template on loopback, the loaded upatch refused subprocess execution via map('system') while allowing in-process Twig rendering.

- **Tested:** 25 Nov 2026
- **Target:** Mautic 7.1.1 on PHP built-in server, loopback only (127.0.0.1:18558)
- **Kernel:** 7.4-shirudo-ci-20261123
- **Architecture:** x86_64
- **Distribution:** Ubuntu 26.04

### Results

| State           | Twig theme map('system') subprocess execution | In-process Twig theme rendering (map('trim')) |
| --------------- | --------------------------------------------- | --------------------------------------------- |
| Before loading  | reached (/bin/echo ran, HTTP 200)             | yes (HTTP 200)                                |
| Upatch loaded   | blocked (execve refused)                      | yes (HTTP 200)                                |
| After unloading | reached (/bin/echo ran, HTTP 200)             | yes (HTTP 200)                                |

## How to apply

Build the upatch from source, sign it with your own shirudo key, and publish it to your own OCI registry. Machines that follow your upatch tree load it within about a minute.

Build and sign:

```sh
git clone https://github.com/copper-helm/upatch-registry
cd upatch-registry
tools/build <shirudo-checkout> <keys-dir> 1.0.0 upatches/cve-2026-9558
```

Publish and roll out:

```sh
shirudo bpm push build/packages/cve-2026-9558-1.0.0.bee oci://<registry>/<namespace>/cve-2026-9558 --keys-dir <keys-dir>
shirudo bpm tree append build/packages/cve-2026-9558-1.0.0.bee oci://<registry>/<namespace>/<tree> --tree-id <tree-id> --keys-dir <keys-dir>
```

## Review

- Contributors: romanlab.
- Reviewers: none recorded yet.

## Sources and links

- [CVE-2026-9558 record (CVE API)](https://cveawg.mitre.org/api/cve/CVE-2026-9558)
- [GitHub Security Advisory GHSA-9fx4-7cmj-47vg](https://github.com/mautic/mautic/security/advisories/GHSA-9fx4-7cmj-47vg)
- [Fix commit 21501f2e0e93](https://github.com/mautic/mautic/commit/21501f2e0e93c1babd247db48f49dc45d11569f3)
- [Mautic 7.1.1 release](https://github.com/mautic/mautic/releases/tag/7.1.1) and [Mautic 7.1.2 release](https://github.com/mautic/mautic/releases/tag/7.1.2)

### Links

- [CVE-2026-9558 on upatch.dev](https://upatch.dev/cve/CVE-2026-9558) (this page, as HTML)
- [NVD](https://nvd.nist.gov/vuln/detail/CVE-2026-9558)
- [CVE.org](https://www.cve.org/CVERecord?id=CVE-2026-9558)
- [CWE-1336](https://cwe.mitre.org/data/definitions/1336.html)
- Upatch source: [upatches/cve-2026-9558](https://github.com/copper-helm/upatch-registry/tree/main/upatches/cve-2026-9558)

### More references from NVD (1)

- [github.com](https://github.com/mautic/mautic/security/advisories/GHSA-9fx4-7cmj-47vg)
