# GHSA-RVX7-JQR9-C242: Overview Several template filters used regular expressions that take time quadratic in the length of their input on some inputs

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

## Affected versions

- @rhinostone/swig (npm): fixed in 2.9.1
- @rhinostone/swig-twig (npm): from 2.0.0-alpha.3, fixed in 2.9.1
- @rhinostone/swig-jinja2 (npm): from 2.5.0, fixed in 2.9.1
- @rhinostone/swig-django (npm): from 2.7.0, fixed in 2.9.1

## Description

### Overview
Several template filters used regular expressions that take time quadratic in the length of their input on some inputs. A template that applied one of them to data supplied at render time (template locals) could be made to block the Node.js event loop for seconds:

1. `striptags`, in every flavor, on text with many `<` and no `>` after them; in swig-jinja2 also on many `<!--` with no `-->` after them.
2. `trim`, in swig-twig and swig-jinja2, on a long run of the trimmed characters inside the text.
3. swig-jinja2 `format`, on a format string (the filter's input) with a `%` followed by a long run of zeros.
4. swig-django `truncatewords` and `pluralize` on a long run of whitespace inside the value, `slugify` on a long run of underscores, and `floatformat` on an argument with a long run of `g` or `u` not at its end.

Rendered through a template on 100 000 characters, each took 3 to 7.5 seconds in 2.9.0 (swig-jinja2 `striptags` on `<!--` about 1.2 seconds, swig-jinja2 `format` about 23 seconds). In 2.9.1 the same inputs take a few milliseconds and give the same output.

### Impact
Availability only (no confidentiality or integrity impact). In an application that applies one of these filters to request data, a single request carrying a crafted value of about 100 000 characters can block the process for seconds.

### Affected & patched
- @rhinostone/swig < 2.9.1: `striptags`. The regex dates from the original project, so every release has it.
- @rhinostone/swig-twig >= 2.0.0-alpha.3, < 2.9.1: `striptags`, `trim`.
- @rhinostone/swig-jinja2 >= 2.5.0, < 2.9.1: `striptags`, `trim`, `format`.
- @rhinostone/swig-django >= 2.7.0, < 2.9.1: `striptags`, `truncatewords`, `slugify`, `floatformat`, and `pluralize` since 2.8.2.

Fixed in 2.9.1: the filters use linear-time helpers added to @rhinostone/swig-core 2.9.1 and give the same output as before. @rhinostone/swig-core has no vulnerable filter itself; the 2.9.1 frontends require swig-core 2.9.1, so upgrade the packages together.

### Workarounds
- Upgrade to 2.9.1 or later.
- Otherwise, cap the length of request data before passing it to these filters, or do not apply them to untrusted values.

### References
- swig-core helpers — https://github.com/gina-io/swig/commit/bfd9e447d33716b4b84cf17bc5fe50c2b5416e4f
- swig — https://github.com/gina-io/swig/commit/947852139523b26f4dc23ae8833f7a2004670f79
- swig-twig — https://github.com/gina-io/swig/commit/732612ae75896dafa5c166ed5a0b2e20c83d4aac
- swig-jinja2 — https://github.com/gina-io/swig/commit/00154bedbbed0501074ba872e25f09d82558548b
- swig-django — https://github.com/gina-io/swig/commit/f273f2ec66630778e684df5972f20bd845cad0ff
- Release notes — https://github.com/gina-io/swig/blob/v2.9.1/HISTORY.md

## References

- https://github.com/gina-io/swig/security/advisories/GHSA-rvx7-jqr9-c242

Page: https://cve.now/GHSA-RVX7-JQR9-C242

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