/

CVE-2026-73649

Severity:

CRITICAL RISK

(9.8)

Server-Side Template Injection (CWE-94) in Velocity.js

CVE-2026-73649

Deferred

Vulnerability type

Category:

Server-Side Template Injection

CWE:

CWE-94

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A server-side template injection vulnerability in Velocity.js allows attacker-controlled templates to reach JavaScript property access that can traverse to the Function constructor. When an application renders untrusted templates, an attacker may execute arbitrary commands in the server process and access sensitive data or internal services.

Affected context

The vulnerability occurs in Velocity.js deployments that render templates influenced by untrusted users or external content. Earlier filtering covered assignment targets but did not consistently restrict property-read expressions, allowing template evaluation to access dangerous JavaScript object properties before the relevant expression was safely constrained.

Exploit preconditions

  • Attack surface: A server-side application that evaluates Velocity.js templates
  • Required access: Ability to supply, modify, or influence a template processed by the application
  • Trigger point: Template evaluation involving property-read expressions
  • Why exploitation is possible: Incomplete filtering permits traversal through JavaScript object properties to a callable constructor capable of executing code

Why this happens

The underlying bug is incomplete enforcement of template expression restrictions. Security checks were applied to assignment targets in the #set handler, while property-read expressions processed through the reference-resolution flow remained able to access sensitive prototype-related properties.

This behavior maps to CWE-94: Improper Control of Generation of Code ('Code Injection'), because attacker-controlled template syntax can be interpreted as executable JavaScript behavior rather than being limited to data access and presentation logic.

Potential impact

  • Arbitrary shell commands may execute with the privileges of the server process
  • Environment variables and application secrets could be exposed
  • Cloud credentials may be accessed
  • Internal network services may be reachable from the compromised host
  • Application data could be modified or destroyed
  • The server environment could be used for further compromise

General mitigation guidance

Mitigation generally focuses on preventing untrusted templates from reaching a fully capable expression engine and enforcing consistent restrictions across every expression path.

Common defensive patterns include:

  • Treating templates as trusted code and separating them from user-supplied content
  • Using a restricted template engine or sandbox with no access to constructors, prototypes, or process APIs
  • Applying allowlisted property access consistently to reads, writes, and nested expressions
  • Validating template sources and reducing the amount of attacker-controlled input
  • Running the rendering process with least privilege and minimal filesystem, network, and credential access
  • Keeping secrets and cloud credentials unavailable to processes that render untrusted content
  • Using a maintained parser and applying security fixes through the organization's normal dependency-management process

How teams detect issues like this

High-level detection approaches include:

  • Static analysis for template engines that evaluate user-controlled strings
  • Code review checks for dynamic template compilation and unrestricted property traversal
  • Searches for access to constructors, prototypes, or runtime execution APIs in template-resolution code
  • Tests confirming that filtering applies consistently to property reads as well as assignment targets
  • Policy enforcement requiring templates to come from trusted, integrity-controlled sources
  • Runtime monitoring for unexpected child processes, shell activity, credential access, or outbound connections from rendering services

Automated code review and dependency-scanning tools may help identify unsafe template usage and known vulnerable components.

Sources

SourceLink
github.comgithub.com/shepherdwind/velocity.js/commit/f8e47a6c4607249b9c967d3a1ced959b4dd64dba
github.comgithub.com/shepherdwind/velocity.js/pull/192
github.comgithub.com/shepherdwind/velocity.js/releases/tag/v2.1.7
github.comgithub.com/shepherdwind/velocity.js/security/advisories/GHSA-7gfh-x38p-prh3

Frequently asked

questions

It can be remotely exploitable when a network-facing application accepts or modifies templates based on attacker-controlled input. If templates are strictly trusted and immutable, that attack path is reduced.

The attacker needs a way to influence a template that the server evaluates. This may be provided by a template-editing feature, user-generated content workflow, or another application path that passes untrusted template text to the renderer.

Do not evaluate untrusted templates with a fully capable JavaScript execution environment. Prefer trusted template sources, a restricted engine, and consistent allowlisted access controls across all expression types.

Treat templates as executable code, review every evaluation path, test prototype and constructor access explicitly, minimize renderer privileges, and enforce dependency and security checks in development pipelines.

Find out what's already
exploitable in your codebase.