Executive brief
Scriban is a templating engine used in applications to safely render user-controlled templates. A flaw allows attackers to bypass the LoopLimit safety mechanism—a resource constraint designed to prevent templates from consuming excessive CPU or memory—by crafting single expressions that iterate internally without triggering the safety check. An attacker can submit malicious template code that forces millions of iterations or gigabytes of memory allocation, causing denial of service even when LoopLimit is set to permit only one iteration.
Technical details
Scriban's LoopLimit constraint is enforced only during script loop statement execution via TemplateContext.StepLoop(), but built-in operations like array iteration and string multiplication perform expensive internal work without invoking this check. A ScriptRange created from expressions like 1..1000000 yields elements sequentially without calling StepLoop(), and string multiplication in ScriptBinaryExpression.CalculateToString() uses a plain for loop unguarded by LoopLimit. Attackers with the ability to submit template content can exploit this with expressions such as {{ 1..1000000 | array.size }} or {{ 'A' * 200000000 }} to trigger uncontrolled resource consumption regardless of the configured LoopLimit value. The vulnerability affects any application rendering untrusted templates that relies on LoopLimit for containment. A patch is available in version 7.0.0.
Affected products
- Scriban Scriban <= 6.6.0
Timeline
- 2026-03-22: disclosed
- 2026-08-16: advisory
- 2026: patched: Version 7.0.0