You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: java/ql/src/experimental/Security/CWE/CWE-094/InsecureBeanValidation.qhelp
+9-5Lines changed: 9 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,11 @@
4
4
<qhelp>
5
5
6
6
<overview>
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>
7
+
<p>Bean validation custom constraint error messages support different types of interpolation,
8
+
including <ahref="https://docs.jboss.org/hibernate/validator/5.1/reference/en-US/html/chapter-message-interpolation.html#section-interpolation-with-message-expressions">Java EL expressions</a>.
9
+
Controlling part of the message template being passed to `ConstraintValidatorContext.buildConstraintViolationWithTemplate()`
10
+
argument will lead to arbitrary Java code execution. Unfortunately, it is common that validated (and therefore, normally
11
+
untrusted) bean properties flow into the custom error message.</p>
context.buildConstraintViolationWithTemplate( "My violation message contains a parameter {foo}").addConstraintViolation();
20
22
```
21
-
<li>Sanitize the validated bean properties to make sure that there are no EL expressions. An example of valid sanitization logic can be found [here](https://github.com/hibernate/hibernate-validator/blob/master/engine/src/main/java/org/hibernate/validator/internal/engine/messageinterpolation/util/InterpolationHelper.java#L17).
23
+
<li>Sanitize the validated bean properties to make sure that there are no EL expressions. An example of valid sanitization
24
+
logic can be found <ahref="https://github.com/hibernate/hibernate-validator/blob/master/engine/src/main/java/org/hibernate/validator/internal/engine/messageinterpolation/util/InterpolationHelper.java#L17">here</a>.
22
25
- Disable the EL interpolation and only use `ParameterMessageInterpolator`:</li>
<li>Replace Hibernate-Validator with Apache BVal which in its latest version does not interpolate EL expressions by default. Note that this replacement may not be a simple drop-in replacement.</li>
33
+
<li>Replace Hibernate-Validator with Apache BVal which in its latest version does not interpolate EL expressions by default.
34
+
Note that this replacement may not be a simple drop-in replacement.</li>
0 commit comments