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

GHSL-2021-020: File disclosure in hbs - CVE-2021-32822

The hbs template engine mixes template data with engine configuration options when used with Express's render API, allowing an attacker to overwrite internal settings. This can lead to file disclosure in downstream applications that pass user-controlled objects directly to the render function.

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 hbs engine accepts configuration options through the same object used for template data, so user-controlled input can override internal settings.

Impact

An attacker could read arbitrary files from the server, but only if the downstream application passes user-controlled input directly to the render function.

What the attacker needed

Downstream app passes user input to render; hbs used as Express view engine

How it was found

  1. Set up an Express app with hbs as the view engine and pass req.query directly to res.render.
  2. Send a request with query parameters that set the views directory and layout option to a target file.
  3. The server responds with the contents of the target file.

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 like hbs help build web pages by filling in data. Express, a web framework, lets you pass data to these engines. If the data comes from a user and includes special settings, an attacker might change how the engine works and read files on the server.

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.