GHSA-28WR-XHQR-9MF4
String builtins bypass the string length limit and cause memory exhaustion
Texto original en inglés · Ver en español
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-28WR-XHQR-9MF4 divulgada · CVSS 7.5 (GitHub) | |
| Remediación | Parche 7.6.0 | Scriban · 0 d desde divulgación | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
Under the default `TemplateContext`, these builtins can allocate far beyond `LimitToString`. `string.literal` is a missed sibling of the guarded `string.escape`.
Details
`StringFunctions.Literal` (`src/Scriban/Functions/StringFunctions.cs:430-433`) calls the unguarded static `Escape()` and has no `TemplateContext` parameter. `Base64Encode` (`StringFunctions.cs:1398-1401`) and `HtmlFunctions.Escape`/`NewlineToBr`/`UrlEncode`/`UrlEscape` (`HtmlFunctions.cs:68-75`, `93-101`, `120-127`, `145-187`) likewise lack allocation guards. Repeated `literal` calls double the string each pass; repeated base64 grows by ~4/3; HTML expansion is up to ~7x per pass.
Proof of concept
Default context, no host objects:
var ctx = new TemplateContext(); // defaults: LimitToString = 1048576
ctx.PushGlobal(new ScriptObject()); // nothing exposed
var template = """{{ s = '\\' * 100000; for i in 1..15; s = s | string.literal; end; s | string.size }}""";
Template.Parse(template).Render(ctx);Observed:
MODE=literal EX ScriptRuntimeException: ... OutOfMemoryException ... peakWS=7232MBA single call with 1 MB of backslashes returns `2000002` chars (limit `1048576`). The same omission affects `string.base64_encode` (559,999,800 chars, ~5 GB peak after 30 passes) and `html.escape` (41,000,000 chars, ~688 MB peak after 10 passes).
Impact
A <100-byte template forces multi-GB allocations and can OOM-kill the host. Same class as GHSA-95w2-9mjq-6c74.
Remediation in Scriban 7.6.0
Upgrade either distribution, Scriban or Scriban.Signed, to 7.6.0 or later.
Templates now use context-aware guarded overloads of string.literal, string.base64_encode, html.escape, html.newline_to_br, html.url_encode, and html.url_escape. Guards account for escaped text, UTF-8/Base64 expansion, HTML entities, CRLF, and Unicode URL encoding. Existing contextless C# overloads remain available for binary compatibility and do not apply context limits.
No CVE identifier is requested for this advisory.
_Remediation notes and package metadata updated by CodeAlta._
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
nugetScriban |
Corregida | 7.6.0 | 0 d | 7.6.1 no afectada |
nugetScriban.Signed |
Corregida | 7.6.0 | 0 d | 7.6.1 no afectada |
7.6.0Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/scriban/scriban/security/advisories/GHSA-28wr-xhqr-9mf4Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
