[🐸 Frogbot] Update version of ejs to 3.1.10 #23
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📦 Vulnerable Dependencies
Critical
🔖 Details
Vulnerability Details
Insufficient input validation in EJS enables attackers to perform template injection when attacker can control the rendering options.
🔬 JFrog Research Details
Description:
Embedded JavaScript templates, also known as EJS, is one of the most popular Node.js templating engines, which is compiled with the Express JS view system.
When rendering views using EJS, it is possible to perform template injection on the
opts.outputFunctionNamevariable, since the variable is injected into the template body without any escaping. Although it is unlikely that the attacker can directly control theoutputFunctionNameproperty, it is possible that it can be influenced in conjunction with a prototype pollution vulnerability.Once template injection is achieved, the attacker can immediately perform remote code execution since the template engine (EJS) allows executing arbitrary JavaScript code.
Example of a vulnerable Node.js application -
Exploiting the above example for RCE -
curl 127.0.0.1:8086 -v --data 'content={"constructor": {"prototype": {"outputFunctionName": "a; return global.process.mainModule.constructor._load(\"child_process\").execSync(\"whoami\"); //"}}}'Due to the prototype pollution in the
lodash.defaultsDeepcall, an attacker can inject theoutputFunctionNameproperty with an arbitrary value. The chosen value executes an arbitrary process via thechild_processmodule.Remediation:
Development mitigations
Add the
Object.freeze(Object.prototype);directive once at the beginning of your main JS source code file (ex.index.js), preferably after all yourrequiredirectives. This will prevent any changes to the prototype object, thus completely negating prototype pollution attacks.Note that this mitigation is supposed to stop any prototype pollution attacks which can allow an attacker to control the
opts.outputFunctionNameparameter indirectly.The mitigation will not stop any (extremely unlikely) scenarios where the JavaScript code allows external input to directly affect
opts.outputFunctionName.🐸 JFrog Frogbot