Arbitrary Code Injection Affecting ejs package, versions <3.1.6



    Attack Complexity High
    Privileges Required High

    Threat Intelligence

    Exploit Maturity Proof of concept

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk ID SNYK-JS-EJS-1049328
  • published 20 Jan 2021
  • disclosed 9 Dec 2020
  • credit fangzequn

Introduced: 9 Dec 2020

CVE NOT AVAILABLE CWE-94 Open this link in a new tab
First added by Snyk

How to fix?

Upgrade ejs to version 3.1.6 or higher.


ejs is a popular JavaScript templating engine.

Affected versions of this package are vulnerable to Arbitrary Code Injection via the render and renderFile. If external input is flowing into the options parameter, an attacker is able run arbitrary code. This include the filename, compileDebug, and client option.


let ejs = require('ejs')
    filename:'/etc/passwd\nfinally {\'child_process\').execSync(\'touch EJS_HACKED\') }',
    compileDebug: true,
    message: 'test',
    client: true