Craft CMS: Arbitrary file read via SplFileObject in non-sandboxed template contexts
Craft CMS versions from 5.9.0 introduced a vulnerability where the Twig `create()` function allows instantiation of arbitrary PHP classes from template code, with only a limited blocklist. The class `SplFileObject` is not blocked, enabling an admin user to read arbitrary files on the server by configuring entry type title or URI formats in non-sandboxed template contexts. This can expose sensitive files such as `.env` containing security keys and database credentials. Exploitation requires admin access and the configuration setting `allowAdminChanges` to be true, which is typically disabled in production. The vulnerability does not affect sandboxed contexts like system email templates. The severity is rated medium due to the required privileges and configuration.
AI Analysis
Technical Summary
The vulnerability arises from the `create()` Twig function introduced in Craft CMS 5.9.0, which allows instantiation of arbitrary PHP classes from template code but restricts only five classes via a blocklist. Since `SplFileObject` is not blocked, an admin user can instantiate it with a file path argument to read arbitrary files on the server. This is exploitable in non-sandboxed template contexts such as entry type title and URI formats, where the file contents are rendered as entry titles visible to users with entry view permissions. The vulnerability requires admin-level access and `allowAdminChanges=true`, which is usually disabled in production environments. The Twig sandbox blocks this function in system email templates, limiting the scope of exploitation. The impact includes exposure of sensitive files like `.env` containing security keys and database credentials.
Potential Impact
An attacker or admin with control over entry type settings can read arbitrary files on the server filesystem, including sensitive configuration files such as `.env` that contain security keys, database credentials, and API keys. The file contents are exposed as entry titles visible to users with permission to view entries in the affected section. The impact is limited by the need for admin access and the `allowAdminChanges` setting being enabled, which is not recommended in production environments.
Mitigation Recommendations
A patch is available for this vulnerability. It is recommended to apply the official fix provided by the vendor. Additionally, ensure that the `allowAdminChanges` configuration setting is set to false in production environments to prevent unauthorized entry type configuration changes. The Twig sandbox already blocks the `create()` function in system email templates, so no action is required for sandboxed contexts.
Craft CMS: Arbitrary file read via SplFileObject in non-sandboxed template contexts
Description
Craft CMS versions from 5.9.0 introduced a vulnerability where the Twig `create()` function allows instantiation of arbitrary PHP classes from template code, with only a limited blocklist. The class `SplFileObject` is not blocked, enabling an admin user to read arbitrary files on the server by configuring entry type title or URI formats in non-sandboxed template contexts. This can expose sensitive files such as `.env` containing security keys and database credentials. Exploitation requires admin access and the configuration setting `allowAdminChanges` to be true, which is typically disabled in production. The vulnerability does not affect sandboxed contexts like system email templates. The severity is rated medium due to the required privileges and configuration.
CVSS v4.0
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
Weaknesses
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The vulnerability arises from the `create()` Twig function introduced in Craft CMS 5.9.0, which allows instantiation of arbitrary PHP classes from template code but restricts only five classes via a blocklist. Since `SplFileObject` is not blocked, an admin user can instantiate it with a file path argument to read arbitrary files on the server. This is exploitable in non-sandboxed template contexts such as entry type title and URI formats, where the file contents are rendered as entry titles visible to users with entry view permissions. The vulnerability requires admin-level access and `allowAdminChanges=true`, which is usually disabled in production environments. The Twig sandbox blocks this function in system email templates, limiting the scope of exploitation. The impact includes exposure of sensitive files like `.env` containing security keys and database credentials.
Potential Impact
An attacker or admin with control over entry type settings can read arbitrary files on the server filesystem, including sensitive configuration files such as `.env` that contain security keys, database credentials, and API keys. The file contents are exposed as entry titles visible to users with permission to view entries in the affected section. The impact is limited by the need for admin access and the `allowAdminChanges` setting being enabled, which is not recommended in production environments.
Mitigation Recommendations
A patch is available for this vulnerability. It is recommended to apply the official fix provided by the vendor. Additionally, ensure that the `allowAdminChanges` configuration setting is set to false in production environments to prevent unauthorized entry type configuration changes. The Twig sandbox already blocks the `create()` function in system email templates, so no action is required for sandboxed contexts.
Technical Details
- Gcve Source
- db.gcve.eu
- Osv Id
- GHSA-957r-qf9p-67xw
- Osv Schema Version
- 1.4.0
- Aliases
- []
- Ecosystems
- ["Packagist"]
- Database Specific Severity
- MODERATE
- Cvss Version
- 4.0
Threat ID: 6a7573b7bf8831d539d93f45
Added to database: 08/07/2026, 05:57:11 UTC
Last enriched: 08/07/2026, 07:16:43 UTC
Last updated: 08/08/2026, 01:06:14 UTC
Views: 3
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.