Skip to content
Info disclosure Advisory Advanced CVE-2020-12668

GHSL-2020-072: Arbitrary file disclosure in JinJava - CVE-2020-12668

JinJava exposed an internal interpreter variable that allowed template authors to access Class and ClassLoader instances, bypassing restrictions. An attacker with template write access could read arbitrary files from the filesystem and perform server-side request forgery.

Alvaro Muñoz Follow

Originally disclosed on GitHub Security Lab

A user with privileges to write JinJava templates, for example in a CMS context, will be able to read arbitrary files from the file system.

pwntester, 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 template engine exposed an internal interpreter variable and failed to block array or map accesses that return Class instances, allowing escape from the sandbox.

Impact

This issue may lead to arbitrary file disclosure and server-side request forgery.

What the attacker needed

Privileges to write JinJava templates

The fix

The issue was fixed in version 2.5.4.

How it was found

  1. Access the internal interpreter through the secret variable.
  2. List all functions to obtain Method instances.
  3. Use a Method's parameter types to get a Class instance.
  4. Obtain a ClassLoader via the Class's protectionDomain.
  5. Use the Class or ClassLoader to read classpath resources.
  6. Convert a classpath resource URL to a URI and open a connection to read arbitrary files.

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.

JinJava is a template engine that lets people write templates to generate web pages. The report found that a hidden variable gave template writers a way to reach Java's internal classes, which they could use to read files on the server. This matters because anyone allowed to edit templates could then read sensitive files.

What is Info disclosure?

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

More by Alvaro Muñoz

View all

132 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.