Skip to content

Commit b5e7716

Browse files
committed
remove flow states, remove string as sources
1 parent 46ddddc commit b5e7716

File tree

1 file changed

+11
-44
lines changed

1 file changed

+11
-44
lines changed

java/ql/src/experimental/Security/CWE/CWE-347/Auth0NoVerifier.ql

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -57,73 +57,40 @@ module JwtAuth0 {
5757
}
5858
}
5959

60-
module JwtDecodeConfig implements DataFlow::StateConfigSig {
61-
class FlowState = DataFlow::FlowState;
62-
63-
predicate isSource(DataFlow::Node source, FlowState state) {
64-
(
65-
exists(Variable v |
66-
source.asExpr() = v.getInitializer() and
67-
v.getType().hasName("String")
68-
)
69-
or
70-
source instanceof RemoteFlowSource
71-
) and
72-
not FlowToJwtVerify::flow(source, _) and
73-
state = "Auth0" and
74-
not state = "Auth0Verify"
60+
module JwtDecodeConfig implements DataFlow::ConfigSig {
61+
predicate isSource(DataFlow::Node source) {
62+
source instanceof RemoteFlowSource and
63+
not FlowToJwtVerify::flow(source, _)
7564
}
7665

77-
predicate isSink(DataFlow::Node sink, FlowState state) {
78-
sink.asExpr() = any(JwtAuth0::GetPayload a) and
79-
state = "Auth0" and
80-
not state = "Auth0Verify"
81-
}
66+
predicate isSink(DataFlow::Node sink) { sink.asExpr() = any(JwtAuth0::GetPayload a) }
8267

83-
predicate isAdditionalFlowStep(
84-
DataFlow::Node nodeFrom, FlowState stateFrom, DataFlow::Node nodeTo, FlowState stateTo
85-
) {
68+
predicate isAdditionalFlowStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) {
8669
// Decode Should be one of the middle nodes
8770
exists(JwtAuth0::Decode a |
8871
nodeFrom.asExpr() = a.getArgument(0) and
89-
nodeTo.asExpr() = a and
90-
stateTo = "Auth0" and
91-
stateFrom = "Auth0"
72+
nodeTo.asExpr() = a
9273
)
9374
or
9475
exists(JwtAuth0::Verify a |
9576
nodeFrom.asExpr() = a.getArgument(0) and
96-
nodeTo.asExpr() = a and
97-
stateTo = "Auth0Verify" and
98-
stateFrom = "Auth0Verify"
77+
nodeTo.asExpr() = a
9978
)
10079
or
10180
exists(JwtAuth0::GetPayload a |
10281
nodeFrom.asExpr() = a.getQualifier() and
103-
nodeTo.asExpr() = a and
104-
stateTo = "Auth0" and
105-
stateFrom = "Auth0"
82+
nodeTo.asExpr() = a
10683
)
10784
}
108-
109-
predicate isBarrier(DataFlow::Node sanitizer, FlowState state) { none() }
11085
}
11186

11287
module FlowToJwtVerifyConfig implements DataFlow::ConfigSig {
113-
predicate isSource(DataFlow::Node source) {
114-
// source instanceof DataFlow::Node
115-
exists(Variable v |
116-
source.asExpr() = v.getInitializer() and
117-
v.getType().hasName("String")
118-
)
119-
}
88+
predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
12089

12190
predicate isSink(DataFlow::Node sink) { sink.asExpr() = any(JwtAuth0::Verify a).getArgument(0) }
122-
123-
predicate isAdditionalFlowStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) { none() }
12491
}
12592

126-
module JwtDecode = TaintTracking::GlobalWithState<JwtDecodeConfig>;
93+
module JwtDecode = TaintTracking::Global<JwtDecodeConfig>;
12794

12895
module FlowToJwtVerify = TaintTracking::Global<FlowToJwtVerifyConfig>;
12996

0 commit comments

Comments
 (0)