GHSL-2020-066: Server-Side Template Injection (SSTI) leading to Remote Code Execution (RCE) in Apache OfBiz
Apache OfBiz was vulnerable to server-side template injection in the renderSortField function, allowing an authenticated attacker to execute arbitrary commands on the server. The flaw arose because a previous fix was incomplete and later partially removed.
Originally disclosed on GitHub Security Lab
Apache OfBiz is vulnerable to Server-Side Template Injection (SSTI) leading to Remote Code Execution (RCE)
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 incomplete escaping of user input in the renderSortField function allowed breaking out of a FreeMarker string context and injecting template code.
Impact
An authenticated attacker could execute arbitrary commands on the server, leading to remote code execution.
What the attacker needed
Authenticated user with access to sortable fields
The fix
The issue was addressed in version 17.12.05.
How it was found
- Log in to the backend application with sufficient permissions.
- Craft a URL to the FindRequest endpoint with a malicious 'foo' parameter containing FreeMarker code.
- Visit the URL; the injected code executes and its output appears alongside sortable fields.
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.
Server-side template injection happens when user input is inserted into a template that the server processes, and the input can contain template code. Here, an attacker could craft a URL that made the server run system commands, like 'id', and show the output on the page. This requires being logged in with certain permissions.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.