Kingdom: Input Validation and Representation
Input validation and representation problems ares caused by metacharacters, alternate encodings and numeric representations. Security problems result from trusting input. The issues include: "Buffer Overflows," "Cross-Site Scripting" attacks, "SQL Injection," and many others.
OGNL Expression Injection
Abstract
The evaluation of unvalidated OGNL expressions can lead to remote code execution.
Explanation
Object-Graph Navigation Language (OGNL) is an open-source Expression Language (EL) for Java that enables the evaluation of EL expressions in the Struts 2
In the following example, the application is using unvalidated user-controlled data to create an evaluate an OGNL expression:
An attacker may submit the following expression to execute arbitrary code in the application server context:
Value Stack
context. Enabling evaluation of unvalidated expressions against the Value Stack
can give an attacker access to modify system variables or execute arbitrary code.In the following example, the application is using unvalidated user-controlled data to create an evaluate an OGNL expression:
OgnlContext ctx = new OgnlContext();
String expression = request.getParameter("input");
Object expr = Ognl.parseExpression(expression);
Object value = Ognl.getValue(expr, ctx, root);
System.out.println("Value: " + value);
An attacker may submit the following expression to execute arbitrary code in the application server context:
(#rt = @java.lang.Runtime@getRuntime(),#rt.exec("calc.exe"))
References
desc.dataflow.java.ognl_expression_injection