Skip to content

Unsafe dynamic code execution via GroovyShell

Description

Dynamic evaluation with GroovyShell or GroovyClassLoader using non-literal input is dangerous. It can lead to Remote Code Execution (RCE).

Examples

Insecure Code

java
GroovyShell shell = new GroovyShell(); shell.evaluate(userInput);

Secure Code

java
if (ALLOWED_EXPRESSIONS.contains(userInput)) { GroovyShell shell = new GroovyShell(); shell.evaluate(userInput); }

Remediation

Use input allowlisting and avoid user input in code evaluation.

Rule Details

FieldValue
IDCODE-0637
CategoryInjection
SeverityCRITICAL
CWECWE-94
ConfidenceHIGH
ImpactHIGH
LikelihoodHIGH
ExploitabilityEASY
TagsRemote Code Execution, RCE
OWASPA03:2021-Injection