@@ -48,10 +48,10 @@ private class CoreDataStore extends CleartextStorageDatabaseSink {
48
48
// example in `coreDataObj.data = sensitive` the post-update node corresponding
49
49
// with `coreDataObj.data` is a sink.
50
50
// (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
53
53
this .( DataFlow:: PostUpdateNode ) .getPreUpdateNode ( ) .asExpr ( ) = e and
54
- e .getFullyConverted ( ) .getType ( ) = cd . getType ( ) and
54
+ e .getFullyConverted ( ) .getType ( ) = t and
55
55
not e .( DeclRefExpr ) .getDecl ( ) instanceof SelfParamDecl
56
56
)
57
57
}
@@ -66,10 +66,10 @@ private class RealmStore extends CleartextStorageDatabaseSink instanceof DataFlo
66
66
// any write into a class derived from `RealmSwiftObject` is a sink. For
67
67
// example in `realmObj.data = sensitive` the post-update node corresponding
68
68
// 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
71
71
this .getPreUpdateNode ( ) .asExpr ( ) = e and
72
- e .getFullyConverted ( ) .getType ( ) = cd . getType ( ) and
72
+ e .getFullyConverted ( ) .getType ( ) = t and
73
73
not e .( DeclRefExpr ) .getDecl ( ) instanceof SelfParamDecl
74
74
)
75
75
}
@@ -122,15 +122,22 @@ private class CleartextStorageDatabaseEncryptionSanitizer extends CleartextStora
122
122
123
123
/**
124
124
* An additional taint step for cleartext database storage vulnerabilities.
125
- * Needed until we have proper content flow through arrays.
126
125
*/
127
126
private class CleartextStorageDatabaseArrayAdditionalTaintStep extends CleartextStorageDatabaseAdditionalTaintStep
128
127
{
129
128
override predicate step ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
129
+ // needed until we have proper content flow through arrays.
130
130
exists ( ArrayExpr arr |
131
131
nodeFrom .asExpr ( ) = arr .getAnElement ( ) and
132
132
nodeTo .asExpr ( ) = arr
133
133
)
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 ( )
134
141
}
135
142
}
136
143
0 commit comments