upatch.dev

CVE-2026-9558

A Server-Side Template Injection (SSTI) vulnerability exists in Mautic's theme engine.

Refuses subprocess execution by PHP processes to mitigate Mautic theme Twig SSTI CVE-2026-9558.

Critical 9.9Vetted

EPSS 0.8%: the estimated chance this CVE is exploited in the next 30 days, as of 25 Nov 2026.

At a glance

CVE-2026-9558 is a critical (CVSS 9.9) vulnerability in Mautic, published 29 May 2026. A vetted upatch, cve-2026-9558-exec-block, blocks it on running Linux machines with shirudo until Mautic is upgraded.

Severity
Critical 9.9 CVSS 3.1
Chance of exploitation
0.8% in the next 30 days (EPSS, 25 Nov 2026)
Known exploited
No, not on CISA’s KEV list
Weakness
CWE-1336
Affected software
Mautic
Upatch status
Vetted, merged into the registry
How to apply
Build, sign and roll out with shirudo

Overview

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.

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

Sources

More references from NVD (1)

Mitigation

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.

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.

The policy

54 lines of BPF C, attached at lsm/bprm_check_security.

// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause

#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>
#include <bpf/bpf_core_read.h>

#define EPERM 1

char _license[] SEC("license") = "Dual BSD/GPL";

static __always_inline bool starts_with_php(const char *s, __u32 len)
{
	return len >= 3 && s[0] == 'p' && s[1] == 'h' && s[2] == 'p' &&
	       (len == 3 || s[3] == 0 || s[3] == '-' ||
		(s[3] >= '0' && s[3] <= '9'));
}

static __always_inline bool current_is_php(void)
{
	char comm[16] = {};

	if (bpf_get_current_comm(comm, sizeof(comm)) == 0 &&
	    starts_with_php(comm, sizeof(comm)))
		return true;

	struct task_struct *task = bpf_get_current_task_btf();
	const struct dentry *exe = BPF_CORE_READ(task, mm, exe_file, f_path.dentry);
	const unsigned char *name = BPF_CORE_READ(exe, d_name.name);
	__u32 len = BPF_CORE_READ(exe, d_name.len);
	char buf[16] = {};

	if (!name || len < 3)
		return false;
	if (bpf_probe_read_kernel_str(buf, sizeof(buf), name) < 0)
		return false;
	return starts_with_php(buf, len);
}

static __always_inline int earlier_verdict(int ret)
{
	return ret >= -4095 && ret < 0 ? ret : -EPERM;
}

SEC("lsm/bprm_check_security")
int BPF_PROG(cve_2026_9558_exec_block, struct linux_binprm *bprm, int ret)
{
	if (ret)
		return earlier_verdict(ret);
	if (!current_is_php())
		return 0;
	return -EPERM;
}

Process

How this upatch was written, checked and reviewed, from the registry’s history.

  1. 29 May 2026CVECVE published
  2. 25 Nov 2026Pull requestPull request #79 openedAdd CVE-2026-9558: Refuses subprocess execution by PHP processes to mitigate Mautic theme Twig SSTIromanlab
  3. 25 Nov 2026CIUpdate upatch.devpassed
  4. 25 Nov 2026CICIpassed
  5. 25 Nov 2026MergeMerged #79romanlab

No human review is recorded on GitHub for this upatch yet.

Evidence

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
StateTwig theme map('system') subprocess executionIn-process Twig theme rendering (map('trim'))
Before loadingreached (/bin/echo ran, HTTP 200)yes (HTTP 200)
Upatch loadedblocked (execve refused)yes (HTTP 200)
After unloadingreached (/bin/echo ran, HTTP 200)yes (HTTP 200)
tools-test.log Output of tools/test --setup on the shirudo test VM showing the before, loaded, and after probe runs.
tools/test --setup, 2026-11-25T14:33:48Z
Target: shirudo test VM, Linux 7.4-shirudo-ci-20261123, x86_64, swtpm
cve-2026-9558
  setup   done         MAUTIC_URL=http://127.0.0.1:18558/upatch-probe
  before  reached      Mautic Twig theme template spawned /bin/echo via map('system') (HTTP 200)
  loaded  blocked      Mautic rendered the Twig theme template (HTTP 200) but subprocess execution was refused
  after   reached      Mautic Twig theme template spawned /bin/echo via map('system') (HTTP 200)
  PASS: reached before, blocked while loaded, reached again after

Use it

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
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
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>