GHSL-2020-071: Server-side template injection in Lithium CMS
A user who can edit a FreeMarker template in Lithium CMS can bypass the template sandbox to access Java classes and instantiate arbitrary objects, leading to remote code execution. The attacker could run arbitrary Java code or system commands with the same privileges as the CMS process.
Originally disclosed on GitHub Security Lab
A user with privileges to edit a FreeMarker template (e.g. a Component) may execute arbitrary Java code or run arbitrary system commands with the same privileges as the account running Lithium CMS.
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 FreeMarker sandbox's deny list for unsafe methods did not block getter methods on java.lang.reflect.Field, allowing access to static fields that can be used to instantiate arbitrary objects.
Impact
This issue leads to Remote Code Execution.
What the attacker needed
Privileges to edit a FreeMarker template
The fix
The issue was fixed on all production systems in version 20.5.
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.
FreeMarker is a template engine that lets you put placeholders in web pages; normally it restricts what Java objects you can access to keep things safe. Here, a user who can edit templates could trick the engine into giving them powerful Java objects, and from there run their own code on the server. This is called server-side template injection.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.