# GHSA-25W8-77GG-4CCW: Overview Data passed to one render could reach other renders in three ways, all fixed in 2.9.6

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

## Affected versions

- @rhinostone/swig-core (npm): fixed in 2.9.6
- @rhinostone/swig (npm): fixed in 2.9.6
- @rhinostone/swig-twig (npm): fixed in 2.9.6
- @rhinostone/swig-jinja2 (npm): fixed in 2.9.6
- @rhinostone/swig-django (npm): fixed in 2.9.6

## Description

### Overview
Data passed to one render could reach other renders in three ways, all fixed in 2.9.6.

**1. Locals in the options of a cached compile.** With the default memory cache (`cache: 'memory'`), or a custom `{ get, set }` cache object, `compile(source, options)` caches the compiled template under `options.filename`, and the cached function kept the `locals` given in the options of the call that created it. A later `render`, `compile` or `compileFile` of the same file returned that function: `render(source, { filename, locals })` rendered the first call's locals on every later call, and a later caller that passed its own locals got the first call's locals merged under them. The same function also served a later `renderFile` of that file and an `{% include %}` of it from another template. `render(source, { filename, locals })` is the shape the API documentation shows for rendering a template string whose `include`, `extends` or `import` must resolve: if an application renders a page from a string with `filename` set and the current user's data in `locals`, every later request for that page shows the first user's data until the cache is cleared or the process restarts. This case does not arise with `cache: false`, in the runtime-only build, or when every call passes its data when the template runs (`renderFile(path, locals)`, `compile(source, options)(locals)`) and no call puts locals in the options of a compile of that file.

**2. An instance's default locals.** A render without call-time locals on an instance with default locals (`new Swig({ locals })` or `setDefaults({ locals })`), and `run(tpl)` without locals, used the defaults object itself as the template's context. The names a template set (`{% set %}`, macros, imports, loop variables, Django `{% cycle %}` state) stayed in that object and reached every later render of every template on that instance, and instances built without their own locals share one defaults object, so `run` on one instance reached the others. With a request-scoped helper in the default locals, such as one that reads the current user from `AsyncLocalStorage`, one of two concurrent renders on the async render path showed the other's data.

**3. A locals object passed to more than one render.** On an instance without default locals, a render used the locals object the caller passed (`renderFile(path, locals)`, `compileFile(path)(locals)`, `compile(source)(locals)`, a template stored with `register`) as the template's context, so the names the template set landed in that object: a later render given the same object read them, and two concurrent renders on the async render path given one object read each other's. With a request-scoped helper in that object, one user's page showed another user's data.

### Impact
Data passed to one render, often the data of one user, appears in renders made for other callers. How much this matters depends on what an application passes in its locals, whether it passes one object to several renders, and whether its default locals hold request-scoped values.

### Affected & patched
Every release of @rhinostone/swig-core, @rhinostone/swig, @rhinostone/swig-twig, @rhinostone/swig-jinja2 and @rhinostone/swig-django before 2.9.6; the code dates from the original swig 1.4.2. The concurrent cases need the async render path: native swig and swig-twig have it since 2.2.0 and swig-jinja2 since its first release, 2.5.0; in swig-django they need a loop holding an include, which renders on that path since 2.9.4.

Fixed in 2.9.6:
- the cache keeps a function without the locals of the call that created it, and each compile or compileFile call that passes locals gets a function that applies them, each call starting from a fresh context;
- a render without call-time locals, and `run` without locals, work on a copy of the default locals;
- a render works on a copy of the locals object the caller passes, made at its top. A template rendered as part of the render, such as an include, still shares its includer's context, so an include's sets still reach the page.

Three cases still write into the object they are given: a template rendered from inside another render of the same instance (a helper that renders a partial with an object of its own), an include given an object with `with … only`, and a dotted set such as `{% set site.user = who %}`, since the copy is shallow. The fixes change how the engine passes locals to a template, not the code it generates for one. The 2.9.6 frontends require @rhinostone/swig-core 2.9.6, so upgrade the packages together.

### Workarounds
- Upgrade to 2.9.6 or later.
- Otherwise, give every render, `run` included, a fresh locals object of its own (on an instance with default locals, a render given call-time locals already worked on a merged copy), pass the data when the template runs (`compile(source, { filename })(locals)` or `renderFile(path, locals)`) instead of in the options of a compile, or set `cache: false`.

### References
- Fixes: https://github.com/gina-io/swig/commit/11c75a17c08d2eee39f4018cd0b55c175aca6c75, https://github.com/gina-io/swig/commit/1ea6044d9e8df1fb5871c59452b49175a74e8724 (with https://github.com/gina-io/swig/commit/89d359534b8f156e4fdfdb55c360cb287d1cf31d and https://github.com/gina-io/swig/commit/8f71bf88b919343308303b2e8db7e2c9043cc649) and https://github.com/gina-io/swig/commit/f3fa589c5c61b64b21f1d3ce244c2bd5ec07ba0c
- Release notes: https://github.com/gina-io/swig/blob/v2.9.6/HISTORY.md

## References

- https://github.com/gina-io/swig/security/advisories/GHSA-25w8-77gg-4ccw

Page: https://cve.now/GHSA-25W8-77GG-4CCW

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