File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
cpp/ql/src/Security/CWE/CWE-313 Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,14 @@ predicate sqlite_encryption_used() {
2828 any ( FunctionCall fc ) .getTarget ( ) .getName ( ) .matches ( "sqlite%\\_key\\_%" )
2929}
3030
31+ /**
32+ * Gets a field of the class `c`, or of another class contained in `c`.
33+ */
34+ Field getRecField ( Class c ) {
35+ result = c .getAField ( ) or
36+ result = getRecField ( c .getAField ( ) .getUnspecifiedType ( ) .stripType ( ) )
37+ }
38+
3139/**
3240 * A taint flow configuration for flow from a sensitive expression to a `SqliteFunctionCall` sink.
3341 */
@@ -44,6 +52,19 @@ class FromSensitiveConfiguration extends TaintTracking::Configuration {
4452 override predicate isSanitizer ( DataFlow:: Node node ) {
4553 node .asExpr ( ) .getUnspecifiedType ( ) instanceof IntegralType
4654 }
55+
56+ override predicate allowImplicitRead ( DataFlow:: Node node , DataFlow:: ContentSet content ) {
57+ // flow out from fields at the sink (only).
58+ isSink ( node ) and
59+ // constrain `content` to a field inside the node.
60+ exists ( Class c |
61+ node .asExpr ( ) .getUnspecifiedType ( ) .stripType ( ) = c and
62+ content .( DataFlow:: FieldContent ) .getField ( ) = getRecField ( c )
63+ )
64+ or
65+ // any default implicit reads
66+ super .allowImplicitRead ( node , content )
67+ }
4768}
4869
4970from
You can’t perform that action at this time.
0 commit comments