Skip to content

Commit 8874d32

Browse files
author
‘niuerzhuang’
committed
fix: custom model
1 parent 387c5ea commit 8874d32

File tree

3 files changed

+70
-113
lines changed

3 files changed

+70
-113
lines changed

dongtai-core/src/main/java/io/dongtai/iast/core/handler/hookpoint/controller/impl/SourceImpl.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,25 +82,9 @@ private static boolean trackTarget(MethodEvent event, SourceNode sourceNode) {
8282
}
8383

8484
TaintPoolUtils.trackObject(event, sourceNode, event.returnInstance, 0);
85-
// @TODO: hook json serializer for custom model
86-
handlerCustomModel(event, sourceNode);
8785
return true;
8886
}
8987

90-
/**
91-
* todo: 处理过程和结果需要细化
92-
*
93-
* @param event MethodEvent
94-
*/
95-
public static void handlerCustomModel(MethodEvent event, SourceNode sourceNode) {
96-
if (!"getSession".equals(event.getMethodName())) {
97-
Set<Object> modelValues = TaintPoolUtils.parseCustomModel(event.returnInstance);
98-
for (Object modelValue : modelValues) {
99-
TaintPoolUtils.trackObject(event, sourceNode, modelValue, 0);
100-
}
101-
}
102-
}
103-
10488
private static boolean allowCall(MethodEvent event) {
10589
boolean allowed = true;
10690
if (METHOD_OF_GETATTRIBUTE.equals(event.getMethodName())) {

dongtai-core/src/main/java/io/dongtai/iast/core/utils/TaintPoolUtils.java

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -146,38 +146,6 @@ public static boolean isAllowTaintType(Object obj) {
146146
return isAllowTaintType(obj.getClass());
147147
}
148148

149-
public static Set<Object> parseCustomModel(Object model) {
150-
Set<Object> modelValues = new HashSet<Object>();
151-
try {
152-
if (!TaintPoolUtils.isAllowTaintGetterModel(model)) {
153-
return modelValues;
154-
}
155-
156-
// getter methods
157-
Method[] methods = model.getClass().getMethods();
158-
Object itemValue = null;
159-
for (Method method : methods) {
160-
if (!TaintPoolUtils.isAllowTaintGetterMethod(method)) {
161-
continue;
162-
}
163-
164-
try {
165-
method.setAccessible(true);
166-
itemValue = method.invoke(model);
167-
if (!TaintPoolUtils.isNotEmpty(itemValue) || !TaintPoolUtils.isAllowTaintType(itemValue)) {
168-
continue;
169-
}
170-
modelValues.add(itemValue);
171-
} catch (Throwable e) {
172-
DongTaiLog.error(ErrorCode.get("UTIL_TAINT_PARSE_CUSTOM_MODEL_FAILED"),
173-
model.getClass().getName(), method.getName(), e);
174-
}
175-
}
176-
} catch (Throwable ignore) {
177-
}
178-
return modelValues;
179-
}
180-
181149
public static boolean isAllowTaintGetterModel(Object model) {
182150
if (!TaintPoolUtils.isNotEmpty(model)) {
183151
return false;
@@ -309,13 +277,6 @@ public static void trackObject(MethodEvent event, PolicyNode policyNode, Object
309277
event.addTargetHash(hash);
310278
EngineManager.TAINT_RANGES_POOL.add(hash, tr);
311279
} else {
312-
if (!(obj instanceof String)) {
313-
Set<Object> modelValues = TaintPoolUtils.parseCustomModel(obj);
314-
for (Object modelValue : modelValues) {
315-
trackObject(event, policyNode, modelValue, depth + 1);
316-
}
317-
}
318-
319280
hash = System.identityHashCode(obj);
320281
if (EngineManager.TAINT_HASH_CODES.contains(hash)) {
321282
event.addSourceHash(hash);

dongtai-core/src/main/resources/com.secnium.iast.resources/blacklist.txt

Lines changed: 70 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3583,6 +3583,7 @@ com/bea/security/xacml/target/TargetEvaluatorRegistry
35833583
com/bea/sslplus/CerticomSSLContext
35843584
com/bea/staxb/buildtime/internal/bts/BaseBindingLoader
35853585
com/bea/staxb/buildtime/internal/bts/BindingFile
3586+
com/bea/staxb/buildtime/internal/bts.BindingFileInputStream
35863587
com/bea/staxb/buildtime/internal/bts/BindingLoader
35873588
com/bea/staxb/buildtime/internal/bts/BindingMappingFile
35883589
com/bea/staxb/buildtime/internal/bts/BindingProperty
@@ -4649,7 +4650,7 @@ com/fasterxml/jackson/databind/DeserializationContext
46494650
com/fasterxml/jackson/databind/DeserializationFeature
46504651
com/fasterxml/jackson/databind/InjectableValues
46514652
com/fasterxml/jackson/databind/JavaType
4652-
com/fasterxml/jackson/databind/JsonDeserializer
4653+
# com/fasterxml/jackson/databind/JsonDeserializer
46534654
com/fasterxml/jackson/databind/JsonMappingException
46544655
com/fasterxml/jackson/databind/JsonSerializable
46554656
com/fasterxml/jackson/databind/JsonSerializable$Base
@@ -4734,61 +4735,61 @@ com/fasterxml/jackson/databind/deser/impl/PropertyBasedCreator$CaseInsensitiveMa
47344735
com/fasterxml/jackson/databind/deser/impl/PropertyBasedObjectIdGenerator
47354736
com/fasterxml/jackson/databind/deser/impl/SetterlessProperty
47364737
com/fasterxml/jackson/databind/deser/impl/TypeWrappedDeserializer
4737-
com/fasterxml/jackson/databind/deser/std/ArrayBlockingQueueDeserializer
4738-
com/fasterxml/jackson/databind/deser/std/AtomicBooleanDeserializer
4739-
com/fasterxml/jackson/databind/deser/std/AtomicReferenceDeserializer
4740-
com/fasterxml/jackson/databind/deser/std/BaseNodeDeserializer
4741-
com/fasterxml/jackson/databind/deser/std/BaseNodeDeserializer$1
4742-
com/fasterxml/jackson/databind/deser/std/ByteBufferDeserializer
4743-
com/fasterxml/jackson/databind/deser/std/CollectionDeserializer
4744-
com/fasterxml/jackson/databind/deser/std/ContainerDeserializerBase
4745-
com/fasterxml/jackson/databind/deser/std/EnumDeserializer
4746-
com/fasterxml/jackson/databind/deser/std/EnumMapDeserializer
4747-
com/fasterxml/jackson/databind/deser/std/EnumSetDeserializer
4748-
com/fasterxml/jackson/databind/deser/std/FromStringDeserializer
4749-
com/fasterxml/jackson/databind/deser/std/FromStringDeserializer$Std
4750-
com/fasterxml/jackson/databind/deser/std/JavaTypeDeserializer
4751-
com/fasterxml/jackson/databind/deser/std/JdkDeserializers
4752-
com/fasterxml/jackson/databind/deser/std/JsonLocationInstantiator
4753-
com/fasterxml/jackson/databind/deser/std/JsonNodeDeserializer
4754-
com/fasterxml/jackson/databind/deser/std/JsonNodeDeserializer$1
4755-
com/fasterxml/jackson/databind/deser/std/JsonNodeDeserializer$ArrayDeserializer
4756-
com/fasterxml/jackson/databind/deser/std/JsonNodeDeserializer$ObjectDeserializer
4757-
com/fasterxml/jackson/databind/deser/std/MapDeserializer
4758-
com/fasterxml/jackson/databind/deser/std/MapEntryDeserializer
4759-
com/fasterxml/jackson/databind/deser/std/NullifyingDeserializer
4760-
com/fasterxml/jackson/databind/deser/std/ObjectArrayDeserializer
4761-
com/fasterxml/jackson/databind/deser/std/StackTraceElementDeserializer
4762-
com/fasterxml/jackson/databind/deser/std/StdDelegatingDeserializer
4763-
com/fasterxml/jackson/databind/deser/std/StdDeserializer
4764-
com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer
4765-
com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$BoolKD
4766-
com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$ByteKD
4767-
com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$CalendarKD
4768-
com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$CharKD
4769-
com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$DateKD
4770-
com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$DelegatingKD
4771-
com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$DoubleKD
4772-
com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$EnumKD
4773-
com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$FloatKD
4774-
com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$IntKD
4775-
com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$LocaleKD
4776-
com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$LongKD
4777-
com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$ShortKD
4778-
com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$StringCtorKeyDeserializer
4779-
com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$StringFactoryKeyDeserializer
4780-
com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$StringKD
4781-
com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$UuidKD
4782-
com/fasterxml/jackson/databind/deser/std/StdKeyDeserializers
4783-
com/fasterxml/jackson/databind/deser/std/StdScalarDeserializer
4784-
com/fasterxml/jackson/databind/deser/std/StdValueInstantiator
4785-
com/fasterxml/jackson/databind/deser/std/StringArrayDeserializer
4786-
com/fasterxml/jackson/databind/deser/std/StringCollectionDeserializer
4787-
com/fasterxml/jackson/databind/deser/std/StringDeserializer
4788-
com/fasterxml/jackson/databind/deser/std/ThrowableDeserializer
4789-
com/fasterxml/jackson/databind/deser/std/TokenBufferDeserializer
4790-
com/fasterxml/jackson/databind/deser/std/UUIDDeserializer
4791-
com/fasterxml/jackson/databind/deser/std/UntypedObjectDeserializer
4738+
# com/fasterxml/jackson/databind/deser/std/ArrayBlockingQueueDeserializer
4739+
# com/fasterxml/jackson/databind/deser/std/AtomicBooleanDeserializer
4740+
# com/fasterxml/jackson/databind/deser/std/AtomicReferenceDeserializer
4741+
# com/fasterxml/jackson/databind/deser/std/BaseNodeDeserializer
4742+
# com/fasterxml/jackson/databind/deser/std/BaseNodeDeserializer$1
4743+
# com/fasterxml/jackson/databind/deser/std/ByteBufferDeserializer
4744+
# com/fasterxml/jackson/databind/deser/std/CollectionDeserializer
4745+
# com/fasterxml/jackson/databind/deser/std/ContainerDeserializerBase
4746+
# com/fasterxml/jackson/databind/deser/std/EnumDeserializer
4747+
# com/fasterxml/jackson/databind/deser/std/EnumMapDeserializer
4748+
# com/fasterxml/jackson/databind/deser/std/EnumSetDeserializer
4749+
# com/fasterxml/jackson/databind/deser/std/FromStringDeserializer
4750+
# com/fasterxml/jackson/databind/deser/std/FromStringDeserializer$Std
4751+
# com/fasterxml/jackson/databind/deser/std/JavaTypeDeserializer
4752+
# com/fasterxml/jackson/databind/deser/std/JdkDeserializers
4753+
# com/fasterxml/jackson/databind/deser/std/JsonLocationInstantiator
4754+
# com/fasterxml/jackson/databind/deser/std/JsonNodeDeserializer
4755+
# com/fasterxml/jackson/databind/deser/std/JsonNodeDeserializer$1
4756+
# com/fasterxml/jackson/databind/deser/std/JsonNodeDeserializer$ArrayDeserializer
4757+
# com/fasterxml/jackson/databind/deser/std/JsonNodeDeserializer$ObjectDeserializer
4758+
# com/fasterxml/jackson/databind/deser/std/MapDeserializer
4759+
# com/fasterxml/jackson/databind/deser/std/MapEntryDeserializer
4760+
# com/fasterxml/jackson/databind/deser/std/NullifyingDeserializer
4761+
# com/fasterxml/jackson/databind/deser/std/ObjectArrayDeserializer
4762+
# com/fasterxml/jackson/databind/deser/std/StackTraceElementDeserializer
4763+
# com/fasterxml/jackson/databind/deser/std/StdDelegatingDeserializer
4764+
# com/fasterxml/jackson/databind/deser/std/StdDeserializer
4765+
# com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer
4766+
# com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$BoolKD
4767+
# com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$ByteKD
4768+
# com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$CalendarKD
4769+
# com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$CharKD
4770+
# com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$DateKD
4771+
# com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$DelegatingKD
4772+
# com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$DoubleKD
4773+
# com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$EnumKD
4774+
# com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$FloatKD
4775+
# com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$IntKD
4776+
# com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$LocaleKD
4777+
# com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$LongKD
4778+
# com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$ShortKD
4779+
# com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$StringCtorKeyDeserializer
4780+
# com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$StringFactoryKeyDeserializer
4781+
# com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$StringKD
4782+
# com/fasterxml/jackson/databind/deser/std/StdKeyDeserializer$UuidKD
4783+
# com/fasterxml/jackson/databind/deser/std/StdKeyDeserializers
4784+
# com/fasterxml/jackson/databind/deser/std/StdScalarDeserializer
4785+
# com/fasterxml/jackson/databind/deser/std/StdValueInstantiator
4786+
# com/fasterxml/jackson/databind/deser/std/StringArrayDeserializer
4787+
# com/fasterxml/jackson/databind/deser/std/StringCollectionDeserializer
4788+
# com/fasterxml/jackson/databind/deser/std/StringDeserializer
4789+
# com/fasterxml/jackson/databind/deser/std/ThrowableDeserializer
4790+
# com/fasterxml/jackson/databind/deser/std/TokenBufferDeserializer
4791+
# com/fasterxml/jackson/databind/deser/std/UUIDDeserializer
4792+
# com/fasterxml/jackson/databind/deser/std/UntypedObjectDeserializer
47924793
com/fasterxml/jackson/databind/exc/IgnoredPropertyException
47934794
com/fasterxml/jackson/databind/exc/InvalidFormatException
47944795
com/fasterxml/jackson/databind/exc/PropertyBindingException
@@ -23724,7 +23725,7 @@ java/io/OutputStream
2372423725
java/io/OutputStreamWriter
2372523726
java/io/PipedOutputStream
2372623727
java/io/PrintStream
23727-
java/io/PushbackInputStream
23728+
# java/io/PushbackInputStream
2372823729
java/io/PushbackReader
2372923730
java/io/RandomAccessFile
2373023731
java/io/RandomAccessFile$1
@@ -24894,6 +24895,7 @@ java/util/StringTokenizer
2489424895
# java/util/stream/IntStream
2489524896
# java/util/stream/Stream
2489624897
java/util/zip/*
24898+
java/util/zip/CheckedInputStream
2489724899
javassist/ByteArrayClassPath
2489824900
javassist/CannotCompileException
2489924901
javassist/ClassClassPath
@@ -27852,6 +27854,7 @@ javelin/jsp/JspTagLibraryFeature$1
2785227854
javelin/jsp/JspTagLibraryFeature$2
2785327855
javelin/jsp/JspTagLibraryFeature$TagLibraryContext
2785427856
javelin/jsp/JspTagLibraryFeature$TldChangeListener
27857+
javelin.jsp.JspTagLibraryFeature$UncloseableInputStream
2785527858
javelin/jsp/JspTagLibraryFeature$WebXmlChangeListener
2785627859
javelin/jsp/JspTagLibraryParser
2785727860
javelin/jsp/JspTagLibraryParser$JSPEntityResolver
@@ -38053,6 +38056,7 @@ org/apache/xerces/impl/XMLEntityManager$EncodingInfo
3805338056
org/apache/xerces/impl/XMLEntityManager$Entity
3805438057
org/apache/xerces/impl/XMLEntityManager$ExternalEntity
3805538058
org/apache/xerces/impl/XMLEntityManager$InternalEntity
38059+
org/apache/xerces/impl/XMLEntityManager$RewindableInputStream
3805638060
org/apache/xerces/impl/XMLEntityManager$ScannedEntity
3805738061
org/apache/xerces/impl/XMLEntityScanner
3805838062
org/apache/xerces/impl/XMLEntityScanner$1
@@ -59960,7 +59964,7 @@ org/springframework/util/SerializationUtils
5996059964
org/springframework/util/StopWatch
5996159965
org/springframework/util/StopWatch$TaskInfo
5996259966
org/springframework/util/StreamUtils$NonClosingOutputStream
59963-
org/springframework/util/StringUtils
59967+
# org/springframework/util/StringUtils
5996459968
org/springframework/util/StringValueResolver
5996559969
org/springframework/util/SystemPropertyUtils
5996659970
org/springframework/util/SystemPropertyUtils$SystemPropertyPlaceholderResolver
@@ -64568,6 +64572,7 @@ weblogic/common/internal/VersionInfoFactory$PEER_INFO_FOR_WIRE_SINGLETON
6456864572
weblogic/common/internal/VersionInfoFactory$PEER_INFO_SINGLETON
6456964573
weblogic/common/internal/VersionInfoFactory$VERSION_INFO_SINGLETON
6457064574
weblogic/common/internal/VersioningError
64575+
weblogic/common/internal/WLObjectInputStream
6457164576
weblogic/common/internal/WLObjectOutputStream
6457264577
weblogic/common/resourcepool/IPooledResourceLinkedList
6457364578
weblogic/common/resourcepool/ObjectLifeCycle
@@ -65955,6 +65960,7 @@ weblogic/iiop/EndPointFactory
6595565960
weblogic/iiop/IDLUtils
6595665961
weblogic/iiop/IIOPClient
6595765962
weblogic/iiop/IIOPClientService
65963+
weblogic/iiop/IIOPInputStream
6595865964
weblogic/iiop/IIOPLogger
6595965965
weblogic/iiop/IIOPLogger$MessageLoggerInitializer
6596065966
weblogic/iiop/IIOPOutputStream
@@ -70018,6 +70024,7 @@ weblogic/net/http/HttpsClient
7001870024
weblogic/net/http/HttpsURLConnection
7001970025
weblogic/net/http/KeepAliveCache
7002070026
weblogic/net/http/KeepAliveKey
70027+
weblogic/net/http/KeepAliveStream
7002170028
weblogic/net/http/MessageHeader
7002270029
weblogic/net/http/NETEnvironment
7002370030
weblogic/net/http/SOAPHttpURLConnection
@@ -72305,6 +72312,7 @@ weblogic/utils/enumerations/LIFO_FileContainer
7230572312
weblogic/utils/expressions/ExpressionEvaluationException
7230672313
weblogic/utils/expressions/ExpressionMap
7230772314
weblogic/utils/http/BytesToString
72315+
weblogic/utils/http/HttpChunkInputStream
7230872316
weblogic/utils/http/HttpChunkOutputStream
7230972317
weblogic/utils/http/HttpConstants
7231072318
weblogic/utils/http/HttpParsing
@@ -72318,13 +72326,15 @@ weblogic/utils/http/MaxRequestParameterExceedException
7231872326
weblogic/utils/io/ByteBufferDataInputStream
7231972327
weblogic/utils/io/ByteBufferDataOutputStream
7232072328
weblogic/utils/io/ByteBufferObjectInputStream
72329+
weblogic/utils/io/ByteBufferObjectInputStream$ContextObjectInputStream
7232172330
weblogic/utils/io/ByteBufferObjectOutputStream
7232272331
weblogic/utils/io/ByteBufferOutputStream
7232372332
weblogic/utils/io/Chunk
7232472333
weblogic/utils/io/ChunkInput
7232572334
weblogic/utils/io/ChunkInputStreamAccess
7232672335
weblogic/utils/io/ChunkOutput
7232772336
weblogic/utils/io/ChunkedDataOutputStream
72337+
weblogic/utils/io/ChunkedInputStream
7232872338
weblogic/utils/io/ChunkedObjectOutputStream
7232972339
weblogic/utils/io/ChunkedObjectOutputStream$NestedObjectOutputStream
7233072340
weblogic/utils/io/ChunkedOutputStream
@@ -73559,6 +73569,7 @@ weblogic/xml/stream/events/SpaceEvent
7355973569
weblogic/xml/stream/events/StartDocumentEvent
7356073570
weblogic/xml/stream/events/StartElementEvent
7356173571
weblogic/xml/stream/util/RecyclingFactory
73572+
weblogic/xml/util/CachedInputStream
7356273573
weblogic/xml/util/Debug
7356373574
weblogic/xml/util/Debug$DebugFacility
7356473575
weblogic/xml/util/Debug$DebugFacility$DebugListener
@@ -73628,6 +73639,7 @@ workshop/util/encoding/EncodingManager$EncodingProxy
7362873639
workshop/util/encoding/EncodingReader
7362973640
workshop/util/encoding/impl/PropertiesEncoding
7363073641
workshop/util/encoding/impl/TextEncoding
73642+
workshop/util/filesystem/util/InputStreamWrapper
7363173643
com/alibaba/druid/filter/logging/Log4jFilter
7363273644
# disable alibaba sandbox's class dongtai-001
7363373645
com/alibaba/jvm/sandbox/*

0 commit comments

Comments
 (0)