Potential code injection when using Spring Expression

Metadata

ID: java-security/spring-expression-injection

Language: Java

Severity: Warning

Category: Security

CWE: 94

Description

A Spring expression is built on a dynamic value using an input string. The source should be checked to ensure there is no injection.

Learn More

Non-Compliant Code Examples

class MyClass {
    public void parseExpressionInterface(Person personObj,String property) {

        ExpressionParser parser = new SpelExpressionParser();

        //Unsafe if the input is control by the user..
        Expression exp = parser.parseExpression(property+" == 'Albert'");

        StandardEvaluationContext testContext = new StandardEvaluationContext(personObj);
        boolean result = exp.getValue(testContext, Boolean.class);
    }
}
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Seamless integrations. Try Datadog Code Analysis

PREVIEWING: rtrieu/product-analytics-ui-changes