1313
1414import cpp
1515import semmle.code.cpp.security.SensitiveExprs
16- import semmle.code.cpp.security.TaintTracking
17- import TaintedWithPath
18-
19- class UserInputIsSensitiveExpr extends SecurityOptions {
20- override predicate isUserInput ( Expr expr , string cause ) {
21- expr instanceof SensitiveExpr and cause = "sensitive information"
22- }
23- }
16+ import semmle.code.cpp.dataflow.TaintTracking
17+ import DataFlow:: PathGraph
2418
2519class SqliteFunctionCall extends FunctionCall {
2620 SqliteFunctionCall ( ) { this .getTarget ( ) .getName ( ) .matches ( "sqlite%" ) }
@@ -34,25 +28,30 @@ predicate sqlite_encryption_used() {
3428 any ( FunctionCall fc ) .getTarget ( ) .getName ( ) .matches ( "sqlite%\\_key\\_%" )
3529}
3630
37- class Configuration extends TaintTrackingConfiguration {
38- override predicate isSource ( Expr source ) {
39- super .isSource ( source ) and source instanceof SensitiveExpr
31+ /**
32+ * Taint flow from a sensitive expression to a `SqliteFunctionCall` sink.
33+ */
34+ class FromSensitiveConfiguration extends TaintTracking:: Configuration {
35+ FromSensitiveConfiguration ( ) { this = "FromSensitiveConfiguration" }
36+
37+ override predicate isSource ( DataFlow:: Node source ) { source .asExpr ( ) instanceof SensitiveExpr }
38+
39+ override predicate isSink ( DataFlow:: Node sink ) {
40+ any ( SqliteFunctionCall c ) .getASource ( ) = sink .asExpr ( ) and
41+ not sqlite_encryption_used ( )
4042 }
4143
42- override predicate isSink ( Element taintedArg ) {
43- exists ( SqliteFunctionCall sqliteCall |
44- taintedArg = sqliteCall .getASource ( ) and
45- not sqlite_encryption_used ( )
46- )
44+ override predicate isSanitizer ( DataFlow:: Node node ) {
45+ node .asExpr ( ) .getUnspecifiedType ( ) instanceof IntegralType
4746 }
4847}
4948
5049from
51- SensitiveExpr taintSource , Expr taintedArg , SqliteFunctionCall sqliteCall , PathNode sourceNode ,
52- PathNode sinkNode
50+ FromSensitiveConfiguration config , SensitiveExpr sensitive , DataFlow :: PathNode source ,
51+ DataFlow :: PathNode sink , SqliteFunctionCall sqliteCall
5352where
54- taintedWithPath ( taintSource , taintedArg , sourceNode , sinkNode ) and
55- taintedArg = sqliteCall . getASource ( )
56- select sqliteCall , sourceNode , sinkNode ,
57- "This SQLite call may store $@ in a non-encrypted SQLite database" , taintSource ,
58- "sensitive information"
53+ config . hasFlowPath ( source , sink ) and
54+ source . getNode ( ) . asExpr ( ) = sensitive and
55+ sqliteCall . getASource ( ) = sink . getNode ( ) . asExpr ( )
56+ select sqliteCall , source , sink , "This SQLite call may store $@ in a non-encrypted SQLite database" ,
57+ sensitive , "sensitive information"
0 commit comments