Skip to content
Info disclosure Advisory Intermediate CVE-2021-32817

GHSL-2021-019: File disclosure in express-hbs - CVE-2021-32817

The express-hbs template engine allowed configuration options such as the layout path to be passed through the Express render API alongside template data. An attacker could supply a layout parameter pointing to a file on the server, causing its contents to be disclosed.

agustingianni Follow

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…

agustingianni, on GitHub Security Lab

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

Likely the engine did not separate template data from configuration options, so a user-controlled layout value was treated as a file path.

Impact

An attacker could read files on the server, but only files that already have an extension; files without an extension get .hbs appended.

What the attacker needed

Application passes req.query to res.render; target file has an extension

The fix

The maintainer added documentation warning users about the dangers of passing user-controlled objects into the render API.

How it was found

  1. The application passes the user-controlled query object directly into the render call.
  2. The attacker sends a request with a layout parameter pointing to a file on the server.
  3. The engine renders that file and returns its contents.

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 fill in placeholders in web pages. Express lets you pass data to them, but express-hbs also accepted settings like which layout file to use from the same data. If a website passed user input straight into that data, an attacker could ask for a different file on the server and read it.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

More by agustingianni

View all

24 more disclosed reports, best first.

More from GitHub Security Lab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.