@@ -13,7 +13,7 @@ import codeql.swift.security.CleartextStorageDatabaseExtensions
1313 * A taint configuration from sensitive information to expressions that are
1414 * transmitted over a network.
1515 */
16- class CleartextStorageConfig extends TaintTracking:: Configuration {
16+ deprecated class CleartextStorageConfig extends TaintTracking:: Configuration {
1717 CleartextStorageConfig ( ) { this = "CleartextStorageConfig" }
1818
1919 override predicate isSource ( DataFlow:: Node node ) { node .asExpr ( ) instanceof SensitiveExpr }
@@ -48,3 +48,44 @@ class CleartextStorageConfig extends TaintTracking::Configuration {
4848 super .allowImplicitRead ( node , c )
4949 }
5050}
51+
52+ /**
53+ * A taint configuration from sensitive information to expressions that are
54+ * transmitted over a network.
55+ */
56+ module CleartextStorageConfig implements DataFlow:: ConfigSig {
57+ predicate isSource ( DataFlow:: Node node ) { node .asExpr ( ) instanceof SensitiveExpr }
58+
59+ predicate isSink ( DataFlow:: Node node ) { node instanceof CleartextStorageDatabaseSink }
60+
61+ predicate isBarrier ( DataFlow:: Node sanitizer ) {
62+ sanitizer instanceof CleartextStorageDatabaseSanitizer
63+ }
64+
65+ predicate isAdditionalFlowStep ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
66+ any ( CleartextStorageDatabaseAdditionalTaintStep s ) .step ( nodeFrom , nodeTo )
67+ }
68+
69+ predicate isBarrierIn ( DataFlow:: Node node ) {
70+ // make sources barriers so that we only report the closest instance
71+ isSource ( node )
72+ }
73+
74+ predicate allowImplicitRead ( DataFlow:: Node node , DataFlow:: ContentSet c ) {
75+ // flow out from fields of an `NSManagedObject` or `RealmSwiftObject` at the sink,
76+ // for example in `realmObj.data = sensitive`.
77+ isSink ( node ) and
78+ exists ( NominalTypeDecl d , Decl cx |
79+ d .getType ( ) .getABaseType * ( ) .getUnderlyingType ( ) .getName ( ) =
80+ [ "NSManagedObject" , "RealmSwiftObject" ] and
81+ cx .asNominalTypeDecl ( ) = d and
82+ c .getAReadContent ( ) .( DataFlow:: Content:: FieldContent ) .getField ( ) = cx .getAMember ( )
83+ )
84+ }
85+ }
86+
87+ /**
88+ * Detect taint flow of sensitive information to expressions that are
89+ * transmitted over a network.
90+ */
91+ module CleartextStorageFlow = TaintTracking:: Global< CleartextStorageConfig > ;
0 commit comments