@@ -48,10 +48,10 @@ private class CoreDataStore extends CleartextStorageDatabaseSink {
4848 // example in `coreDataObj.data = sensitive` the post-update node corresponding
4949 // with `coreDataObj.data` is a sink.
5050 // (ideally this would be only members with the `@NSManaged` attribute)
51- exists ( ClassOrStructDecl cd , Expr e |
52- cd . getABaseTypeDecl * ( ) .getName ( ) = "NSManagedObject" and
51+ exists ( NominalType t , Expr e |
52+ t . getABaseType * ( ) .getName ( ) = "NSManagedObject" and
5353 this .( DataFlow:: PostUpdateNode ) .getPreUpdateNode ( ) .asExpr ( ) = e and
54- e .getFullyConverted ( ) .getType ( ) = cd . getType ( ) and
54+ e .getFullyConverted ( ) .getType ( ) = t and
5555 not e .( DeclRefExpr ) .getDecl ( ) instanceof SelfParamDecl
5656 )
5757 }
@@ -66,10 +66,10 @@ private class RealmStore extends CleartextStorageDatabaseSink instanceof DataFlo
6666 // any write into a class derived from `RealmSwiftObject` is a sink. For
6767 // example in `realmObj.data = sensitive` the post-update node corresponding
6868 // with `realmObj.data` is a sink.
69- exists ( ClassOrStructDecl cd , Expr e |
70- cd . getABaseTypeDecl * ( ) .getName ( ) = "RealmSwiftObject" and
69+ exists ( NominalType t , Expr e |
70+ t . getABaseType * ( ) .getName ( ) = "RealmSwiftObject" and
7171 this .getPreUpdateNode ( ) .asExpr ( ) = e and
72- e .getFullyConverted ( ) .getType ( ) = cd . getType ( ) and
72+ e .getFullyConverted ( ) .getType ( ) = t and
7373 not e .( DeclRefExpr ) .getDecl ( ) instanceof SelfParamDecl
7474 )
7575 }
@@ -122,15 +122,22 @@ private class CleartextStorageDatabaseEncryptionSanitizer extends CleartextStora
122122
123123/**
124124 * An additional taint step for cleartext database storage vulnerabilities.
125- * Needed until we have proper content flow through arrays.
126125 */
127126private class CleartextStorageDatabaseArrayAdditionalTaintStep extends CleartextStorageDatabaseAdditionalTaintStep
128127{
129128 override predicate step ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
129+ // needed until we have proper content flow through arrays.
130130 exists ( ArrayExpr arr |
131131 nodeFrom .asExpr ( ) = arr .getAnElement ( ) and
132132 nodeTo .asExpr ( ) = arr
133133 )
134+ or
135+ // if an object is sensitive, its fields are always sensitive
136+ // (this is needed because the sensitive data sources are in a sense
137+ // approximate; for example we might identify `passwordBox` as a source,
138+ // whereas it is more accurate to say that `passwordBox.textField` is the
139+ // true source).
140+ nodeTo .asExpr ( ) .( MemberRefExpr ) .getBase ( ) = nodeFrom .asExpr ( )
134141 }
135142}
136143
0 commit comments