← Java / Spring · Contents

JAVA-081 / Advanced

Evaluating user input with ScriptEngine or Groovy

A03:2021 Injection · CWE-94 Code Injection

Why is this a problem?

Input strings execute as scripts.

How to fix it

java
// Calculate with a dedicated parser and allowlisted operators; do not expose the script engine

Further reading