Skip to content

Commit df5314d

Browse files
committed
feat: 新增QLExpress表达式注入检测时判断sendbox和白名单配置
1 parent 0bd0d5f commit df5314d

File tree

1 file changed

+25
-10
lines changed
  • dongtai-core/src/main/java/io/dongtai/iast/core/handler/hookpoint/vulscan/dynamic

1 file changed

+25
-10
lines changed

dongtai-core/src/main/java/io/dongtai/iast/core/handler/hookpoint/vulscan/dynamic/QLExpressCheck.java

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.lang.reflect.Modifier;
1010
import java.util.Arrays;
1111
import java.util.List;
12+
import java.util.Set;
1213

1314
/**
1415
* @author UzJu
@@ -36,29 +37,43 @@ public boolean match(MethodEvent event, SinkNode sinkNode) {
3637
@Override
3738
public boolean isSafe(MethodEvent event, SinkNode sinkNode){
3839
/**
39-
* Die QLExpress-Komponente bietet die Konfigurationsfunktion forbidInvokeSecurityRiskMethods, um die Erkennung von schwarzen Listen zu ermöglichen. Daher muss zusätzlich zur Bestimmung des Senkenpunkts auch festgestellt werden, ob der Benutzer diese Konfiguration aktiviert hat.
40-
* Wenn diese Konfiguration aktiviert ist, werden Sie beim Aufruf einer auf der schwarzen Liste stehenden Klasse aufgefordert: com.ql.util.express.exception.QLSecurityRiskException: Eine unsichere Systemmethode wurde mit QLExpress aufgerufen: public java.lang.Process java. lang.Runtime.exec(java.lang.String) throws java.io.IOException
40+
* The QLExpress component provides the forbidInvokeSecurityRiskMethods configuration function to enable blacklist detection. Therefore, in addition to determining the sink point, you must also determine if the user has this configuration enabled.
41+
* If this configuration is enabled, you will be prompted when calling a blacklisted class: com.ql.util.express.exception.QLSecurityRiskException: An unsafe system method was called using QLExpress: public java.lang.Process java. lang.Runtime.exec(java.lang.String) throws java.io.IOException
4142
* */
42-
DongTaiLog.debug("Start der Ermittlung, ob das Feld forbidInvokeSecurityRiskMethods der QLExpress-Komponente wahr ist oder nicht");
43+
DongTaiLog.debug("Start determining whether the forbidInvokeSecurityRiskMethods field of the QLExpress component is true or not.");
4344
try {
4445
Class<?> cls;
4546
if (QL_CLASS_LOADER == null){
4647
cls = Class.forName(" com.ql.util.express.config.QLExpressRunStrategy".substring(1));
4748
}else {
4849
cls = Class.forName(" com.ql.util.express.config.QLExpressRunStrategy".substring(1), false, QL_CLASS_LOADER);
4950
}
50-
Field field = cls.getDeclaredField("forbidInvokeSecurityRiskMethods");
51-
if (Modifier.isStatic(field.getModifiers()) && Modifier.isPrivate(field.getModifiers())) {
52-
field.setAccessible(true);
53-
boolean value = field.getBoolean(null);
54-
DongTaiLog.debug("forbidInvokeSecurityRiskMethods = " + value);
55-
return value;
51+
52+
Field getBlackListField = cls.getDeclaredField("forbidInvokeSecurityRiskMethods");
53+
Field getSendBoxModeField = cls.getDeclaredField("sandboxMode");
54+
Field getWhiteListField = cls.getDeclaredField("SECURE_METHOD_LIST");
55+
56+
if (Modifier.isStatic(getBlackListField.getModifiers()) && Modifier.isPrivate(getBlackListField.getModifiers()) && Modifier.isStatic(getSendBoxModeField.getModifiers()) && Modifier.isPrivate(getSendBoxModeField.getModifiers()) && Modifier.isStatic(getWhiteListField.getModifiers()) && Modifier.isPrivate(getWhiteListField.getModifiers())) {
57+
// Make private fields accessible to reflection
58+
getBlackListField.setAccessible(true);
59+
getSendBoxModeField.setAccessible(true);
60+
getWhiteListField.setAccessible(true);
61+
62+
// get fields value
63+
boolean blackListBoolean = getBlackListField.getBoolean(null);
64+
boolean sendBoxBoolean = getSendBoxModeField.getBoolean(null);
65+
Set<String> secureMethodList = (Set<String>) getWhiteListField.get(null);
66+
DongTaiLog.debug("SECURE_METHOD_LIST = " + secureMethodList);
67+
DongTaiLog.debug("sandboxMode = " + sendBoxBoolean);
68+
DongTaiLog.debug("forbidInvokeSecurityRiskMethods = " + blackListBoolean);
69+
// All three conditions need to be met
70+
return (secureMethodList != null && !secureMethodList.isEmpty()) || sendBoxBoolean || blackListBoolean;
5671
} else {
5772
DongTaiLog.debug("Field is not static and private.");
5873
return true;
5974
}
6075
}catch (Throwable e){
61-
DongTaiLog.debug("Beim Abrufen der Felder der QLExpress-Komponente ist ein Fehler aufgetreten.: {}, {}",
76+
DongTaiLog.debug("An error occurred while retrieving the fields of the QLExpress component.: {}, {}",
6277
e.getClass().getName() + ": " + e.getMessage(),
6378
e.getCause() != null ? e.getCause().getMessage() : "");
6479
return true;

0 commit comments

Comments
 (0)