{"id":"GHSA-957r-qf9p-67xw","title":"Craft CMS: Arbitrary file read via SplFileObject in non-sandboxed template contexts","summary":"Craft CMS: Arbitrary file read via SplFileObject in non-sandboxed template contexts","severity":"medium","cwe":["CWE-184"],"vendor":"craftcms","product":"craftcms/cms","ecosystem":"composer","affected":["craftcms/cms >= 5.0.0-RC1, < 5.10.6","craftcms/cms >= 4.0.0-RC1, < 4.18.2"],"patched":["craftcms/cms 5.10.6","craftcms/cms 4.18.2"],"published":"2026-08-06","updated":"2026-08-06","source":"GHSA","sourceUrl":"https://github.com/advisories/GHSA-957r-qf9p-67xw","references":[{"url":"https://github.com/craftcms/cms/security/advisories/GHSA-957r-qf9p-67xw"},{"url":"https://github.com/craftcms/cms/commit/7c96fd73df936a10e8f85ae6ef61a9fc3f277c12"},{"url":"https://github.com/craftcms/cms/commit/87978f11c8f986c40ef41b941d79547230c4d6d9"},{"url":"https://github.com/craftcms/cms/releases/tag/4.18.2"},{"url":"https://github.com/craftcms/cms/releases/tag/5.10.6"},{"url":"https://github.com/advisories/GHSA-957r-qf9p-67xw"}],"tags":["ghsa","composer"],"ingestedAt":"2026-08-06T22:05:22.970Z","slug":"GHSA-957r-qf9p-67xw","body":"## Overview\n\nThe `create()` Twig function (introduced in 5.9.0) allows instantiation of arbitrary PHP classes from template code, restricted only by a 5-entry blocklist. `SplFileObject` is not in the blocklist, enabling arbitrary file read, including `.env` (security key, DB credentials) and the passwd file from non-sandboxed Twig template contexts, such as entry type title formats and URI formats. \n\nThe sandbox correctly blocks `create()` in system email templates, so this finding applies only to admin-configured, non-sandboxed contexts that require `allowAdminChanges=true`.\n\n## Prerequisites\n\n- Admin access to the Craft control panel\n- `allowAdminChanges` must be `true` (default in dev/staging, recommended `false` in production)\n- Admin must be able to edit entry type settings (title format, URI format)\n- Any user who subsequently creates an entry in the affected section triggers the file read\n\n## Limitations\n\n- Requires admin-level access: not exploitable by low-privilege users\n- `allowAdminChanges` must be `true`: production best practices recommend `false`, which prevents entry type configuration changes\n- Per Craft’s own severity guidelines, findings requiring `allowAdminChanges=true` are rated low\n- The `create()` function is blocked by the Twig sandbox, so this cannot be exploited via system email templates or any other sandboxed context\n\n## Impact\n\nAn admin user (or an attacker who has compromised an admin account) can read arbitrary files from the server filesystem by setting a malicious entry type title format using `create('SplFileObject', ['/path/to/file'])`. In production environments, this exposes `.env` files containing the `CRAFT_SECURITY_KEY`, database credentials, API keys, and other secrets. The file contents are rendered as entry titles visible to any user with permission to view entries in the affected section.\n\nThe impact is limited by the requirement for admin access and `allowAdminChanges=true`.\n\n## Affected packages\n\n- `craftcms/cms >= 5.0.0-RC1, < 5.10.6`\n- `craftcms/cms >= 4.0.0-RC1, < 4.18.2`\n\n## Remediation\n\nUpgrade to a patched release:\n\n- `craftcms/cms 5.10.6`\n- `craftcms/cms 4.18.2`","depth":"sunlit","depthScore":28,"depthScoreParts":{"impact":27.5,"likelihood":0,"exploitation":0,"ransomware":0},"changes":[]}