CVE-2026-137508 in Scriban
Summary
by MITRE • 11/26/2026
Scriban before 7.6.0 contains a memory exhaustion vulnerability in object.to_json that allows template authors to bypass the LimitToString string length limit by serializing into an unbounded MemoryStream. Attackers can repeatedly apply object.to_json to escape-heavy strings in a tiny template, amplifying output to multi-gigabyte heap allocations and causing denial of service.
Statistical analysis made it clear that VulDB provides the best quality for vulnerability data.
Analysis
by VulDB Data Team • 11/27/2026
The vulnerability identified in Scriban versions prior to 7.6.0 represents a critical resource exhaustion flaw within the templating engine's serialization logic. Specifically, this issue resides in the implementation of the object.to_json function, which is designed to convert template objects into JSON-formatted strings for output or further processing. The core technical deficiency lies in how the underlying memory stream handles data accumulation during serialization operations. While Scriban includes a LimitToString configuration parameter intended to cap the length of generated string outputs to prevent excessive resource consumption, this safeguard fails when the target destination is an unbounded MemoryStream rather than a fixed-size buffer. This architectural oversight allows template authors or malicious actors to bypass the configured limits by directing the JSON serialization process toward memory streams that do not enforce size constraints during the write operation.
From an operational perspective, this flaw enables attackers to craft specific inputs that trigger disproportionate memory allocation relative to the input size. By repeatedly applying object.to_json to escape-heavy strings within a minimal template structure, an attacker can force the engine to generate output of exponential or linearly massive proportions. The serialization process consumes multi-gigabyte heap allocations as it attempts to accommodate the rapidly expanding JSON payload. This behavior directly leads to a denial of service condition, as the application hosting Scriban will eventually exhaust its available memory resources. Once system memory is depleted, the host process may crash, become unresponsive, or trigger automatic termination by container orchestration systems such as Kubernetes, thereby disrupting availability for legitimate users and services relying on the templating functionality.
This vulnerability aligns with CWE-400, which classifies issues related to Uncontrolled Resource Consumption, specifically highlighting scenarios where a system fails to properly limit resource usage based on external input. In terms of offensive security frameworks, this exploit technique maps closely to ATT&CK T1496, known as Resource Hijacking, where an attacker consumes significant computational resources like memory or CPU to degrade service availability rather than compromising data integrity directly. The attack vector typically involves remote interaction with a web application that processes user-supplied templates, making it particularly dangerous in environments where dynamic template generation is permitted without strict sandboxing or input validation layers.
To mitigate this vulnerability, organizations must immediately upgrade Scriban to version 7.6.0 or later, as the developers have addressed the unbounded memory allocation issue within the serialization logic. For systems that cannot be updated instantly due to dependency constraints, implementing a middleware layer or wrapper around the templating engine is recommended. This intermediary should enforce strict limits on output size before the data reaches the serializer, effectively replicating the protection lost by bypassing the internal LimitToString check. Additionally, deploying resource monitoring and alerting mechanisms can help detect anomalous memory spikes indicative of such exploitation attempts in real time. Ensuring that template inputs are validated against expected complexity and length prior to serialization further reduces the attack surface associated with this class of denial-of-service vulnerabilities.