GHSL-2020-030: Server-Side Template Injection in Dropwizard
Dropwizard's self-validating feature passes untrusted bean properties into error message templates that support Java EL expressions, allowing an attacker to inject arbitrary EL and execute code. This can lead to remote code execution.
Originally disclosed on GitHub Security Lab
A Server-Side Template Injection was identified in Dropwizard self-validating feature enabling attackers to inject arbitrary Java EL expressions, leading to Remote Code Execution (RCE) vulnerability.
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 ViolationCollector.addViolation() method passes its argument directly to ConstraintValidatorContext.buildConstraintViolationWithTemplate() without sanitisation, so any untrusted data becomes part of an EL expression that is later evaluated.
Impact
This issue may lead to remote code execution.
What the attacker needed
Application uses Dropwizard self-validating feature; untrusted input included in violation message
The fix
The issue was fixed by the vendor, but the initial fix was insufficient due to a Hibernate implementation bug, and a new fix was prepared.
How it was found
- Modify the example Person class to be self-validated and include the fullName property in a violation message.
- Send a POST request to /people with a JSON body containing a malicious fullName value.
- Check for the existence of /tmp/pwned or inspect the response to confirm code execution.
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.
Dropwizard is a Java framework. Its validation feature builds error messages using a template system that can evaluate Java EL expressions (small code snippets). If a developer includes user input in those messages, an attacker can inject their own expression and run 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.