@@ -7,10 +7,47 @@ private import semmle.javascript.security.dataflow.SqlInjectionCustomizations
7
7
private import semmle.javascript.security.dataflow.DomBasedXssCustomizations
8
8
private import semmle.javascript.security.dataflow.NosqlInjectionCustomizations
9
9
private import semmle.javascript.security.dataflow.TaintedPathCustomizations
10
- private import CoreKnowledge as CoreKnowledge
11
10
private import semmle.javascript.heuristics.SyntacticHeuristics as SyntacticHeuristics
12
11
private import semmle.javascript.filters.ClassifyFiles as ClassifyFiles
13
12
private import StandardEndpointFilters as StandardEndpointFilters
13
+ private import semmle.javascript.security.dataflow.XxeCustomizations
14
+ private import semmle.javascript.security.dataflow.RemotePropertyInjectionCustomizations
15
+ private import semmle.javascript.security.dataflow.TypeConfusionThroughParameterTamperingCustomizations
16
+ private import semmle.javascript.security.dataflow.ZipSlipCustomizations
17
+ private import semmle.javascript.security.dataflow.TaintedPathCustomizations
18
+ private import semmle.javascript.security.dataflow.CleartextLoggingCustomizations
19
+ private import semmle.javascript.security.dataflow.XpathInjectionCustomizations
20
+ private import semmle.javascript.security.dataflow.Xss:: Shared as Xss
21
+ private import semmle.javascript.security.dataflow.StackTraceExposureCustomizations
22
+ private import semmle.javascript.security.dataflow.ClientSideUrlRedirectCustomizations
23
+ private import semmle.javascript.security.dataflow.CodeInjectionCustomizations
24
+ private import semmle.javascript.security.dataflow.RequestForgeryCustomizations
25
+ private import semmle.javascript.security.dataflow.CorsMisconfigurationForCredentialsCustomizations
26
+ private import semmle.javascript.security.dataflow.ShellCommandInjectionFromEnvironmentCustomizations
27
+ private import semmle.javascript.security.dataflow.DifferentKindsComparisonBypassCustomizations
28
+ private import semmle.javascript.security.dataflow.CommandInjectionCustomizations
29
+ private import semmle.javascript.security.dataflow.PrototypePollutionCustomizations
30
+ private import semmle.javascript.security.dataflow.UnvalidatedDynamicMethodCallCustomizations
31
+ private import semmle.javascript.security.dataflow.TaintedFormatStringCustomizations
32
+ private import semmle.javascript.security.dataflow.NosqlInjectionCustomizations
33
+ private import semmle.javascript.security.dataflow.PostMessageStarCustomizations
34
+ private import semmle.javascript.security.dataflow.RegExpInjectionCustomizations
35
+ private import semmle.javascript.security.dataflow.SqlInjectionCustomizations
36
+ private import semmle.javascript.security.dataflow.InsecureRandomnessCustomizations
37
+ private import semmle.javascript.security.dataflow.XmlBombCustomizations
38
+ private import semmle.javascript.security.dataflow.InsufficientPasswordHashCustomizations
39
+ private import semmle.javascript.security.dataflow.HardcodedCredentialsCustomizations
40
+ private import semmle.javascript.security.dataflow.FileAccessToHttpCustomizations
41
+ private import semmle.javascript.security.dataflow.UnsafeDynamicMethodAccessCustomizations
42
+ private import semmle.javascript.security.dataflow.UnsafeDeserializationCustomizations
43
+ private import semmle.javascript.security.dataflow.HardcodedDataInterpretedAsCodeCustomizations
44
+ private import semmle.javascript.security.dataflow.ServerSideUrlRedirectCustomizations
45
+ private import semmle.javascript.security.dataflow.IndirectCommandInjectionCustomizations
46
+ private import semmle.javascript.security.dataflow.ConditionalBypassCustomizations
47
+ private import semmle.javascript.security.dataflow.HttpToFileAccessCustomizations
48
+ private import semmle.javascript.security.dataflow.BrokenCryptoAlgorithmCustomizations
49
+ private import semmle.javascript.security.dataflow.LoopBoundInjectionCustomizations
50
+ private import semmle.javascript.security.dataflow.CleartextStorageCustomizations
14
51
15
52
/**
16
53
* A set of characteristics that a particular endpoint might have. This set of characteristics is used to make decisions
@@ -61,6 +98,63 @@ abstract class EndpointCharacteristic extends string {
61
98
final float mediumConfidence ( ) { result = 0.6 }
62
99
}
63
100
101
+ /*
102
+ * Helper predicates.
103
+ */
104
+
105
+ /**
106
+ * Holds if the node `n` is a known sink for the external API security query.
107
+ *
108
+ * This corresponds to known sinks from security queries whose sources include remote flow and
109
+ * DOM-based sources.
110
+ */
111
+ private predicate isKnownExternalApiQuerySink ( DataFlow:: Node n ) {
112
+ n instanceof Xxe:: Sink or
113
+ n instanceof TaintedPath:: Sink or
114
+ n instanceof XpathInjection:: Sink or
115
+ n instanceof Xss:: Sink or
116
+ n instanceof ClientSideUrlRedirect:: Sink or
117
+ n instanceof CodeInjection:: Sink or
118
+ n instanceof RequestForgery:: Sink or
119
+ n instanceof CorsMisconfigurationForCredentials:: Sink or
120
+ n instanceof CommandInjection:: Sink or
121
+ n instanceof PrototypePollution:: Sink or
122
+ n instanceof UnvalidatedDynamicMethodCall:: Sink or
123
+ n instanceof TaintedFormatString:: Sink or
124
+ n instanceof NosqlInjection:: Sink or
125
+ n instanceof PostMessageStar:: Sink or
126
+ n instanceof RegExpInjection:: Sink or
127
+ n instanceof SqlInjection:: Sink or
128
+ n instanceof XmlBomb:: Sink or
129
+ n instanceof ZipSlip:: Sink or
130
+ n instanceof UnsafeDeserialization:: Sink or
131
+ n instanceof ServerSideUrlRedirect:: Sink or
132
+ n instanceof CleartextStorage:: Sink or
133
+ n instanceof HttpToFileAccess:: Sink
134
+ }
135
+
136
+ /**
137
+ * Holds if the node `n` is a known sink in a modeled library.
138
+ */
139
+ private predicate isKnownLibrarySink ( DataFlow:: Node n ) {
140
+ isKnownExternalApiQuerySink ( n ) or
141
+ n instanceof CleartextLogging:: Sink or
142
+ n instanceof StackTraceExposure:: Sink or
143
+ n instanceof ShellCommandInjectionFromEnvironment:: Sink or
144
+ n instanceof InsecureRandomness:: Sink or
145
+ n instanceof FileAccessToHttp:: Sink or
146
+ n instanceof IndirectCommandInjection:: Sink
147
+ }
148
+
149
+ /**
150
+ * Holds if the node `n` is known as the predecessor in a modeled flow step.
151
+ */
152
+ private predicate isKnownStepSrc ( DataFlow:: Node n ) {
153
+ TaintTracking:: sharedTaintStep ( n , _) or
154
+ DataFlow:: SharedFlowStep:: step ( n , _) or
155
+ DataFlow:: SharedFlowStep:: step ( n , _, _, _)
156
+ }
157
+
64
158
/*
65
159
* Characteristics that are indicative of a sink.
66
160
* NOTE: Initially each sink type has only one characteristic, which is that it's a sink of this type in the standard
@@ -511,9 +605,9 @@ class IsArgumentToModeledFunctionCharacteristic extends StandardEndpointFilterCh
511
605
invk .getAnArgument ( ) = n and
512
606
invk .getAnArgument ( ) = known and
513
607
(
514
- CoreKnowledge :: isKnownLibrarySink ( known )
608
+ isKnownLibrarySink ( known )
515
609
or
516
- CoreKnowledge :: isKnownStepSrc ( known )
610
+ isKnownStepSrc ( known )
517
611
or
518
612
exists ( OtherModeledArgumentCharacteristic characteristic |
519
613
characteristic .getEndpoints ( known )
@@ -616,10 +710,19 @@ private class DatabaseAccessCallHeuristicCharacteristic extends NosqlInjectionSi
616
710
private class ModeledSinkCharacteristic extends NosqlInjectionSinkEndpointFilterCharacteristic {
617
711
ModeledSinkCharacteristic ( ) { this = "modeled sink" }
618
712
713
+ /**
714
+ * Holds if the node `n` is a known sink in a modeled library, or a sibling-argument of such a sink.
715
+ */
716
+ predicate isArgumentToKnownLibrarySinkFunction ( DataFlow:: Node n ) {
717
+ exists ( DataFlow:: InvokeNode invk , DataFlow:: Node known |
718
+ invk .getAnArgument ( ) = n and invk .getAnArgument ( ) = known and isKnownLibrarySink ( known )
719
+ )
720
+ }
721
+
619
722
override predicate getEndpoints ( DataFlow:: Node n ) {
620
723
exists ( DataFlow:: CallNode call | n = call .getAnArgument ( ) |
621
724
// Remove modeled sinks
622
- CoreKnowledge :: isArgumentToKnownLibrarySinkFunction ( n )
725
+ isArgumentToKnownLibrarySinkFunction ( n )
623
726
)
624
727
}
625
728
}
@@ -630,7 +733,7 @@ private class PredecessorInModeledFlowStepCharacteristic extends NosqlInjectionS
630
733
override predicate getEndpoints ( DataFlow:: Node n ) {
631
734
exists ( DataFlow:: CallNode call | n = call .getAnArgument ( ) |
632
735
// Remove common kinds of unlikely sinks
633
- CoreKnowledge :: isKnownStepSrc ( n )
736
+ isKnownStepSrc ( n )
634
737
)
635
738
}
636
739
}
0 commit comments