Skip to content

Commit 3edc8bc

Browse files
committed
Doc improvements
1 parent d9fb650 commit 3edc8bc

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

java/ql/src/Security/CWE/CWE-917/OgnlInjection.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@ public void evaluate(HttpServletRequest request, Object root) throws OgnlExcepti
1414
} else {
1515
// Reject the request
1616
}
17-
}
17+
}
18+
19+
public void isValid(Strig expression) {
20+
// Custom method to validate the expression.
21+
// For instance, make sure it doesn't include unexpected code.
22+
}

java/ql/src/Security/CWE/CWE-917/OgnlInjection.qhelp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,33 @@
33
"qhelp.dtd">
44
<qhelp>
55
<overview>
6-
<p>Object-Graph Navigation Language (OGNL) is an open-source Expression Language (EL) for Java. Due
7-
to its ability to create or change executable code, OGNL is capable of introducing critical
8-
security flaws to any application that uses it. Evaluation of unvalidated expressions can let
9-
attacker to modify Java objects' properties or execute arbitrary code.</p>
6+
<p>Object-Graph Navigation Language (OGNL) is an open-source Expression Language (EL) for Java.
7+
OGNL can create or change executable code, consequently it can introduce critical
8+
security flaws to any application that uses it. Evaluation of unvalidated expressions is a common
9+
flaw in OGNL. This exposes the properties of Java objects to modification by an attacker and
10+
may allow them to execute arbitrary code.</p>
1011
</overview>
1112

1213
<recommendation>
13-
<p>The general recommendation is to not evaluate untrusted ONGL expressions. If user provided OGNL
14-
expressions must be evaluated, do this in sandbox (add <code>-Dognl.security.manager</code> to JVM arguments)
15-
and validate the expressions before evaluation.</p>
14+
<p>The general recommendation is to avoid evaluating untrusted ONGL expressions. If user-provided OGNL
15+
expressions must be evaluated, do this in a sandbox and validate the expressions before evaluation.</p>
1616
</recommendation>
1717

1818
<example>
1919
<p>In the following examples, the code accepts an OGNL expression from the user and evaluates it.
2020
</p>
2121

22-
<p>In the first example, the user provided OGNL expression is parsed and evaluated.</p>
22+
<p>In the first example, the user-provided OGNL expression is parsed and evaluated.</p>
2323

24-
<p>The second example validates the expression and evaluates it inside the sandbox.</p>
24+
<p>The second example validates the expression and evaluates it inside a sandbox.
25+
You can add a sandbox by setting a system property, as shown in the example, or by adding
26+
<code>-Dognl.security.manager</code> to JVM arguments.</p>
2527

2628
<sample src="OgnlInjection.java" />
2729
</example>
2830

2931
<references>
30-
<li><a href="https://github.com/jkuhnert/ognl/">OGNL library</a>.</li>
32+
<li>Apache Commons: <a href="https://commons.apache.org/proper/commons-ognl/">Apache Commons OGNL</a>.</li>
3133
<li>Struts security: <a href="https://struts.apache.org/security/#proactively-protect-from-ognl-expression-injections-attacks-if-easily-applicable">Proactively protect from OGNL Expression Injections attacks</a>.</li>
3234
</references>
33-
</qhelp>
35+
</qhelp>

java/ql/src/Security/CWE/CWE-917/OgnlInjection.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ import DataFlow::PathGraph
1616

1717
from DataFlow::PathNode source, DataFlow::PathNode sink, OgnlInjectionFlowConfig conf
1818
where conf.hasFlowPath(source, sink)
19-
select sink.getNode(), source, sink, "OGNL expression might include input from $@.",
19+
select sink.getNode(), source, sink, "OGNL expression might include data from $@.",
2020
source.getNode(), "this user input"

0 commit comments

Comments
 (0)