CVE-2022-29078 in ejs

LogPulse has a published detection rule for this CVE: it raises a notable when someone tries to exploit it.

What the vulnerability is

The ejs (aka Embedded JavaScript templates) package 3.1.6 for Node.js allows server-side template injection in settings[view options][outputFunctionName]. This is parsed as an internal option, and overwrites the outputFunctionName option with an arbitrary OS command (which is executed upon template compilation).

Affected software: ejs

Scores

What LogPulse has for it

How to mitigate it

Upgrade ejs to 3.1.7 or later

Patch or upgrade. ejs before 3.1.7 lets the outputFunctionName option, when an app passes request data into render options, inject code into the compiled template. Version 3.1.7 validates the option.

Applies to: ejs (npm) versions before 3.1.7

  1. Find Node.js apps that depend on ejs: run npm ls ejs in each project.
  2. Update the dependency: npm install ejs@^3.1.7 (or a later 3.x release) and commit the lock file.
  3. Do not pass the whole request query or body as the render options object (res.render(view, req.query)); pass only the values the template needs.
  4. Rebuild and redeploy the app.
  5. Rerun the vulnerability scan to confirm CVE-2022-29078 is no longer reported.

Sources:

Source data: NIST NVD, CISA KEV and FIRST EPSS. LogPulse processes new CVEs every hour.

We build every detection with great care, but no two environments are the same. Log sources, parsing and configuration differ, so test a detection in your own environment before you rely on it.

Start free with LogPulse