Alta

@rhinostone/swig: arbitrary local file read via include/extends path traversal

  • Publicada: 18.08.2026
  • Actualizado: 11.10.2026 10:22

Overview

@rhinostone/swig is a maintained fork of the abandoned swig template engine and inherited the directory-traversal vulnerability tracked upstream as CVE-2023-25345 / GHSA-2rq5-699j-x7p6. The {% include %}, {% extends %}, and {% import %} tags resolve their target path through the filesystem loader without confining the result to the configured template root. A path that traverses upward (../) escapes the root and reads an arbitrary file from the host filesystem, whose contents are emitted into the rendered output.

Attack scenario

The dangerous case does not require the attacker to control template source — only template data (the locals passed at render time). An application that renders a trusted template whose include / extends path is variable-driven is exposed:

js
// application code — a configured filesystem loader with a basepath
swig.renderFile('page.html', { partial: req.query.partial });
{# page.html — trusted template #}
{% include partial %}

Setting ?partial=../../../../etc/passwd makes the loader resolve and read that file, and its contents are rendered into the response. A literal in trusted source is equally affected: {% include "../../../etc/passwd" %}.

Impact

Arbitrary local file disclosure (confidentiality). An attacker able to influence an include / extends / import path — directly, or via untrusted locals — can read files outside the template directory: application configuration, credentials, source code, /etc/passwd, and so on. There is no integrity or availability impact.

Affected & patched

Every published version up to and including 2.7.0 is affected — @rhinostone/swig, and the shared @rhinostone/swig-core loader, hence @rhinostone/swig-twig, @rhinostone/swig-jinja2, and @rhinostone/swig-django as well.

Fixed in 2.7.1: the filesystem loader now rejects any include / extends / import path that resolves outside the configured basepath root, including paths supplied through an untrusted runtime variable. A new allowOutsideRoot loader option is available for the rare case of intentionally reading files from outside the root.

Upgrade to 2.7.2 or later: 2.7.1 fixed the vulnerability but introduced a regression — a relative basepath wrongly rejected every in-root template path. 2.7.2 resolves the basepath to an absolute path before the check and restores correct in-root resolution.

Workarounds

  • Upgrade to 2.7.2 (or later).
  • If you cannot upgrade immediately: configure the filesystem loader with an explicit basepath, and never pass untrusted data into an {% include %} / {% extends %} / {% import %} path.

References

Software afectado

Haz clic en una tecnología para ver todas sus vulnerabilidades.

PlataformaPaqueteVersiones vulnerablesCorregida en
Paquete de npm @rhinostone/swig < 2.7.1 2.7.1
Paquete de npm @rhinostone/swig-core < 2.7.1 2.7.1
Paquete de npm @rhinostone/swig-django < 2.7.1 2.7.1
Paquete de npm @rhinostone/swig-jinja2 < 2.7.1 2.7.1
Paquete de npm @rhinostone/swig-twig < 2.7.1 2.7.1

Referencias

Puntuación CVSS 7.5/10
Vector CVSS
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
Debilidad (CWE)
CWE-22
Plataforma
npm
Paquete
@rhinostone/swig, @rhinostone/swig-core, @rhinostone/swig-django
Publicada
18.08.2026
Actualizado
11.10.2026 10:22

Fuentes y licencias

OSV / GitHub Advisory Database - GHSA-2mf3-mr2r-r4vf - CC BY 4.0

Historial de vulnerabilidades: @rhinostone/swig-jinja2

Todas las vulnerabilidades publicadas de este paquete (Paquete de npm), de la más reciente a la más antigua. Muestra si es un fallo aislado o un paquete que hay que vigilar.

Esta es la única vulnerabilidad conocida de este paquete.

Identifica las vulnerabilidades de tu aplicación

Con la integración de DockRay y el inventario de software activado, DockRay compara las versiones notificadas de los componentes con las vulnerabilidades conocidas y avisa de las coincidencias confirmadas. La cobertura depende de la tecnología compatible y de los avisos disponibles.

Conectar tu aplicación
Newsletter DockRay

La seguridad de tus aplicaciones en tu correo

Vulnerabilidades importantes, recomendaciones concretas y consejos prácticos para tus aplicaciones. Elige tus tecnologías y sigue lo que importa para tu proyecto.

  • Un resumen diario de nuevas vulnerabilidades, también las críticas.
  • Avisos sobre actualizaciones importantes.
  • Consejos prácticos sobre seguridad y monitorización de aplicaciones.

Déjalo vacío para recibir avisos de todas las tecnologías.

Suscripción gratuita. Date de baja con un clic en cualquier correo.