Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8904411

Browse files
Alvaro Muñozpwntester
authored andcommitted
address review comments
1 parent debfc68 commit 8904411

2 files changed

Lines changed: 4 additions & 18 deletions

File tree

java/ql/src/experimental/Security/CWE/CWE-094/InsecureBeanValidation.qhelp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
<qhelp>
55

66
<overview>
7-
<p>When building custom constraint violation error messages, it is important to understand that they support different types of interpolation, including [Java EL expressions](https://docs.jboss.org/hibernate/validator/5.1/reference/en-US/html/chapter-message-interpolation.html#section-interpolation-with-message-expressions). Therefore if an attacker can inject arbitrary data in the error message template being passed to `ConstraintValidatorContext.buildConstraintViolationWithTemplate()` argument, he will be able to run arbitrary Java code. Unfortunately, it is common that validated (and therefore, normally untrusted) bean properties flow into the custom error message.</p>
7+
<p>Bean validation custom constraint error messages support different types of interpolation, including [Java EL expressions](https://docs.jboss.org/hibernate/validator/5.1/reference/en-US/html/chapter-message-interpolation.html#section-interpolation-with-message-expressions).
8+
Controlling part of the error message template being passed to `ConstraintValidatorContext.buildConstraintViolationWithTemplate()` argument will lead to arbitrary Java code execution.
9+
Unfortunately, it is common that validated (and therefore, normally untrusted) bean properties flow into the custom error message.</p>
810
</overview>
911

1012
<recommendation>
@@ -35,5 +37,6 @@ Validator validator = Validation.byDefaultProvider()
3537

3638
<references>
3739
<li>https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/#_the_code_constraintvalidatorcontext_code</li>
40+
<li>https://securitylab.github.com/research/bean-validation-RCE</li>
3841
</references>
3942
</qhelp>

java/ql/src/experimental/Security/CWE/CWE-094/InsecureBeanValidation.ql

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,6 @@ class BeanValidationSource extends RemoteFlowSource {
3232
override string getSourceType() { result = "BeanValidation source" }
3333
}
3434

35-
class ExceptionTaintStep extends TaintTracking::AdditionalTaintStep {
36-
override predicate step(DataFlow::Node n1, DataFlow::Node n2) {
37-
exists(Call call, TryStmt t, CatchClause c, MethodAccess gm |
38-
call.getEnclosingStmt().getEnclosingStmt*() = t.getBlock() and
39-
t.getACatchClause() = c and
40-
(
41-
call.getCallee().getAThrownExceptionType().getASubtype*() = c.getACaughtType() or
42-
c.getACaughtType().getASupertype*() instanceof TypeRuntimeException
43-
) and
44-
c.getVariable().getAnAccess() = gm.getQualifier() and
45-
gm.getMethod().getName().regexpMatch("get(Localized)?Message|toString") and
46-
n1.asExpr() = call.getAnArgument() and
47-
n2.asExpr() = gm
48-
)
49-
}
50-
}
51-
5235
class BuildConstraintViolationWithTemplateMethod extends Method {
5336
BuildConstraintViolationWithTemplateMethod() {
5437
getDeclaringType()

0 commit comments

Comments
 (0)