# GHSA-48RG-VG49-R5VM: @rhinostone/swig-jinja2 and @rhinostone/swig-twig: unbounded loop (denial of service) in wordwrap and range from template data

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

## Affected versions

- @rhinostone/swig-jinja2 (npm): fixed in 2.8.2
- @rhinostone/swig-twig (npm): from 2.0.0-alpha.5, fixed in 2.8.2
- @rhinostone/swig-core (npm): from 2.0.0-alpha.5, fixed in 2.8.2

## Description

### Overview
Two code paths could be driven into an unbounded loop by data supplied at render time (template locals), exhausting memory and hanging the Node.js process:
1. swig-jinja2 `wordwrap` with a width below 1 (0, a negative number, or a string such as `"0"`) ran for seconds and consumed more than 2 GB of memory before a RangeError. Present since swig-jinja2 2.5.0, its first release.
2. swig-twig ranges `a..b` with an infinite bound (plain JSON yields `Infinity` for a number such as `1e999`) looped until the array overflowed, taking seconds and more than 2 GB. Present since 2.0.0-alpha.5, in the shared swig-core range helper that swig-twig calls.

The native @rhinostone/swig frontend has neither the `wordwrap` filter nor the `..` operator, and swig-django's `wordwrap` does not loop.

### Impact
Availability only (no confidentiality or integrity impact). In an application that passes request data into a `wordwrap` width or a range bound, a single request can hang the process for seconds and make it allocate more than 2 GB.

### Affected & patched
Affected: @rhinostone/swig-jinja2 < 2.8.2; @rhinostone/swig-twig and @rhinostone/swig-core >= 2.0.0-alpha.5, < 2.8.2. Fixed in 2.8.2: `wordwrap` returns the input unchanged for a width of 0 or less and breaks one character at a time for a width between 0 and 1; the range helper returns an empty range for a bound that is not finite, as it already did for NaN.

### Workarounds
- Upgrade to 2.8.2 or later.
- Validate or clamp a `wordwrap` width and a range bound taken from untrusted data.

### References
- wordwrap fix — https://github.com/gina-io/swig/commit/0d7b518dcc2dbacd64265bb09ce5cb8e26422992
- range fix — https://github.com/gina-io/swig/commit/b381a278e0e6b18426c598df23479fac557e2e2b

## References

- https://github.com/gina-io/swig/security/advisories/GHSA-48rg-vg49-r5vm

Page: https://cve.now/GHSA-48RG-VG49-R5VM

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