GHSA-596p-6jv8-775v: SQL Injection

Published Aug 6, 2026
·
Updated

Environment variables and secrets are interpolated into a Twig template even when the Twig sandbox is enabled, allowing them to be leaked by an authenticated attacker.

The Craft vulnerability CVE-2026-31857 was only patched by applying sandboxed Twig templating. This theoretically protects Craft CMS against RCE attacks, provided the sandbox is enabled and secure, with no known bypasses.

However, the same request parameter elementId, which allows for sandboxed Twig templates to be rendered, also includes functionality that interpolates referenced environment variables. If the parameter includes a string of the form ${ENVVAR} then the string is replaced with the environment variable or secret from a secrets file with that name.

Afterward, the string is rendered as a Twig template. If the sandbox is disabled, Twig templates can already gain RCE or access environment variables using the getenv function. Sandboxed Twig templates should not have this access, but now do thanks to this additional environment-variable replacement behavior.

The template’s resulting value is not directly reflected in the response. To exfiltrate the value, the sandboxed Twig template cannot use network functions. But it can use a blind error-based approach similar to blind SQL injection. With enough requests, any environment variable or secret can be incrementally leaked. This can be abused to forge a session, escalate privileges with the CRAFTSECURITYKEY, and steal credentials for the database, SMTP server, or other connected APIs or blob storage.

Impact

An authenticated attacker, with permission to access the control panel, can render a malicious Twig template and steal arbitrary environment variables and secrets with a large number of requests, even if the Twig sandbox is enabled through enableTwigSandbox().

Affected Software

2 affected componentsFixes available
composer/craftcms/cms>=4.0.0-RC1<4.18.2
4.18.2
composer/craftcms/cms>=5.0.0-RC1<5.10.6
5.10.6

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade composer/craftcms/cms to a version that resolves this vulnerability.

    Fixed in 4.18.2
  2. Upgrade

    Upgrade composer/craftcms/cms to a version that resolves this vulnerability.

    Fixed in 5.10.6

Event History

Aug 6, 2026
Advisory Published
via GitHub·09:53 PM
Data Sourced
via GitHub·09:53 PM
DescriptionWeaknessAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of GHSA-596p-6jv8-775v?

The severity of GHSA-596p-6jv8-775v is rated as 73.

2

What type of vulnerability is GHSA-596p-6jv8-775v?

GHSA-596p-6jv8-775v is categorized as a risk allowing for potential leakage of secrets through Twig templates.

3

Who is affected by GHSA-596p-6jv8-775v?

GHSA-596p-6jv8-775v affects users of Craft CMS, particularly those using Twig templating with environment variables.

4

How do I fix GHSA-596p-6jv8-775v?

To fix GHSA-596p-6jv8-775v, update your Craft CMS to version 4.18.2 or 5.10.6 or later.

5

What are the consequences of GHSA-596p-6jv8-775v?

The consequences of GHSA-596p-6jv8-775v include the risk of sensitive information being leaked by an authenticated attacker.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203