15
15
16
16
import cpp
17
17
import semmle.code.cpp.ir.dataflow.DataFlow
18
- import semmle.code.cpp.ir.dataflow.DataFlow2
19
18
20
19
/**
21
20
* A function call to SetSecurityDescriptorDacl to set the ACL, specified by (2nd argument) bDaclPresent = TRUE
@@ -30,26 +29,24 @@ class SetSecurityDescriptorDaclFunctionCall extends FunctionCall {
30
29
/**
31
30
* Dataflow that detects a call to SetSecurityDescriptorDacl with a NULL DACL as the pDacl argument
32
31
*/
33
- class NullDaclConfig extends DataFlow:: Configuration {
34
- NullDaclConfig ( ) { this = "NullDaclConfig" }
32
+ module NullDaclConfig implements DataFlow:: ConfigSig {
33
+ predicate isSource ( DataFlow :: Node source ) { source . asExpr ( ) instanceof NullValue }
35
34
36
- override predicate isSource ( DataFlow:: Node source ) { source .asExpr ( ) instanceof NullValue }
37
-
38
- override predicate isSink ( DataFlow:: Node sink ) {
35
+ predicate isSink ( DataFlow:: Node sink ) {
39
36
exists ( SetSecurityDescriptorDaclFunctionCall call , VariableAccess val | val = sink .asExpr ( ) |
40
37
val = call .getArgument ( 2 )
41
38
)
42
39
}
43
40
}
44
41
42
+ module NullDaclFlow = DataFlow:: Make< NullDaclConfig > ;
43
+
45
44
/**
46
45
* Dataflow that detects a call to SetSecurityDescriptorDacl with a pDacl
47
46
* argument that's _not_ likely to be NULL.
48
47
*/
49
- class NonNullDaclConfig extends DataFlow2:: Configuration {
50
- NonNullDaclConfig ( ) { this = "NonNullDaclConfig" }
51
-
52
- override predicate isSource ( DataFlow:: Node source ) {
48
+ module NonNullDaclConfig implements DataFlow:: ConfigSig {
49
+ predicate isSource ( DataFlow:: Node source ) {
53
50
source .getType ( ) .getUnspecifiedType ( ) .( PointerType ) .getBaseType ( ) =
54
51
any ( Type t | t .getName ( ) = "ACL" ) .getUnspecifiedType ( ) and
55
52
(
@@ -68,11 +65,13 @@ class NonNullDaclConfig extends DataFlow2::Configuration {
68
65
)
69
66
}
70
67
71
- override predicate isSink ( DataFlow:: Node sink ) {
68
+ predicate isSink ( DataFlow:: Node sink ) {
72
69
exists ( SetSecurityDescriptorDaclFunctionCall call | sink .asExpr ( ) = call .getArgument ( 2 ) )
73
70
}
74
71
}
75
72
73
+ module NonNullDaclFlow = DataFlow:: Make< NonNullDaclConfig > ;
74
+
76
75
from SetSecurityDescriptorDaclFunctionCall call , string message
77
76
where
78
77
exists ( NullValue nullExpr |
@@ -83,13 +82,13 @@ where
83
82
call .getArgument ( 2 ) = nullExpr
84
83
)
85
84
or
86
- exists ( VariableAccess var , NullDaclConfig nullDaclConfig , NonNullDaclConfig nonNullDaclConfig |
85
+ exists ( VariableAccess var |
87
86
message =
88
87
"Setting a DACL to NULL in a SECURITY_DESCRIPTOR using variable " + var +
89
88
" that is set to NULL will result in an unprotected object."
90
89
|
91
90
var = call .getArgument ( 2 ) and
92
- nullDaclConfig . hasFlowToExpr ( var ) and
93
- not nonNullDaclConfig . hasFlowToExpr ( var )
91
+ NullDaclFlow :: hasFlowToExpr ( var ) and
92
+ not NonNullDaclFlow :: hasFlowToExpr ( var )
94
93
)
95
94
select call , message
0 commit comments