GHSA-957R-QF9P-67XW

Vulnerability from github – Published: 2026-08-06 21:54 – Updated: 2026-08-06 21:54
VLAI
Summary
Craft CMS: Arbitrary file read via SplFileObject in non-sandboxed template contexts
Details

The 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.

The sandbox correctly blocks create() in system email templates, so this finding applies only to admin-configured, non-sandboxed contexts that require allowAdminChanges=true.

Prerequisites

  • Admin access to the Craft control panel
  • allowAdminChanges must be true (default in dev/staging, recommended false in production)
  • Admin must be able to edit entry type settings (title format, URI format)
  • Any user who subsequently creates an entry in the affected section triggers the file read

Limitations

  • Requires admin-level access: not exploitable by low-privilege users
  • allowAdminChanges must be true: production best practices recommend false, which prevents entry type configuration changes
  • Per Craft’s own severity guidelines, findings requiring allowAdminChanges=true are rated low
  • The create() function is blocked by the Twig sandbox, so this cannot be exploited via system email templates or any other sandboxed context

Impact

An 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.

The impact is limited by the requirement for admin access and allowAdminChanges=true.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "Packagist",
        "name": "craftcms/cms"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "5.0.0-RC1"
            },
            {
              "fixed": "5.10.6"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    },
    {
      "package": {
        "ecosystem": "Packagist",
        "name": "craftcms/cms"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "4.0.0-RC1"
            },
            {
              "fixed": "4.18.2"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [],
  "database_specific": {
    "cwe_ids": [
      "CWE-184"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-08-06T21:54:45Z",
    "nvd_published_at": null,
    "severity": "MODERATE"
  },
  "details": "The `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\u2019s 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(\u0027SplFileObject\u0027, [\u0027/path/to/file\u0027])`. 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`.",
  "id": "GHSA-957r-qf9p-67xw",
  "modified": "2026-08-06T21:54:45Z",
  "published": "2026-08-06T21:54:45Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/craftcms/cms/security/advisories/GHSA-957r-qf9p-67xw"
    },
    {
      "type": "WEB",
      "url": "https://github.com/craftcms/cms/commit/7c96fd73df936a10e8f85ae6ef61a9fc3f277c12"
    },
    {
      "type": "WEB",
      "url": "https://github.com/craftcms/cms/commit/87978f11c8f986c40ef41b941d79547230c4d6d9"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/craftcms/cms"
    },
    {
      "type": "WEB",
      "url": "https://github.com/craftcms/cms/releases/tag/4.18.2"
    },
    {
      "type": "WEB",
      "url": "https://github.com/craftcms/cms/releases/tag/5.10.6"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N",
      "type": "CVSS_V4"
    }
  ],
  "summary": "Craft CMS: Arbitrary file read via SplFileObject in non-sandboxed template contexts"
}



Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.

Sightings

Author Source Type Date Other

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.

Loading…

Detection rules are retrieved from Rulezet.

Loading…

Loading…