CVE-2026-73649: Velocityjs Remote Code Execution Vulnerability

CRITICAL
Advisory Identifier: GHSA-7gfh-x38p-prh3
CVSS 9.8
CWE-94
Published
Advisory Summary

CVE-2026-73649 is a CRITICAL (CVSS 9.8) remote code execution vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Velocityjs libraries in the npm ecosystem. The issue involves remote code execution via property-read to function constructor (bypass of ghsa-j658-c2gf-x6pq fix). Remediation is available by upgrading affected packages to version 2.1.7.

CVE-2026-73649 at a Glance

CVE Identifier CVE-2026-73649
GHSA Identifier GHSA-7gfh-x38p-prh3
Severity CRITICAL
CVSS v3.1 Base Score 9.8
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Velocityjs
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 9.8

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:H/A:H).

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 High (I:H)
Availability High (A:H)

How to Fix CVE-2026-73649

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

velocityjs fixed: 2.1.7
npm install velocityjs@2.1.7
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 velocityjs

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-73649, inspect your project dependencies using npm:

npm ls velocityjs

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

Note: The npm ls velocityjs 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-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Velocityjs, 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

### Summary Remote Code Execution (RCE) in velocityjs v2.1.6 via property-read to the Function constructor. This bypasses the fix for GHSA-j658-c2gf-x6pq ("Prototype Pollution in #set path assignment") — that advisory blocked constructor/__proto__/prototype only in the #set assignment handler (set.cjs), but property read expressions are unfiltered. Any application rendering attacker-controlled Velocity templates is vulnerable to arbitrary code execution on the server. ### Details GHSA-j658-c2gf-x6pq added isBlockedPathKey() to dist/cjs/compile/set.cjs:35-43, which blocks __proto__, constructor, and prototype keys. However, this check only runs when the #set directive assigns a value — it validates the assignment target path, not the value expression being evaluated. The value expression is evaluated via getReferences() in dist/cjs/compile/references.cjs:16, which calls getAttributes() at line 81. The property access at line 88-89 has no filtering: // references.cjs:81-91 getAttributes(property, baseRef, ast) { if (property.type === "property") { return baseRef[property.id]; // ← NO BLOCK on "constructor", "prototype", etc. } ... } Meanwhile, set.cjs:35-43 properly blocks these keys, but only for the #set target: // set.cjs:35-43 isBlockedPathKey(baseRef, key, isEnd) { if (key === PROTO_KEY) return true; // "__proto__" if (key === "prototype" && typeof baseRef === "function") return true; return !isEnd && PROTOTYPE_CHAIN_KEYS.has(key) && !hasOwnProperty(baseRef, key); } The exploit chain: 1. $x.constructor → getAttributes() → {}["constructor"] → Object 2. .constructor → getAttributes() → Object["constructor"] → Function 3. ("return process.mainModule.require('child_process').execSync('whoami')") → calls Function(...) → creates a function 4. The #set assigns the result to $f, which is then rendered as $r The #set handler validates $f as the assignment target (which passes — f is not blocked), but never inspects the right-hand expression for prototype chain traversal. ### PoC const velocity = require('velocityjs'); const template = "#set($f=$x.constructor.constructor(\"return process.mainModule.require('child_process').execSync('whoami').toString()\"))#set($r=$f())$r"; console.log(velocity.render(template, { x: {} })); // Output: <current OS username> Verified on velocityjs v2.1.6, Node.js v24.15.0, Windows. ### Impact Type: Remote Code Execution (RCE) Any application that renders attacker-controlled Velocity templates using velocityjs is vulnerable to full server compromise. The attacker can execute arbitrary shell commands, read environment variables, access cloud credentials, and pivot to internal network resources. The existing advisory GHSA-j658-c2gf-x6pq established the threat model: "any app rendering attacker-controlled templates." This finding demonstrates that the fix was incomplete — the #set blocking was added but property read expressions remain unfiltered, making the issue strictly worse (RCE vs prototype pollution). ### Patches Fixed in [velocityjs 2.1.7](https://www.npmjs.com/package/velocityjs/v/2.1.7). The fix was merged in [pull request #192](https://github.com/shepherdwind/velocity.js/pull/192) and released as [v2.1.7](https://github.com/shepherdwind/velocity.js/releases/tag/v2.1.7). Users should upgrade to version 2.1.7 or later.

CVE-2026-73649 Affected Velocityjs Versions

1 component(s)
Fixed Versions:
2.1.7
Product / Package Ecosystem Affected Versions Fixed Version
velocityjs
npm
< 2.1.7
2.1.7

References

Frequently Asked Questions

What is CVE-2026-73649?
CVE-2026-73649 is a security vulnerability in Velocityjs involving Remote Code Execution via property-read to Function constructor (bypass of GHSA-j658-c2gf-x6pq fix) under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Velocityjs versions are affected?
Affected versions include releases prior to 2.1.7 across affected packages: velocityjs.
What version fixes CVE-2026-73649?
Upgrading to 2.1.7 (or the latest patched release for your respective branch) resolves the vulnerability.
Is velocityjs affected?
Yes, velocityjs is affected in releases prior to 2.1.7. Upgrade your dependency to 2.1.7 or later.
What is the CVSS score of CVE-2026-73649?
CVE-2026-73649 has a CVSS v3.1 base score of 9.8 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2026-73649?
CVE-2026-73649 is classified under CWE-94: Improper Control of Generation of Code ('Code Injection') (The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.).
How can I check npm dependencies for CVE-2026-73649?
Run the dependency tree command: 'npm ls velocityjs'. 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-7gfh-x38p-prh3",
  "modified" : "2026-08-13T18:05:38Z",
  "published" : "2026-07-24T16:21:22Z",
  "aliases" : [ "CVE-2026-73649" ],
  "summary" : "Velocity.js: Remote Code Execution via property-read to Function constructor (bypass of GHSA-j658-c2gf-x6pq fix)",
  "details" : "### Summary\n\nRemote Code Execution (RCE) in velocityjs v2.1.6 via property-read to the Function constructor. This bypasses the fix for GHSA-j658-c2gf-x6pq (\"Prototype Pollution in #set path assignment\") — that advisory blocked constructor/__proto__/prototype only in the #set assignment handler (set.cjs), but property read expressions are unfiltered. Any application rendering attacker-controlled Velocity templates is vulnerable to arbitrary code execution on the server.\n\n### Details\n\nGHSA-j658-c2gf-x6pq added isBlockedPathKey() to dist/cjs/compile/set.cjs:35-43, which blocks __proto__, constructor, and prototype keys. However, this check only runs when the #set directive assigns a value — it validates the assignment target path, not the value expression being evaluated.\nThe value expression is evaluated via getReferences() in dist/cjs/compile/references.cjs:16, which calls getAttributes() at line 81. The property access at line 88-89 has no filtering:\n// references.cjs:81-91\ngetAttributes(property, baseRef, ast) {\n  if (property.type === \"property\") {\n    return baseRef[property.id];  // ← NO BLOCK on \"constructor\", \"prototype\", etc.\n  }\n  ...\n}\nMeanwhile, set.cjs:35-43 properly blocks these keys, but only for the #set target:\n// set.cjs:35-43\nisBlockedPathKey(baseRef, key, isEnd) {\n  if (key === PROTO_KEY) return true;          // \"__proto__\"\n  if (key === \"prototype\" && typeof baseRef === \"function\") return true;\n  return !isEnd && PROTOTYPE_CHAIN_KEYS.has(key) && !hasOwnProperty(baseRef, key);\n}\nThe exploit chain:\n1. $x.constructor → getAttributes() → {}[\"constructor\"] → Object\n2. .constructor → getAttributes() → Object[\"constructor\"] → Function\n3. (\"return process.mainModule.require('child_process').execSync('whoami')\") → calls Function(...) → creates a function\n4. The #set assigns the result to $f, which is then rendered as $r\nThe #set handler validates $f as the assignment target (which passes — f is not blocked), but never inspects the right-hand expression for prototype chain traversal.\n\n### PoC\n\nconst velocity = require('velocityjs');\n\nconst template = \"#set($f=$x.constructor.constructor(\\\"return process.mainModule.require('child_process').execSync('whoami').toString()\\\"))#set($r=$f())$r\";\n\nconsole.log(velocity.render(template, { x: {} }));\n// Output: <current OS username>\nVerified on velocityjs v2.1.6, Node.js v24.15.0, Windows.\n\n### Impact\n\nType: Remote Code Execution (RCE)\n\nAny application that renders attacker-controlled Velocity templates using velocityjs is vulnerable to full server compromise. The attacker can execute arbitrary shell commands, read environment variables, access cloud credentials, and pivot to internal network resources.\nThe existing advisory GHSA-j658-c2gf-x6pq established the threat model: \"any app rendering attacker-controlled templates.\" This finding demonstrates that the fix was incomplete — the #set blocking was added but property read expressions remain unfiltered, making the issue strictly worse (RCE vs prototype pollution).\n\n### Patches\n\nFixed in [velocityjs 2.1.7](https://www.npmjs.com/package/velocityjs/v/2.1.7). The fix was merged in [pull request #192](https://github.com/shepherdwind/velocity.js/pull/192) and released as [v2.1.7](https://github.com/shepherdwind/velocity.js/releases/tag/v2.1.7). Users should upgrade to version 2.1.7 or later.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "velocityjs"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.1.7"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 2.1.6"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/shepherdwind/velocity.js/security/advisories/GHSA-7gfh-x38p-prh3"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/shepherdwind/velocity.js/pull/192"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/shepherdwind/velocity.js/commit/f8e47a6c4607249b9c967d3a1ced959b4dd64dba"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/shepherdwind/velocity.js"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/shepherdwind/velocity.js/releases/tag/v2.1.7"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-24T16:21:22Z",
    "nvd_published_at" : null
  }
}