Skip to content

Commit b51c6d6

Browse files
Fixes based on PR feedback
1 parent e5f5d46 commit b51c6d6

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

csharp/ql/src/experimental/Security Features/JsonWebTokenHandler/JsonWebTokenHandlerLib.qll

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ import DataFlow
66
*/
77
class TokenValidationParametersPropertySensitiveValidation extends Property {
88
TokenValidationParametersPropertySensitiveValidation() {
9-
exists(Property p, Class c |
9+
exists(Class c |
1010
c.hasQualifiedName("Microsoft.IdentityModel.Tokens.TokenValidationParameters")
1111
|
12-
p = this and
13-
c.getAProperty() = p and
14-
p.getName() in [
12+
c.getAProperty() = this and
13+
this.getName() in [
1514
"ValidateIssuer", "ValidateAudience", "ValidateLifetime", "RequireExpirationTime",
1615
"RequireAudience"
1716
]
@@ -34,8 +33,8 @@ class FalseValueFlowsToTokenValidationParametersPropertyWriteToBypassValidation
3433

3534
override predicate isSink(DataFlow::Node sink) {
3635
exists(Assignment a |
37-
sink.asExpr() = a.getRValue() and
38-
a.getLValue().(PropertyAccess).getProperty() instanceof TokenValidationParametersPropertySensitiveValidation
36+
sink.asExpr() =
37+
any(TokenValidationParametersPropertySensitiveValidation p).getAnAssignedValue()
3938
)
4039
}
4140
}
@@ -106,12 +105,11 @@ private class FlowsToTokenValidationResultIsValidCall extends DataFlow::Configur
106105
*/
107106
class TokenValidationParametersProperty extends Property {
108107
TokenValidationParametersProperty() {
109-
exists(Property p, Class c |
108+
exists(Class c |
110109
c.hasQualifiedName("Microsoft.IdentityModel.Tokens.TokenValidationParameters")
111110
|
112-
p = this and
113-
c.getAProperty() = p and
114-
p.getName() in [
111+
c.getAProperty() = this and
112+
this.getName() in [
115113
"SignatureValidator", "TokenReplayValidator", "AlgorithmValidator", "AudienceValidator",
116114
"IssuerSigningKeyValidator", "LifetimeValidator"
117115
]
@@ -153,9 +151,7 @@ class CallableAlwaysReturnsTrue extends Callable {
153151
or
154152
lambdaExprReturnsOnlyLiteralTrue(this)
155153
or
156-
exists(AnonymousFunctionExpr le, Call call, Callable callable |
157-
this = le
158-
|
154+
exists(AnonymousFunctionExpr le, Call call, Callable callable | this = le |
159155
callable.getACall() = call and
160156
call = le.getExpressionBody() and
161157
callableHasAReturnStmtAndAlwaysReturnsTrue(callable)
@@ -231,13 +227,13 @@ class CallableAlwaysReturnsParameter0 extends CallableReturnsStringAndArg0IsStri
231227
class CallableAlwaysReturnsParameter0MayThrowExceptions extends CallableReturnsStringAndArg0IsString {
232228
CallableAlwaysReturnsParameter0MayThrowExceptions() {
233229
forex(Expr ret | this.canReturn(ret) |
234-
ret = this.getParameter(0).getAnAccess()
235-
or
236-
exists(CallableAlwaysReturnsParameter0MayThrowExceptions c |
237-
ret = c.getACall() and
238-
ret.(Call).getArgument(0) = this.getParameter(0).getAnAccess()
230+
ret = this.getParameter(0).getAnAccess()
231+
or
232+
exists(CallableAlwaysReturnsParameter0MayThrowExceptions c |
233+
ret = c.getACall() and
234+
ret.(Call).getArgument(0) = this.getParameter(0).getAnAccess()
235+
)
239236
)
240-
)
241237
}
242238
}
243239

csharp/ql/src/experimental/Security Features/JsonWebTokenHandler/delegated-security-validations-always-return-true.ql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ import csharp
1515
import DataFlow
1616
import JsonWebTokenHandlerLib
1717

18-
from
19-
TokenValidationParametersProperty p , CallableAlwaysReturnsTrueHigherPrecision e
18+
from TokenValidationParametersProperty p, CallableAlwaysReturnsTrueHigherPrecision e
2019
where e = p.getAnAssignedValue()
2120
select e, "JsonWebTokenHandler security-sensitive property $@ is being delegated to $@.", p,
2221
p.getQualifiedName().toString(), e, "a callable that always returns \"true\""

0 commit comments

Comments
 (0)