@@ -2,7 +2,7 @@ import csharp
2
2
import DataFlow
3
3
4
4
/**
5
- * Abstract PropertyWrite for `TokenValidationParameters`.
5
+ * An abstract PropertyWrite for `TokenValidationParameters`.
6
6
* Not really necessary anymore, but keeping it in case we want to extend the queries to check on other properties.
7
7
*/
8
8
abstract class TokenValidationParametersPropertyWrite extends PropertyWrite { }
@@ -18,27 +18,29 @@ class TokenValidationParametersPropertyWriteToBypassSensitiveValidation extends
18
18
p .getAnAccess ( ) = this and
19
19
c .getAProperty ( ) = p and
20
20
p .getName ( ) in [
21
- "ValidateIssuer" , "ValidateAudience" , "ValidateLifetime" , "RequireExpirationTime"
21
+ "ValidateIssuer" , "ValidateAudience" , "ValidateLifetime" , "RequireExpirationTime" , "RequireAudience"
22
22
]
23
23
)
24
24
}
25
25
}
26
26
27
27
/**
28
- * Dataflow from a `false` value to an to a write sensitive property for `TokenValidationParameters`.
28
+ * A dataflow from a `false` value to a write sensitive property for `TokenValidationParameters`.
29
29
*/
30
30
class FalseValueFlowsToTokenValidationParametersPropertyWriteToBypassValidation extends TaintTracking:: Configuration {
31
31
FalseValueFlowsToTokenValidationParametersPropertyWriteToBypassValidation ( ) {
32
32
this = "FlowsToTokenValidationResultIsValidCall"
33
33
}
34
34
35
35
override predicate isSource ( DataFlow:: Node source ) {
36
- source .asExpr ( ) .( BoolLiteral ) .getValue ( ) = "false"
36
+ source .asExpr ( ) .getValue ( ) = "false" and
37
+ source .asExpr ( ) .getType ( ) instanceof BoolType
37
38
}
38
39
39
40
override predicate isSink ( DataFlow:: Node sink ) {
40
- exists ( TokenValidationParametersPropertyWrite pw , Assignment a | a . getLValue ( ) = pw |
41
+ exists ( Assignment a |
41
42
sink .asExpr ( ) = a .getRValue ( )
43
+ and a .getLValue ( ) instanceof TokenValidationParametersPropertyWrite
42
44
)
43
45
}
44
46
}
@@ -55,7 +57,7 @@ predicate isAssemblyOlderVersion(string assemblyName, string ver) {
55
57
}
56
58
57
59
/**
58
- * Method `ValidateToken` for `Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler` or other Token handler that shares the same behavior characteristics
60
+ * A method `ValidateToken` for `Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler` or other Token handler that shares the same behavior characteristics
59
61
*/
60
62
class JsonWebTokenHandlerValidateTokenMethod extends Method {
61
63
JsonWebTokenHandlerValidateTokenMethod ( ) {
@@ -78,7 +80,7 @@ class JsonWebTokenHandlerValidateTokenCall extends MethodCall {
78
80
}
79
81
80
82
/**
81
- * Read access for properties `IsValid` or `Exception` for `Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler.ValidateToken`
83
+ * A read access for properties `IsValid` or `Exception` for `Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler.ValidateToken`
82
84
*/
83
85
class TokenValidationResultIsValidCall extends PropertyRead {
84
86
TokenValidationResultIsValidCall ( ) {
@@ -116,7 +118,7 @@ predicate hasAFlowToTokenValidationResultIsValidCall(JsonWebTokenHandlerValidate
116
118
}
117
119
118
120
/**
119
- * Property write for security-sensitive properties for `Microsoft.IdentityModel.Tokens.TokenValidationParameters`
121
+ * A property write for security-sensitive properties for `Microsoft.IdentityModel.Tokens.TokenValidationParameters`
120
122
*/
121
123
class TokenValidationParametersPropertyWriteToValidationDelegated extends PropertyWrite {
122
124
TokenValidationParametersPropertyWriteToValidationDelegated ( ) {
@@ -136,7 +138,7 @@ class TokenValidationParametersPropertyWriteToValidationDelegated extends Proper
136
138
/**
137
139
* Holds if the callable has a return statement and it always returns true for all such statements
138
140
*/
139
- predicate callableHasARetrunStmtAndAlwaysReturnsTrue ( Callable c ) {
141
+ predicate callableHasAReturnStmtAndAlwaysReturnsTrue ( Callable c ) {
140
142
c .getReturnType ( ) .toString ( ) = "Boolean" and
141
143
forall ( ReturnStmt rs | rs .getEnclosingCallable ( ) = c |
142
144
rs .getChildExpr ( 0 ) .( BoolLiteral ) .getBoolValue ( ) = true
@@ -153,7 +155,7 @@ predicate lambdaExprReturnsOnlyLiteralTrue(LambdaExpr le) {
153
155
154
156
class CallableAlwaysReturnsTrue extends Callable {
155
157
CallableAlwaysReturnsTrue ( ) {
156
- callableHasARetrunStmtAndAlwaysReturnsTrue ( this )
158
+ callableHasAReturnStmtAndAlwaysReturnsTrue ( this )
157
159
or
158
160
lambdaExprReturnsOnlyLiteralTrue ( this )
159
161
or
@@ -195,7 +197,7 @@ class CallableAlwaysReturnsTrueHigherPrecision extends CallableAlwaysReturnsTrue
195
197
}
196
198
197
199
/**
198
- * Property Write for the `IssuerValidator` property for `Microsoft.IdentityModel.Tokens.TokenValidationParameters`
200
+ * A property Write for the `IssuerValidator` property for `Microsoft.IdentityModel.Tokens.TokenValidationParameters`
199
201
*/
200
202
class TokenValidationParametersPropertyWriteToValidationDelegatedIssuerValidator extends PropertyWrite {
201
203
TokenValidationParametersPropertyWriteToValidationDelegatedIssuerValidator ( ) {
@@ -204,7 +206,7 @@ class TokenValidationParametersPropertyWriteToValidationDelegatedIssuerValidator
204
206
|
205
207
p .getAnAccess ( ) = this and
206
208
c .getAProperty ( ) = p and
207
- p .getName ( ) in [ "IssuerValidator" ]
209
+ p .hasName ( "IssuerValidator" )
208
210
)
209
211
}
210
212
}
@@ -214,22 +216,22 @@ class TokenValidationParametersPropertyWriteToValidationDelegatedIssuerValidator
214
216
*/
215
217
private class CallableReturnsStringAndArg0IsString extends Callable {
216
218
CallableReturnsStringAndArg0IsString ( ) {
217
- this .getReturnType ( ) . toString ( ) = "String" and
219
+ this .getReturnType ( ) instanceof StringType and
218
220
this .getParameter ( 0 ) .getType ( ) .toString ( ) = "String"
219
221
}
220
222
}
221
223
222
224
/**
223
- * A Callable that always retrun the 1st argument, both of `string` type
225
+ * A Callable that always return the 1st argument, both of `string` type
224
226
*/
225
- class CallableAlwatsReturnsParameter0 extends CallableReturnsStringAndArg0IsString {
226
- CallableAlwatsReturnsParameter0 ( ) {
227
+ class CallableAlwaysReturnsParameter0 extends CallableReturnsStringAndArg0IsString {
228
+ CallableAlwaysReturnsParameter0 ( ) {
227
229
forall ( ReturnStmt rs | rs .getEnclosingCallable ( ) = this |
228
230
rs .getChild ( 0 ) = this .getParameter ( 0 ) .getAnAccess ( )
229
231
) and
230
232
exists ( ReturnStmt rs | rs .getEnclosingCallable ( ) = this )
231
233
or
232
- exists ( LambdaExpr le , Call call , CallableAlwatsReturnsParameter0 cat | this = le |
234
+ exists ( LambdaExpr le , Call call , CallableAlwaysReturnsParameter0 cat | this = le |
233
235
call = le .getExpressionBody ( ) and
234
236
cat .getACall ( ) = call
235
237
)
@@ -239,17 +241,17 @@ class CallableAlwatsReturnsParameter0 extends CallableReturnsStringAndArg0IsStri
239
241
}
240
242
241
243
/**
242
- * A Callable that always retrun the 1st argument, both of `string` type. Higher precision
244
+ * A Callable that always return the 1st argument, both of `string` type. Higher precision
243
245
*/
244
- class CallableAlwatsReturnsParameter0MayThrowExceptions extends CallableReturnsStringAndArg0IsString {
245
- CallableAlwatsReturnsParameter0MayThrowExceptions ( ) {
246
+ class CallableAlwaysReturnsParameter0MayThrowExceptions extends CallableReturnsStringAndArg0IsString {
247
+ CallableAlwaysReturnsParameter0MayThrowExceptions ( ) {
246
248
callableOnlyThrowsArgumentNullException ( this ) and
247
249
forall ( ReturnStmt rs | rs .getEnclosingCallable ( ) = this |
248
250
rs .getChild ( 0 ) = this .getParameter ( 0 ) .getAnAccess ( )
249
251
) and
250
252
exists ( ReturnStmt rs | rs .getEnclosingCallable ( ) = this )
251
253
or
252
- exists ( LambdaExpr le , Call call , CallableAlwatsReturnsParameter0MayThrowExceptions cat |
254
+ exists ( LambdaExpr le , Call call , CallableAlwaysReturnsParameter0MayThrowExceptions cat |
253
255
this = le
254
256
|
255
257
call = le .getExpressionBody ( ) and
0 commit comments