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
- CVSS: 9.8 (critical)
- EPSS: 32.81% chance of exploitation in the next 30 days
- CISA KEV: Not listed
- Published: 2022-04-25
What LogPulse has for it
- Detection rule: Yes, published
- Agent check (vulnerable version): No
- Mitigation: Yes, see below
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
- Find Node.js apps that depend on ejs: run npm ls ejs in each project.
- Update the dependency: npm install ejs@^3.1.7 (or a later 3.x release) and commit the lock file.
- 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.
- Rebuild and redeploy the app.
- 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.