GHSA-5rpf-x9jg-8j5p json
Scriban Affected by Memory Exhaustion (OOM) via Unbounded String Generation (Denial of Service)
published 7mo ago modified 4mo ago
- cvss
- 5.3
- version 3.1, GitHub
- cisa kev
- Not listed
- not in CISA's catalog
- epss
- —
- no score, EPSS covers CVEs only
- public exploits
- 0
- none known
Summary
`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.
```csharp 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).
```csharp public int LimitToString { get; set; } = 1048576; ```
Patch / fix
Is GHSA-5rpf-x9jg-8j5p in your dependencies? Fencer shows which of your repositories are affected as soon as an advisory lands, and opens the fix as a pull request.
Check with FencerCVSS scores
| assigned by | version | score | vector |
|---|---|---|---|
| GitHub | 3.1 | 5.3 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L |
Affected packages
| ecosystem | package | affected | fixed in |
|---|---|---|---|
| nuget | scriban | <6.6.0 |
6.6.0 |
| nuget | Scriban.Signed | <6.6.0 |
6.6.0 |
Classification
- Weakness
-
- CWE-770 Allocation of Resources Without Limits or Throttling
References
Sources
- GitHub Advisory GHSA-5rpf-x9jg-8j5p
Fencer Intel keeps one entry per vulnerability: the CVE id wins, then GHSA, and records that alias each other are merged, except that two CVEs always keep separate entries. The same data is available as JSON.