-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Potential Express Injection Vulnerability #3316
Comments
Hello @qxyuan853 , So, this also assumes that mybatis is used in an application that has a vulnerability allowing an attacker to execute arbitrary code using any class in the app's dependencies, am I right? FYI, OGNL provides a custom security manager that prevents some risky calls. |
Hi harawata, In addition, from what we’ve observed, most users tend to stick with the default configuration. Therefore, adding a default blacklist and whitelist restrictions might be a helpful enhancement. Otherwise, the OGNL parsing functionality in MyBatis could be more easily exploited by attackers to carry out malicious actions. Thank you for your continued attention to this matter. |
Hi harawata, |
The commit adds restriction to Thymeleaf's internal expression language. If the attacker can call And, please educate the developers you know about these security measures like JEP-290 if they haven't used them. |
Hi harawata, |
In MyBatis, risky string is not evaluated by OGNL unless 1) the app developer passes risky string directly to OGNL expression in their app or 2) there is some library that has vulnerability allowing attacker to execute arbitrary code. |
However, it seems that MyBatis-3 includes scenarios where OGNL may evaluate expressions that involve user input. The dynamic SQL features in MyBatis-3 (such as , , , and ) rely on OGNL to evaluate conditional expressions. External user input, passed through the parameterObject, can be included in these expressions and dynamically evaluated by OGNL. |
It might be. Here is the POJO. public class User {
private Integer id;
private String name;
// getters, setters
} The mapper and the method to search users by the properties of the public interface UserMapper {
List<User> search(User criteria);
} The mapper statement may look something like this. <select id="search" resultType="pkg.User">
select id, name from user
<where>
<if test="name != null">
and name = #{name}
</if>
</where>
</select> Now, if the developer sets an external user's input (e.g. a request parameter) to Even if the value of Hope this clarifies your concern. |
Problem Statement
In the MyBatis framework, the ExpressionEvaluator module uses OGNL to evaluate the values of expressions and handle the returned results. However, this functionality may be exploited by attackers to inject carefully crafted malicious expressions, enabling attacks such as remote code execution.
A vulnerable code example.
MyBatis version
<= 3.5.17
Steps to reproduce
Considering the security implications, I just provide the following test case as an example to reproduce the attack.
Vulnerability Impact
Remote Command Execution (RCE), such as the invocation of the calculator application.
The text was updated successfully, but these errors were encountered: