CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



GHSA-596P-6JV8-775V

GHSA-596p-6jv8-775v: Authenticated Leak of Secret Environment Variables in Craft CMS

Amit Schendel
Amit Schendel
Senior Security Researcher

Aug 7, 2026·5 min read·15 visits

Executive Summary (TL;DR)

Authenticated users can exfiltrate sensitive environment variables by abusing sequential evaluation of environment parsing and sandboxed Twig templates.

An authenticated information disclosure vulnerability in Craft CMS allows high-privilege administrators to extract sensitive environment variables, including the CRAFT_SECURITY_KEY and database credentials, using a blind error-based template injection attack within element select condition rules.

Vulnerability Overview

In Craft CMS, authenticated administrators or users with access to the Control Panel can configure element select condition rules. These rules utilize input parameters such as elementId in Craft 4 or elementIds in Craft 5 to dynamically filter and select specific content assets or entries.

A previous vulnerability fix, CVE-2026-31857 (GHSA-fp5j-j7j4-mcxc), attempted to secure this input channel by enforcing the use of a sandboxed Twig template rendering engine when processing user-defined inputs. This sandbox was designed to prevent remote code execution via Server-Side Template Injection (SSTI).

Despite the sandbox protection, GHSA-596P-6JV8-775V introduces a validation bypass in the template processing pipeline. An authenticated attacker can exploit the sequence in which inputs are resolved to perform a blind error-based injection attack, ultimately exfiltrating sensitive environment variables from the server config.

Root Cause Analysis

The root cause of this vulnerability lies in a sequence-of-operations flaw where environment variable interpolation occurs before sandboxed template rendering.

When evaluating the condition rule parameters, the application first passes the input string to the App::parseEnv() helper method. This method automatically processes and interpolates environment variables or secrets matching patterns like $ENV_VAR or ${ENV_VAR}.

Immediately following this environment variable interpolation, the resulting string is rendered as a Twig template via renderSandboxedObjectTemplate(). Because the secrets are inserted directly into the string before rendering, Twig parses the resolved secret values as part of the executable template context rather than as plain, non-evaluable text literals.

Although the Twig engine operates within a restricted sandbox that blocks dangerous PHP functions and classes, an attacker can still write standard control flow statements. By crafting conditional statements that check individual characters of the interpolated environment variables, the attacker can trigger runtime execution exceptions based on whether a specific condition is met.

Code Analysis

In vulnerable versions of Craft CMS 4 (pre-4.18.2), the vulnerable flow is located in src/base/conditions/BaseElementSelectConditionRule.php within the getElementId method:

public function getElementId(bool $parse = true): int|string|null
{
    if ($parse && is_string($this->_elementId)) {
        // Step 1: Interpolate environment variables into the string
        $elementId = App::parseEnv($this->_elementId);
        
        if ($this->condition instanceof ElementCondition && isset($this->condition->referenceElement)) {
            $referenceElement = $this->condition->referenceElement;
        } else {
            $referenceElement = new stdClass();
        }
        
        // Step 2: Pass the interpolated string to the template engine
        return Craft::$app->getView()->renderSandboxedObjectTemplate($elementId, $referenceElement);
    }
    return $this->_elementId;
}

The implementation in Craft CMS 5 (pre-5.10.6) reflects the same logical design flaw inside the modified array handler getElementIds:

public function getElementIds(bool $parse = true): array|string
{
    if ($parse && is_string($this->_elementIds)) {
        // Step 1: Interpolation occurs first
        $elementIds = App::parseEnv($this->_elementIds);
        
        if ($this->condition instanceof ElementCondition && isset($this->condition->referenceElement)) {
            $referenceElement = $this->condition->referenceElement;
        } else {
            $referenceElement = new stdClass();
        }
        
        // Step 2: The output of step 1 is compiled
        $elementIds = Craft::$app->getView()->renderSandboxedObjectTemplate($elementIds, $referenceElement);
        
        return array_values(array_filter(array_map(
            fn(string $elementId) => (int)trim($elementId),
            explode(',', $elementIds),
        )));
    }
    return $this->_elementIds;
}

The vulnerability is resolved in the updated releases by adding strict regex checks. If environment variable interpolation alters the initial string, additional Twig templating execution is completely bypassed unless the original input is a simple environment variable format matching /^\$\{?\w+\}?$/.

Exploitation Methodology

An attacker with Control Panel access can exploit this vulnerability using a blind error-based template injection technique. This requires crafting a payload that dynamically evaluates a character of the target variable and triggers a standard PHP runtime error on a match.

The attacker inputs the following payload into a condition rule text field:

{% if "${CRAFT_SECURITY_KEY}"|slice(0, 1) == "a" %}{{ 1/0 }}{% endif %}

When the server processes this rule, App::parseEnv() resolves ${CRAFT_SECURITY_KEY} into its actual plaintext value. The Twig compilation engine then evaluates the comparison expression:

  • Matching Condition: If the first character of the key is 'a', Twig executes {{ 1/0 }}. This produces a DivisionByZeroError, resulting in an HTTP 500 Internal Server Error returned to the attacker.
  • Non-Matching Condition: If the character is not 'a', the template compiles safely to an empty string, yielding an HTTP 200 OK response.

By programmatically adjusting the slice index and testing different characters, an automated script can reconstruct sensitive keys character-by-character.

Impact Assessment

A successful exploit allows the exfiltration of core secrets. The main target of such an attack is the CRAFT_SECURITY_KEY, which is responsible for signing cookies, sessions, and security tokens. Gaining access to this key allows attackers to forge administrative sessions, perform object injection, and potentially escalate permissions to remote code execution.

Additionally, secondary variables such as CRAFT_DB_PASSWORD (database credentials), API keys, and SMTP server passwords can be exfiltrated. This introduces risks of lateral movement and complete compromise of external databases or connected cloud environments.

While this attack requires authenticated access with permissions to define element condition rules, it presents a substantial risk in multi-tenant installations, delegated administration frameworks, or instances compromised via minor entry points.

Remediation and Patch Analysis

To remediate this vulnerability, administrators must update Craft CMS installations to the patched versions immediately.

  • Craft CMS 4.x: Upgrade to version 4.18.2 or higher.
  • Craft CMS 5.x: Upgrade to version 5.10.6 or higher.

The official patch mitigates the flaw by implementing validation checks. The application checks if the environment-resolved string differs from the original. If a change is detected, it only permits rendering if the string contains a single, simple environment variable format without complex syntax structures or Twig delimiters.

If immediate updates are not possible, administrators should restrict Control Panel access to trusted personnel and closely monitor database tables and configuration files for unexpected Twig delimiters inside condition rules.

Official Patches

Craft CMSCraft CMS Release 4.18.2 Official Patch
Craft CMSCraft CMS Release 5.10.6 Official Patch

Technical Appendix

CVSS Score
5.1/ 10
CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N

Affected Systems

Craft CMS 4.x systems prior to 4.18.2Craft CMS 5.x systems prior to 5.10.6

Affected Versions Detail

Product
Affected Versions
Fixed Version
Craft CMS
Pixel & Tonic
>= 4.0.0-RC1, <= 4.18.14.18.2
Craft CMS
Pixel & Tonic
>= 5.0.0-RC1, <= 5.10.55.10.6
AttributeDetail
CWE IDCWE-1336
Attack VectorNetwork
CVSS v4.05.1
ImpactPartial Information Disclosure
Exploit StatusProof-of-Concept
Privileges RequiredHigh (Admin Access)
CISA KEV StatusNo

MITRE ATT&CK Mapping

T1552Unsecured Credentials
Credential Access
T1059Command and Scripting Interpreter: Template Injection
Execution
CWE-1336
Improper Neutralization of Special Elements Used in a Template Engine

Improper Neutralization of Special Elements Used in a Template Engine

Vulnerability Timeline

Security updates Craft CMS 4.18.2 and 5.10.6 released to fix the environment parsing bypass
2026-06-16
GitHub Advisory GHSA-596p-6jv8-775v published detailing the vulnerability
2026-06-16

References & Sources

  • [1]GitHub Security Advisory GHSA-596p-6jv8-775v
  • [2]Craft CMS Core Repository

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

More Reports

•31 minutes ago•CVE-2026-126297
7.5

CVE-2026-126297: Algorithmic Complexity Denial of Service in NLTK ConllCorpusReader

CVE-2026-126297 (GHSA-v8f3-6phw-6mh9) is an uncontrolled resource consumption and algorithmic complexity vulnerability in the Natural Language Toolkit (NLTK) prior to version 3.10.4. Located in the Semantic Role Labeling (SRL) parser within `nltk/corpus/reader/conll.py`, the flaw allows an attacker to trigger quadratic O(N^2) CPU processing overhead by providing crafted CoNLL-formatted corpus inputs containing decoy span columns or nested full-width verb spans. Applications parsing untrusted linguistic corpora can experience prolonged CPU exhaustion and application-level Denial of Service (DoS).

Amit Schendel
Amit Schendel
1 views•12 min read
•about 2 hours ago•CVE-2026-126298
7.5

CVE-2026-126298: Quadratic Algorithmic Complexity Denial of Service in NLTK Tree.chomsky_normal_form

CVE-2026-126298 (also tracked as GHSA-r53h-rw34-8h97) is an algorithmic complexity Denial of Service (DoS) vulnerability in the Natural Language Toolkit (NLTK) Python library affecting all versions prior to 3.10.4. The vulnerability resides in the nltk.tree.transforms.chomsky_normal_form function and its corresponding public method Tree.chomsky_normal_form(). When transforming a parse tree into Chomsky Normal Form using the default right-factoring strategy, the function repeatedly invokes list.pop(0) inside a loop iterating over all children of a node. In CPython, removing the initial element of a standard list requires an O(N) memory shift operation, causing the overall binarization algorithm to degrade to O(N^2) quadratic time complexity relative to the width of a node. Furthermore, converting horizontal node width into vertical tree depth bypasses initial parsing depth bounds, triggering subsequent stack exhaustion (RecursionError) when recursive methods traverse the mutated structure. Unauthenticated remote attackers who can submit bracketed tree strings to applications invoking this transformation can exhaust single-threaded CPU resources or induce unhandled application exceptions.

Alon Barad
Alon Barad
3 views•12 min read
•about 3 hours ago•CVE-2026-126299
7.5

CVE-2026-126299: Quadratic Algorithmic Complexity Denial of Service in NLTK CCG Lexicon Parser

An algorithmic complexity vulnerability (CWE-407) in the Natural Language Toolkit (NLTK) before version 3.10.4 allows remote unauthenticated attackers to cause a denial of service via crafted Combinatory Categorial Grammar (CCG) lexicon strings. The parser in nltk.ccg.lexicon.fromstring performs repeated immutable string slicing, concatenation, and regex tail capturing, resulting in O(n^2) CPU consumption when processing wide, flat category definitions.

Alon Barad
Alon Barad
4 views•10 min read
•about 4 hours ago•CVE-2026-126295
7.1

CVE-2026-126295: Path Traversal and Unconfined File Access in NLTK BllipParser

CVE-2026-126295 (also tracked as GHSA-fg9w-wfp5-j933) is a path confinement bypass vulnerability in the Natural Language Toolkit (NLTK) affecting versions 3.10.0 prior to 3.10.4. The flaw resides in nltk/parse/bllip.py within the BllipParser class and its factory method BllipParser.from_unified_model_dir(). Unlike sibling tool wrappers in NLTK that enforce data-root confinement via the nltk.pathsec module, BllipParser passes caller-supplied filesystem paths directly into the third-party bllipparser native C extension without validation. When an application passes untrusted input as model paths or directories to BllipParser, an attacker can force the native extension to open arbitrary files on the local filesystem. This leads to information disclosure through parser diagnostic oracles, local model tampering via shared directories, and denial of service by hanging worker threads on blocking special files (such as FIFOs or device nodes) or exhausting memory via oversized files.

Amit Schendel
Amit Schendel
2 views•11 min read
•about 5 hours ago•CVE-2026-126300
5.3

CVE-2026-126300: Algorithmic Complexity Denial of Service in NLTK TreebankWordTokenizer.span_tokenize

CVE-2026-126300 (GHSA-ffr9-mgrr-wcvr) is an inefficient algorithmic complexity vulnerability (CWE-407) in the Natural Language Toolkit (NLTK) Python library affecting versions 3.2.5 prior to 3.10.4. The flaw resides in the quote-restoration routine of TreebankWordTokenizer.span_tokenize and NLTKWordTokenizer.span_tokenize, where repeated calls to list.pop(0) over matched quote tokens introduce quadratic O(n^2) time complexity. An unauthenticated remote attacker who supplies input containing long sequences of double-quote characters can exhaust CPU resources and degrade service availability.

Amit Schendel
Amit Schendel
3 views•10 min read
•about 6 hours ago•GHSA-GPWC-27CW-RH9R
5.3

CVE-2026-126301: Quadratic CPU Exhaustion in NLTK LegalitySyllableTokenizer

The Natural Language Toolkit (NLTK) versions 3.6 through 3.10.3 contain an algorithmic complexity vulnerability in the LegalitySyllableTokenizer.tokenize method. When processing tokens composed of continuous runs of vowels, an unguarded string reversal and set membership lookup loop executes in quadratic time relative to the input token length. Remote attackers capable of submitting arbitrary text to applications utilizing this tokenizer can trigger sustained single-core CPU exhaustion and application-level denial of service.

Amit Schendel
Amit Schendel
5 views•10 min read