-
Notifications
You must be signed in to change notification settings - Fork 844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unrestricted render option may lead to a RCE vulnerability #451
Comments
The problem here is that EJS is simply a way of executing JS to render a template. If you allow passing of arbitrary/unsanitized options and data to the render function, you will encounter all security problems that would occur as a result of arbitrary code execution. Henny Youngman used to tell a joke: "The patient says, 'Doctor, it hurts when I do this.' So the doctor says, 'Then don't do that!'" I'm open to PRs that improve security, but this looks to me to be far beyond the purview of the library. These responsibilities live squarely in userland. |
This prevents injection of arbitrary code if the server is already vulnerable to prototype poisoning. This resolves mde#451. I deliberately opted to not support complex Unicode identifiers even though they're valid JS identifiers. They're complex to validate and users probably shouldn't even try to be that creative.
By passing an unrestricted render option can lead to a RCE vulnerability.
If attacker can control server render option eg:
outputFunctionName
, that can inject evil code to the render engine.There is a simply way to control that option by using prototype pollution.
For a short express application example
By default
outputFunctionName
is undefined, but after the attacker post the following data:Due to prototype pollution, the
Object
now has attributeoutputFunctionName
which the attcker controls, then inject to variableprepended
and getshell. At ejs.js L575I don't think this would be easy to inject that code, but if attacker can use other security vulnerability or developer's mistakes at the same time, it would be a very serious problem.
The text was updated successfully, but these errors were encountered: