@@ -40,68 +40,24 @@ predicate isNotCleartextCredentials(string value) {
40
40
value .toLowerCase ( ) .matches ( possibleSecretName ( ) )
41
41
}
42
42
43
- /** The credentials configuration property. */
43
+ /** A configuration property that appears to contain a cleartext secret . */
44
44
class CredentialsConfig extends ConfigPair {
45
45
CredentialsConfig ( ) {
46
46
this .getNameElement ( ) .getName ( ) .trim ( ) .toLowerCase ( ) .matches ( possibleSecretName ( ) ) and
47
47
not this .getNameElement ( ) .getName ( ) .trim ( ) .toLowerCase ( ) .matches ( possibleEncryptedSecretName ( ) ) and
48
48
not isNotCleartextCredentials ( this .getValueElement ( ) .getValue ( ) .trim ( ) )
49
49
}
50
50
51
+ /** Gets the whitespace-trimmed name of this property. */
51
52
string getName ( ) { result = this .getNameElement ( ) .getName ( ) .trim ( ) }
52
53
54
+ /** Gets the whitespace-trimmed value of this property. */
53
55
string getValue ( ) { result = this .getValueElement ( ) .getValue ( ) .trim ( ) }
54
56
55
57
/** Returns a description of this vulnerability. */
56
58
string getConfigDesc ( ) {
57
- exists (
58
- // getProperty(...)
59
- LoadCredentialsConfiguration cc , DataFlow:: Node source , DataFlow:: Node sink , MethodAccess ma
60
- |
61
- this .getName ( ) = source .asExpr ( ) .( CompileTimeConstantExpr ) .getStringValue ( ) and
62
- cc .hasFlow ( source , sink ) and
63
- ma .getArgument ( 0 ) = sink .asExpr ( ) and
64
- result = "Plaintext credentials " + this .getName ( ) + " are loaded in Java Properties " + ma
65
- )
66
- or
67
- exists (
68
- // @Value("${mail.password}")
69
- Annotation a
70
- |
71
- a .getType ( ) .hasQualifiedName ( "org.springframework.beans.factory.annotation" , "Value" ) and
72
- a .getAValue ( ) .( CompileTimeConstantExpr ) .getStringValue ( ) = "${" + this .getName ( ) + "}" and
73
- result = "Plaintext credentials " + this .getName ( ) + " are loaded in Spring annotation " + a
74
- )
75
- or
76
- not exists ( LoadCredentialsConfiguration cc , DataFlow:: Node source , DataFlow:: Node sink |
77
- this .getName ( ) = source .asExpr ( ) .( CompileTimeConstantExpr ) .getStringValue ( ) and
78
- cc .hasFlow ( source , sink )
79
- ) and
80
- not exists ( Annotation a |
81
- a .getType ( ) .hasQualifiedName ( "org.springframework.beans.factory.annotation" , "Value" ) and
82
- a .getAValue ( ) .( CompileTimeConstantExpr ) .getStringValue ( ) = "${" + this .getName ( ) + "}"
83
- ) and
84
59
result =
85
60
"Plaintext credentials " + this .getName ( ) + " have cleartext value " + this .getValue ( ) +
86
61
" in properties file"
87
62
}
88
63
}
89
-
90
- /**
91
- * A dataflow configuration tracking flow of cleartext credentials stored in a properties file
92
- * to a `Properties.getProperty(...)` method call.
93
- */
94
- class LoadCredentialsConfiguration extends DataFlow:: Configuration {
95
- LoadCredentialsConfiguration ( ) { this = "LoadCredentialsConfiguration" }
96
-
97
- override predicate isSource ( DataFlow:: Node source ) {
98
- exists ( CredentialsConfig cc |
99
- source .asExpr ( ) .( CompileTimeConstantExpr ) .getStringValue ( ) = cc .getName ( )
100
- )
101
- }
102
-
103
- override predicate isSink ( DataFlow:: Node sink ) {
104
- sink .asExpr ( ) =
105
- any ( MethodAccess ma | ma .getMethod ( ) instanceof PropertiesGetPropertyMethod ) .getArgument ( 0 )
106
- }
107
- }
0 commit comments