The vulnerability exists in the QLExpressEngine class, which is part of the hutool-extra package. The core of the issue lies in the eval method, which is responsible for evaluating expressions. Before the patch, this method did not properly enforce any restrictions on the code being executed, allowing an attacker to invoke arbitrary Java methods. This could be leveraged for Remote Code Execution (RCE) by calling dangerous methods, such as javax.naming.InitialContext.doLookup, to perform a JNDI injection attack.
The security patch addresses this in two ways:
- It modifies the
QLExpressEngine constructor to enable a security manager (QLExpressRunStrategy.setForbidInvokeSecurityRiskMethods(true)) and explicitly blacklist the potentially harmful doLookup method from the InitialContext class.
- It enhances the
eval method to respect the allowClassSet parameter, which acts as a whitelist for permissible classes and their methods during expression evaluation.
Therefore, the primary vulnerable function is cn.hutool.extra.expression.engine.qlexpress.QLExpressEngine.eval as it's the entry point for the malicious expression. The constructor cn.hutool.extra.expression.engine.qlexpress.QLExpressEngine.QLExpressEngine is also relevant as its lack of security initialization is a key part of why the vulnerability was exploitable.