GHSL-2021-065: Post-authentication Remote Code Execution (RCE) in ZStack REST API - CVE-2021-32829
The ZStack REST API evaluates a user-supplied Groovy script in a sandbox that can be bypassed via Java annotations, allowing any authenticated user to execute arbitrary commands on the server.
Originally disclosed on GitHub Security Lab
ZStack REST API is vulnerable to post-authentication Remote Code Execution (RCE) via bypass of the Groovy shell sandbox
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
The Groovy sandbox only restricts method calls and property access on certain object types, but it does not prevent code execution through Java annotations, which can be abused to bypass the sandbox.
What the attacker needed
Valid user account (any privilege level)
The fix
The issue was fixed in a later release.
How it was found
- Authenticate to the ZStack REST API as any non-privileged user or system admin.
- Send a GET request to the batch-queries endpoint with a crafted Groovy script in the 'script' parameter that uses an annotation to execute a command.
- Observe that the server returns an error but the command has been executed (e.g., a file is created).
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.
ZStack is a cloud management platform. Its REST API lets users run small scripts written in Groovy (a programming language that runs on Java). The developers tried to block dangerous actions with a sandbox, but a flaw in how Groovy handles annotations (special code markers) let attackers escape the sandbox and run system commands. Any logged-in user, even a low-privileged one, could exploit this to take full control of 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.