GHSL-2021-023: Remote code execution in squirrelly - CVE-2021-32819
The squirrelly template engine mixes template data with configuration options when used with Express's render API, allowing an attacker to overwrite internal settings. This can lead to remote code execution in downstream applications that pass user-controlled query parameters directly to the render function.
Originally disclosed on GitHub Security Lab
The Express render API was designed to only pass in template data. By allowing template engine configuration options to be passed through the Express render API directly, downstream users of an Express template engine may inadvertently introduce insecure behavior into their applications with impacts ranging from Cross…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The template engine accepts configuration options through the same object used for template data, so user-controlled input can override internal settings.
Impact
This vulnerability leads to remote code execution.
What the attacker needed
Express app using squirrelly; passes user-controlled object to render
How it was found
- Set up an Express application using squirrelly as the view engine and pass req.query directly to res.render.
- Send a request with query parameters that include malicious configuration options.
- The engine processes the options and executes the injected code.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Template engines help build web pages by filling in placeholders with data. Express, a web framework, lets you pass data to these engines. If the engine also accepts configuration settings from the same data, an attacker can change those settings to run their own code on the server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.