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-WGH7-7M3C-FX25
7.5

GHSA-WGH7-7M3C-FX25: Uncontrolled Recursion leading to Denial of Service in Scriban Parser

Alon Barad
Alon Barad
Software Engineer

Mar 20, 2026·5 min read·4 visits

PoC Available

Executive Summary (TL;DR)

Scriban versions prior to 6.6.0 fail to enforce default recursion depth limits during template parsing and object evaluation. Deeply nested template syntax exhausts the thread stack, causing the .NET host application to terminate immediately. The vulnerability is remediated in version 6.6.0 by enforcing safe default limits on expression depth, object recursion, and output buffer size.

The Scriban templating engine prior to version 6.6.0 contains an uncontrolled recursion vulnerability in its recursive-descent parser. Attackers providing maliciously nested templates can trigger a StackOverflowException, resulting in an unrecoverable process crash and complete denial of service.

Vulnerability Overview

The Scriban templating engine prior to version 6.6.0 contains an uncontrolled recursion vulnerability (CWE-674). Applications parsing untrusted templates using affected versions expose an unauthenticated denial-of-service attack vector. The vulnerability originates from the engine's recursive-descent parser, which processes template syntax without enforcing default structural depth limits.

When the parser encounters specific syntactic elements, it allocates stack frames proportional to the nesting depth of the input. Without a boundary limit, malicious inputs rapidly consume the available thread stack space. This mechanism reliably triggers a process-level crash in the hosting .NET application.

The attack surface extends beyond template parsing into the object graph evaluation phase. The evaluation logic lacked default constraints on object recursion and output buffer sizes. Attackers exploiting this secondary vector induce memory exhaustion, compounding the availability impact on the host system.

Root Cause Analysis

Scriban implements a recursive-descent parser to evaluate template expressions. The parser relies on method recursion to handle nested syntactical structures, such as parenthesized groups or member access chains. Each nested element invokes the EnterExpression() method, adding a new frame to the execution call stack.

In versions prior to 6.6.0, the ExpressionDepthLimit property within ParserOptions was defined as a nullable integer and initialized to null. The parser logic did not perform boundary checks against the recursion depth unless developers explicitly configured a limit. Consequently, the parser unconditionally traversed maliciously nested input strings.

The .NET runtime handles thread stack exhaustion by throwing a StackOverflowException. This specific exception is non-recoverable and terminates the host process immediately without allowing exception handling blocks to execute. A separate flaw in TemplateContext.cs allowed unbounded object graph traversal during string serialization, as ObjectRecursionLimit and LimitToString defaulted to zero.

Code Analysis

The vulnerability stems from missing default limits in configuration classes and the absence of boundary enforcement in the parsing routines. The fix spans two primary commits to enforce safety boundaries globally. The first commit (a6fe6074199e5c04f4d29dc8d8e652b24d33e3e4) establishes safe default limits within the configuration objects.

// Vulnerable state: ParserOptions.cs
public int? ExpressionDepthLimit { get; set; } = null;
 
// Patched state: ParserOptions.cs
public int? ExpressionDepthLimit { get; set; } = 250;

The second commit (b5ac4bf30459fdc76964e3f751e16f7e96079ea7) modifies the parser itself to enforce the depth limit actively, ensuring backward compatibility for users who explicitly passed null to bypass checks.

// Patched state: Parser.Expressions.cs
private void EnterExpression() {
    var limit = Options.ExpressionDepthLimit ?? 250;
    if (CurrentDepth > limit) {
        // Throw safe parser error instead of StackOverflowException
    }
    CurrentDepth++;
}

Additionally, limits were applied to the evaluation context to prevent Out-Of-Memory (OOM) conditions during object resolution. The LimitToString property now caps output buffers at 1,048,576 characters (1MB), and ObjectRecursionLimit restricts graph traversal depth to 20 levels.

Exploitation

Exploitation requires the attacker to submit a crafted template string to an endpoint that processes input using Template.Parse(). No authentication is necessary if the application exposes template functionality to anonymous users. The attack relies solely on creating deep syntactic nesting.

The core exploitation technique leverages consecutive grouping characters. By opening thousands of parentheses without closing them, the attacker forces the parser into deep recursion. The following proof-of-concept constructs an excessively nested string that crashes the parsing process.

// Proof of Concept generating 10,000 nested layers
var templateText = new string('(', 10000) + "1" + new string(')', 10000);
Template.Parse(templateText);

Upon executing Template.Parse(), the host process immediately throws a StackOverflowException. The application terminates, dropping all current connections and ceasing to process further requests. Alternative payloads include nested if statements or recursive wrap blocks to achieve identical denial-of-service conditions.

Impact Assessment

The vulnerability yields a complete loss of availability, reflected in the CVSS score of 7.5 (High). An attacker requires minimal resources to crash the targeted service. The impact is systemic, affecting the entire application hosting the Scriban engine.

The use of StackOverflowException is particularly lethal in the .NET runtime environment. Unlike standard runtime exceptions, stack overflows cannot be caught using standard try-catch blocks. The CLR enforces immediate process termination to preserve memory integrity.

Applications functioning as multi-tenant platforms or rendering user-supplied markdown and templates are highly susceptible. The secondary OOM vectors similarly result in process termination or extreme performance degradation, requiring manual restarts of the affected service containers or processes.

Remediation

The primary remediation strategy requires upgrading the Scriban NuGet package to version 6.6.0 or later. This release introduces enforced safe defaults for both parsing depth and evaluation buffer sizes. The update does not introduce breaking API changes, allowing seamless integration for existing implementations.

If immediate patching is not technically feasible, developers must manually enforce configuration limits before parsing untrusted input. The ParserOptions and TemplateContext objects must be instantiated with explicit boundaries prior to invocation.

// Manual Mitigation Pattern
var options = new ParserOptions { ExpressionDepthLimit = 250 };
var context = new TemplateContext { 
    ObjectRecursionLimit = 20,
    LimitToString = 1048576 
};

Security teams should implement static code analysis rules to detect instances of Template.Parse() or Template.Render() operating without custom configuration limits on older package versions. Monitoring for unexpected process terminations accompanied by stack overflow event logs serves as a reactive detection mechanism.

Official Patches

ScribanPrimary Fix Commit

Fix Analysis (2)

Technical Appendix

CVSS Score
7.5/ 10
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

Affected Systems

Scriban NuGet Package (< 6.6.0).NET applications utilizing Scriban for template rendering

Affected Versions Detail

Product
Affected Versions
Fixed Version
Scriban
Alexandre Mutel (xoofx)
< 6.6.06.6.0
AttributeDetail
Vulnerability ClassUncontrolled Recursion (CWE-674)
Attack VectorNetwork (Remote)
CVSS v3.1 Score7.5 (High)
ImpactDenial of Service (Process Crash)
Authentication RequiredNone
Exploit StatusProof of Concept Available

MITRE ATT&CK Mapping

T1499.004Endpoint Denial of Service: Application or System Exploitation
Impact
T1190Exploit Public-Facing Application
Initial Access
CWE-674
Uncontrolled Recursion

The program does not properly control the amount of recursion that takes place, consuming excessive resources, such as allocated memory or the program stack.

Known Exploits & Detection

Advisory PoCProof of concept demonstrating stack exhaustion via nested parentheses.

Vulnerability Timeline

Fix Commits Authored
2024-03-15
Scriban 6.6.0 Published to NuGet
2024-03-19

References & Sources

  • [1]GitHub Advisory: GHSA-WGH7-7M3C-FX25
  • [2]Scriban Repository
  • [3]Fix Commit 1
  • [4]Fix Commit 2
  • [5]GitLab Advisory Entry

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.