Skip to main content
CriticalCodeOWASP A03:2021CWE-94

How to fix: GroovyShell.evaluate() Called With Request Data

A GroovyShell instance's evaluate() method is called directly with request data.

Why it matters

Groovy scripting engines execute arbitrary JVM code with the permissions of the host application; this has been the root cause of numerous real-world RCE vulnerabilities in Java applications and CMS plugin systems.

GroovyShell.evaluate() compiles and runs the given string as a full Groovy script with no sandboxing by default, equivalent in severity to eval() in JavaScript but with direct access to the JVM's class loader and reflection APIs.

How to fix it

  1. 1Never pass request-derived data to GroovyShell.evaluate() or any scripting-engine eval method.
  2. 2If dynamic scripting is a genuine requirement, use a properly configured SecureASTCustomizer allowlist and run under a restrictive SecurityManager or separate sandboxed process.
  3. 3Prefer a fixed set of supported operations over arbitrary script execution.

Code examples

Avoid evaluating request-controlled Groovy

Java
// BAD
GroovyShell shell = new GroovyShell();
shell.evaluate(request.getParameter("script"));

// GOOD: dispatch to a fixed, reviewed set of operations instead
switch (request.getParameter("op")) {
  case "add": return a + b;
  default: throw new IllegalArgumentException("Unsupported operation");
}

References

Detected automatically by VulnRadar. The check id is code-eval-groovyshell, stable across every scan so you can filter or diff on it.

See every code check

Questions

How severe is GroovyShell.evaluate() Called With Request Data?
VulnRadar rates this critical severity in the code category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id code-eval-groovyshell, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does GroovyShell.evaluate() Called With Request Data map to?
It maps to CWE-94. In the OWASP Top 10 it falls under A03:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for groovyshell.evaluate() called with request data

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

GroovyShell.evaluate() Called With Request Data | VulnRadar