# GHSA-86PR-X856-XRQ5: Overview On the async render path (renderFile(path, locals, cb) with a loader that sets loader.async, or compileFile with codegenMode: 'async'), nothing limited how deeply templates could nest

- Database: GitHub
- Severity: CVSS 7.5 (High)
- Published: 2026-10-25
- Modified: 2026-10-25

## Affected versions

- @rhinostone/swig-core (npm): from 2.2.0, fixed in 2.9.5
- @rhinostone/swig (npm): from 2.2.0, fixed in 2.9.5
- @rhinostone/swig-twig (npm): from 2.2.0, fixed in 2.9.5
- @rhinostone/swig-jinja2 (npm): from 2.5.0, fixed in 2.9.5
- @rhinostone/swig-django (npm): from 2.7.0, fixed in 2.9.5

## Description

### Overview
On the async render path (`renderFile(path, locals, cb)` with a loader that sets `loader.async`, or `compileFile` with `codegenMode: 'async'`), nothing limited how deeply templates could nest. A template that includes, imports or extends itself, directly or through other templates, therefore loaded and compiled templates without end:

- an extends cycle (`a.html` extends `b.html`, which extends `a.html`), or a dynamic `{% extends layout %}` whose value names the template itself;
- a template that includes itself, with a literal path or with a path taken from the template data (`{% include partial %}`);
- an import or from-import cycle (`a.html` imports `b.html`, which imports `a.html`).

Each round loads one more template and the heap keeps growing until V8 aborts the process with "JavaScript heap out of memory", which a program cannot catch. Under a 64 MB heap, @rhinostone/swig 2.9.4 aborted after 11 to 14 seconds and 22,000 to 26,000 template loads on an extends cycle, on a template that includes itself through a path from the data, and on an import cycle; with a larger heap it takes longer and ends the same way.

The sync render path is not affected: it ends these renders (an extends cycle fails with "Illegal circular extends", a template that includes or imports itself with a stack overflow).

### Impact
Availability only (no confidentiality or integrity impact). In an application that renders on the async path and takes an include or extends path from the request, such as a page or partial name, a single request naming a template that includes or extends itself can abort the Node.js process. A template mistake has the same effect without any request data.

### Affected & patched
- @rhinostone/swig-core >= 2.2.0, < 2.9.5: the async render path's template loading.
- @rhinostone/swig >= 2.2.0, < 2.9.5 and @rhinostone/swig-twig >= 2.2.0, < 2.9.5.
- @rhinostone/swig-jinja2 >= 2.5.0, < 2.9.5 and @rhinostone/swig-django >= 2.7.0, < 2.9.5 (since their first releases).

Fixed in 2.9.5: each top-level async render counts the templates it has in progress. Loading a template while 1000 are in progress fails the render with `Template "<name>" is nested more than 1000 levels deep: a template probably includes, imports or extends itself.`, and an extends cycle fails at once with `Illegal circular extends of "<name>".`, the sync path's message. A recursive include therefore renders 1000 levels deep and fails at 1001, which rendered before. An include marked `ignore missing` swallows that error, as it swallows any error of the template it includes, so a template that includes itself under `ignore missing` now ends after 1000 levels. The 2.9.5 frontends require @rhinostone/swig-core 2.9.5, so upgrade the packages together.

### Workarounds
- Upgrade to 2.9.5 or later.
- Otherwise, on the async render path, do not pass a template path taken from untrusted data to an include or an extends.

### References
- Fix: https://github.com/gina-io/swig/commit/429ba8696d02fc469d27fd14faa293075320288e
- Release notes: https://github.com/gina-io/swig/blob/v2.9.5/HISTORY.md

## References

- https://github.com/gina-io/swig/security/advisories/GHSA-86pr-x856-xrq5

Page: https://cve.now/GHSA-86PR-X856-XRQ5

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
