mde / ejs

Embedded JavaScript templates -- http://ejs.co
Apache License 2.0
7.7k stars 841 forks source link

Fix potential security issue caused by Prototype Pollution #674

Closed ttpf-x closed 2 years ago

ttpf-x commented 2 years ago

Replace the regular matching method to traversing the prototype element which defined by defineProperty and__ proto__ , and copy it into the ownproperty with the value of undefined, so as to prevent the polluteded element from being found through the prototype during program execution, resulting in security problems

Because the program itself will use defineProperty to define some elements during execution, for example, express will use defineProperty to set properties such as filename,view and cache, so blacklist filtering is adopted for properties defined by defineProperty to prevent affecting normal data