PortGate

Advisories · Node.js & Next.js

CVE-2022-29078 Critical CVSS 9.8

EJS template injection

Disclosed 2022 · Last reviewed 2 Dec 2026

Request data copied into the EJS render options could run code on the server.

What happened

The render function treated an options field as template settings.

Affected and patched versions

Affected
ejs before 3.1.7 when render options can be influenced by a request.
Patched
ejs 3.1.7 and later.

How to check your server

Check

npm ls ejs

How to fix and harden

  1. Upgrade ejs to 3.1.7 or later.
  2. Do not spread req.query into the options object. Pass only the locals you intend.

Fix

npm ls ejs

Sources

Version ranges and fixes follow the vendor advisory. When a distribution backports a fix, trust its security tracker over the upstream version number. New advisories: RSS · JSON