Unsandboxed Groovy Template to Rev Shell

Unsandboxed Groovy Scripting in File Bot’s Format Expressions

This project demonstrates a dangerous unsandboxed Groovy scripting feature within File Bot’s Format Expressions. By showcasing how a reverse shell can be achieved through user-supplied code, the demo highlights the significant risks of allowing unrestricted script execution in templating engines. It is important to note that this is not presented as a traditional vulnerability or CVE; rather, it relies on a scenario in which a user is tricked into pasting a malicious reverse shell payload into their configuration. Although the current demonstration is limited—further research is needed to inject payloads from a file during File Bot’s parsing process. Ultimately, the project aims to underscore why running an unsandboxed templating engine can be extremely dangerous, especially when custom templates are sourced from unverified or untrusted parties.

GitHub: Unsandboxed Groovy


Testing

This section describes the testing process used to validate the behavior of unsandboxed expression evaluation, error handling, and dynamic code execution. The tests illustrate how Groovy can be manipulated to perform unintended actions when not properly sandboxed.

Confirm Expression Evaluation

Expression evaluation in this context refers to running Groovy code snippets dynamically to transform data or execute simple operations. The test demonstrates that basic expressions (like converting strings to uppercase) are executed without restrictions.

Visible Runtime Exceptions


Backend Language Determination

This section explains how the backend language was identified. The key test shows that it’s possible to execute operating system commands via Spring Expression Language (SpEL) syntax when using unsandboxed Groovy.


GroovyShell Instantiation and Evaluation

Here, the GroovyShell is instantiated to demonstrate dynamic code evaluation. GroovyShell allows for the on-the-fly interpretation and execution of Groovy code, which, if left unsandboxed, can be exploited to perform arbitrary computations.


Reverse Shell Demonstration

This section illustrates the dangerous potential of unsandboxed scripting by demonstrating how a reverse shell can be executed. The provided code snippet shows how a user-supplied script can be used to create a connection back to an attacker's machine, thereby achieving remote code execution. Although this isn't classified as a traditional CVE or vulnerability (since exploitation requires deliberate user input), it underscores the risks of unsafe script execution.


Findings

The testing clearly demonstrates that a reverse shell can be achieved through user-supplied code. This finding emphasizes the severe risks associated with allowing unrestricted script execution in templating engines like File Bot’s Format Expressions. Importantly, the exploit requires user interaction (e.g., pasting the malicious code into a custom template) and is not a remotely exploitable vulnerability in itself. However, it serves as a powerful reminder of the dangers involved with unsandboxed environments.

Project Code

The provided link to the FileBot Expression Filter code shows where unsandboxed execution is integrated into the application. This highlights the potential for abuse if user-supplied templates are not properly sanitized or restricted.


Threat Model

Several risks and potential avenues for exploitation have been identified:


Mitigation Strategies

To protect against the risks associated with unsandboxed scripting, the following measures are recommended:


Next Steps

Further research and testing are needed to fully understand the exploitation potential of this unsandboxed environment. One key area for future work is determining if a malicious video file, when parsed by File Bot, could trigger code execution unexpectedly. This additional research is currently a work in progress (WIP) and may shed further light on potential vulnerabilities present in the templating engine.


Final Note: The information provided here is for educational purposes only.



Tags: Vulnerability, CSTI, PoC, Code Review

← Back home