tj / consolidate.js

Template engine consolidation library for node.js
3.48k stars 357 forks source link

Prototype pollution in function consolidate.teacup.render #349

Open lelecolacola123 opened 1 year ago

lelecolacola123 commented 1 year ago

Affected versions of this package are vulnerable to Prototype Pollution which can allow an attacker to add/modify properties of the Object.prototype.Consolidate runs the risk of Prototype Pollution when using the function teacup.render. The function use vm and coffee.compile lead an attacker to modify properties of the Object.prototype. the risk locate is in here https://github.com/tj/consolidate.js/blob/ec2e1ae511d37a69716022311a4ca29785f62143/lib/consolidate.js#L1756 and the POC is as follow: var consolidate = require("consolidate") console.log({}.test) consolidate.teacup.render("proto.test=123") console.log({}.test) //123

the function teacup.render in the file consolidate/lib/consolidate.js in the line L1756, by using the vm,change the Object.prototype.you didn't have the protection or identify whether the object maybe polluted,so if an attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values.

titanism commented 1 year ago

We have forked this repository for maintenance and released it under @ladjs/consolidate, see https://github.com/ladjs/consolidate.js. We have merged PR's and updated it for email-templates. Please click the "Watch" button to get notified of all releases at https://github.com/ladjs/consolidate.js. Thank you 🙏

Screen Shot 2023-06-08 at 3 05 12 PM
justinvforvendetta commented 9 months ago

@titanism where can we find the sha512 for the new releases like 1.1.3? thanks!

harryzcy commented 4 months ago

@titanism Can you enable issues on your fork? thanks