@@ -2,7 +2,7 @@ import csharp
22import DataFlow
33
44/**
5- * Abstract PropertyWrite for `TokenValidationParameters`.
5+ * An abstract PropertyWrite for `TokenValidationParameters`.
66 * Not really necessary anymore, but keeping it in case we want to extend the queries to check on other properties.
77 */
88abstract class TokenValidationParametersPropertyWrite extends PropertyWrite { }
@@ -18,27 +18,29 @@ class TokenValidationParametersPropertyWriteToBypassSensitiveValidation extends
1818 p .getAnAccess ( ) = this and
1919 c .getAProperty ( ) = p and
2020 p .getName ( ) in [
21- "ValidateIssuer" , "ValidateAudience" , "ValidateLifetime" , "RequireExpirationTime"
21+ "ValidateIssuer" , "ValidateAudience" , "ValidateLifetime" , "RequireExpirationTime" , "RequireAudience"
2222 ]
2323 )
2424 }
2525}
2626
2727/**
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`.
2929 */
3030class FalseValueFlowsToTokenValidationParametersPropertyWriteToBypassValidation extends TaintTracking:: Configuration {
3131 FalseValueFlowsToTokenValidationParametersPropertyWriteToBypassValidation ( ) {
3232 this = "FlowsToTokenValidationResultIsValidCall"
3333 }
3434
3535 override predicate isSource ( DataFlow:: Node source ) {
36- source .asExpr ( ) .( BoolLiteral ) .getValue ( ) = "false"
36+ source .asExpr ( ) .getValue ( ) = "false" and
37+ source .asExpr ( ) .getType ( ) instanceof BoolType
3738 }
3839
3940 override predicate isSink ( DataFlow:: Node sink ) {
40- exists ( TokenValidationParametersPropertyWrite pw , Assignment a | a . getLValue ( ) = pw |
41+ exists ( Assignment a |
4142 sink .asExpr ( ) = a .getRValue ( )
43+ and a .getLValue ( ) instanceof TokenValidationParametersPropertyWrite
4244 )
4345 }
4446}
@@ -55,7 +57,7 @@ predicate isAssemblyOlderVersion(string assemblyName, string ver) {
5557}
5658
5759/**
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
5961 */
6062class JsonWebTokenHandlerValidateTokenMethod extends Method {
6163 JsonWebTokenHandlerValidateTokenMethod ( ) {
@@ -78,7 +80,7 @@ class JsonWebTokenHandlerValidateTokenCall extends MethodCall {
7880}
7981
8082/**
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`
8284 */
8385class TokenValidationResultIsValidCall extends PropertyRead {
8486 TokenValidationResultIsValidCall ( ) {
@@ -116,7 +118,7 @@ predicate hasAFlowToTokenValidationResultIsValidCall(JsonWebTokenHandlerValidate
116118}
117119
118120/**
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`
120122 */
121123class TokenValidationParametersPropertyWriteToValidationDelegated extends PropertyWrite {
122124 TokenValidationParametersPropertyWriteToValidationDelegated ( ) {
@@ -136,7 +138,7 @@ class TokenValidationParametersPropertyWriteToValidationDelegated extends Proper
136138/**
137139 * Holds if the callable has a return statement and it always returns true for all such statements
138140 */
139- predicate callableHasARetrunStmtAndAlwaysReturnsTrue ( Callable c ) {
141+ predicate callableHasAReturnStmtAndAlwaysReturnsTrue ( Callable c ) {
140142 c .getReturnType ( ) .toString ( ) = "Boolean" and
141143 forall ( ReturnStmt rs | rs .getEnclosingCallable ( ) = c |
142144 rs .getChildExpr ( 0 ) .( BoolLiteral ) .getBoolValue ( ) = true
@@ -153,7 +155,7 @@ predicate lambdaExprReturnsOnlyLiteralTrue(LambdaExpr le) {
153155
154156class CallableAlwaysReturnsTrue extends Callable {
155157 CallableAlwaysReturnsTrue ( ) {
156- callableHasARetrunStmtAndAlwaysReturnsTrue ( this )
158+ callableHasAReturnStmtAndAlwaysReturnsTrue ( this )
157159 or
158160 lambdaExprReturnsOnlyLiteralTrue ( this )
159161 or
@@ -195,7 +197,7 @@ class CallableAlwaysReturnsTrueHigherPrecision extends CallableAlwaysReturnsTrue
195197}
196198
197199/**
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`
199201 */
200202class TokenValidationParametersPropertyWriteToValidationDelegatedIssuerValidator extends PropertyWrite {
201203 TokenValidationParametersPropertyWriteToValidationDelegatedIssuerValidator ( ) {
@@ -204,7 +206,7 @@ class TokenValidationParametersPropertyWriteToValidationDelegatedIssuerValidator
204206 |
205207 p .getAnAccess ( ) = this and
206208 c .getAProperty ( ) = p and
207- p .getName ( ) in [ "IssuerValidator" ]
209+ p .hasName ( "IssuerValidator" )
208210 )
209211 }
210212}
@@ -214,22 +216,22 @@ class TokenValidationParametersPropertyWriteToValidationDelegatedIssuerValidator
214216 */
215217private class CallableReturnsStringAndArg0IsString extends Callable {
216218 CallableReturnsStringAndArg0IsString ( ) {
217- this .getReturnType ( ) . toString ( ) = "String" and
219+ this .getReturnType ( ) instanceof StringType and
218220 this .getParameter ( 0 ) .getType ( ) .toString ( ) = "String"
219221 }
220222}
221223
222224/**
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
224226 */
225- class CallableAlwatsReturnsParameter0 extends CallableReturnsStringAndArg0IsString {
226- CallableAlwatsReturnsParameter0 ( ) {
227+ class CallableAlwaysReturnsParameter0 extends CallableReturnsStringAndArg0IsString {
228+ CallableAlwaysReturnsParameter0 ( ) {
227229 forall ( ReturnStmt rs | rs .getEnclosingCallable ( ) = this |
228230 rs .getChild ( 0 ) = this .getParameter ( 0 ) .getAnAccess ( )
229231 ) and
230232 exists ( ReturnStmt rs | rs .getEnclosingCallable ( ) = this )
231233 or
232- exists ( LambdaExpr le , Call call , CallableAlwatsReturnsParameter0 cat | this = le |
234+ exists ( LambdaExpr le , Call call , CallableAlwaysReturnsParameter0 cat | this = le |
233235 call = le .getExpressionBody ( ) and
234236 cat .getACall ( ) = call
235237 )
@@ -239,17 +241,17 @@ class CallableAlwatsReturnsParameter0 extends CallableReturnsStringAndArg0IsStri
239241}
240242
241243/**
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
243245 */
244- class CallableAlwatsReturnsParameter0MayThrowExceptions extends CallableReturnsStringAndArg0IsString {
245- CallableAlwatsReturnsParameter0MayThrowExceptions ( ) {
246+ class CallableAlwaysReturnsParameter0MayThrowExceptions extends CallableReturnsStringAndArg0IsString {
247+ CallableAlwaysReturnsParameter0MayThrowExceptions ( ) {
246248 callableOnlyThrowsArgumentNullException ( this ) and
247249 forall ( ReturnStmt rs | rs .getEnclosingCallable ( ) = this |
248250 rs .getChild ( 0 ) = this .getParameter ( 0 ) .getAnAccess ( )
249251 ) and
250252 exists ( ReturnStmt rs | rs .getEnclosingCallable ( ) = this )
251253 or
252- exists ( LambdaExpr le , Call call , CallableAlwatsReturnsParameter0MayThrowExceptions cat |
254+ exists ( LambdaExpr le , Call call , CallableAlwaysReturnsParameter0MayThrowExceptions cat |
253255 this = le
254256 |
255257 call = le .getExpressionBody ( ) and
0 commit comments