Vulnerabilities in pkg:npm/@rhinostone/swig-core

PACKAGE
Advisory Summary

GHSA-2mf3-mr2r-r4vf is a HIGH (CVSS 7.5) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting @rhinostone/swig libraries in the npm ecosystem. The issue involves arbitrary local file read via include/extends path traversal. Remediation is available by upgrading affected packages to version 2.7.1.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/@rhinostone/swig-core

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/@rhinostone/swig-core. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-2mf3-mr2r-r4vf - HIGH @rhinostone/swig: arbitrary local file read via include/extends path traversal

GHSA-2mf3-mr2r-r4vf at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-2mf3-mr2r-r4vf
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product @rhinostone/swig
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix GHSA-2mf3-mr2r-r4vf

To remediate this vulnerability, upgrade all affected @rhinostone/swig dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

@rhinostone/swig fixed: 2.7.1
npm install @rhinostone/swig@2.7.1
@rhinostone/swig-core fixed: 2.7.1
npm install @rhinostone/swig-core@2.7.1
@rhinostone/swig-twig fixed: 2.7.1
npm install @rhinostone/swig-twig@2.7.1
@rhinostone/swig-jinja2 fixed: 2.7.1
npm install @rhinostone/swig-jinja2@2.7.1
@rhinostone/swig-django fixed: 2.7.1
npm install @rhinostone/swig-django@2.7.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls @rhinostone/swig

How to Check if You Are Affected

To determine whether your Node.js application is affected by GHSA-2mf3-mr2r-r4vf, inspect your project dependencies using npm:

npm ls @rhinostone/swig

Analyze the terminal output to locate any version of @rhinostone/swig in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.7.1), your application is affected.

Note: The npm ls @rhinostone/swig command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In @rhinostone/swig, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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 - GHSA-2rq5-699j-x7p6 — https://github.com/advisories/GHSA-2rq5-699j-x7p6 - CVE-2023-25345 (NVD) — https://nvd.nist.gov/vuln/detail/CVE-2023-25345 - Upstream issue (swig-templates) — https://github.com/node-swig/swig-templates/issues/88 - Fix commit — https://github.com/gina-io/swig/commit/381bdc305e0b10e45368d56324328b9b4f7017fc

GHSA-2mf3-mr2r-r4vf Affected @rhinostone/swig Versions

5 component(s)
Fixed Versions:
2.7.1
Product / Package Ecosystem Affected Versions Fixed Version
@rhinostone/swig
npm
< 2.7.1
2.7.1
@rhinostone/swig-core
npm
< 2.7.1
2.7.1
@rhinostone/swig-twig
npm
< 2.7.1
2.7.1
@rhinostone/swig-jinja2
npm
< 2.7.1
2.7.1
@rhinostone/swig-django
npm
< 2.7.1
2.7.1

References

Frequently Asked Questions

What is GHSA-2mf3-mr2r-r4vf?
GHSA-2mf3-mr2r-r4vf is a security vulnerability in @rhinostone/swig involving arbitrary local file read via include/extends path traversal under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which @rhinostone/swig versions are affected?
Affected versions include releases prior to 2.7.1 across affected packages: @rhinostone/swig, @rhinostone/swig-core, @rhinostone/swig-twig, @rhinostone/swig-jinja2, @rhinostone/swig-django.
What version fixes GHSA-2mf3-mr2r-r4vf?
Upgrading to 2.7.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @rhinostone/swig affected?
Yes, @rhinostone/swig is affected in releases prior to 2.7.1. Upgrade your dependency to 2.7.1 or later.
Is @rhinostone/swig-core affected?
Yes, @rhinostone/swig-core is affected in releases prior to 2.7.1. Upgrade your dependency to 2.7.1 or later.
What is the CVSS score of GHSA-2mf3-mr2r-r4vf?
GHSA-2mf3-mr2r-r4vf has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N.
What CWE is associated with GHSA-2mf3-mr2r-r4vf?
GHSA-2mf3-mr2r-r4vf is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check npm dependencies for GHSA-2mf3-mr2r-r4vf?
Run the dependency tree command: 'npm ls @rhinostone/swig'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-2mf3-mr2r-r4vf",
  "modified" : "2026-08-18T16:31:16Z",
  "published" : "2026-08-18T16:31:16Z",
  "aliases" : [ ],
  "summary" : "@rhinostone/swig: arbitrary local file read via include/extends path traversal",
  "details" : "### Overview\n\n`@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.\n\n### Attack scenario\n\nThe 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:\n\n```js\n// application code — a configured filesystem loader with a basepath\nswig.renderFile('page.html', { partial: req.query.partial });\n```\n\n```\n{# page.html — trusted template #}\n{% include partial %}\n```\n\nSetting `?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\" %}`.\n\n### Impact\n\nArbitrary 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.\n\n### Affected & patched\n\nEvery 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.\n\nFixed 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.\n\n**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.\n\n### Workarounds\n\n- Upgrade to `2.7.2` (or later).\n- If you cannot upgrade immediately: configure the filesystem loader with an explicit `basepath`, and never pass untrusted data into an `{% include %}` / `{% extends %}` / `{% import %}` path.\n\n### References\n\n- GHSA-2rq5-699j-x7p6 — https://github.com/advisories/GHSA-2rq5-699j-x7p6\n- CVE-2023-25345 (NVD) — https://nvd.nist.gov/vuln/detail/CVE-2023-25345\n- Upstream issue (swig-templates) — https://github.com/node-swig/swig-templates/issues/88\n- Fix commit — https://github.com/gina-io/swig/commit/381bdc305e0b10e45368d56324328b9b4f7017fc",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@rhinostone/swig"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.7.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@rhinostone/swig-core"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.7.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@rhinostone/swig-twig"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.7.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@rhinostone/swig-jinja2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.7.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@rhinostone/swig-django"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.7.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/gina-io/swig/security/advisories/GHSA-2mf3-mr2r-r4vf"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-25345"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gina-io/swig/commit/381bdc305e0b10e45368d56324328b9b4f7017fc"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/gina-io/swig"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-08-18T16:31:16Z",
    "nvd_published_at" : null
  }
}