@@ -13,6 +13,8 @@ import semmle.python.Concepts
13
13
import ServerSideRequestForgeryCustomizations:: ServerSideRequestForgery
14
14
15
15
/**
16
+ * DEPRECATED: Use `FullServerSideRequestForgeryFlow` module instead.
17
+ *
16
18
* A taint-tracking configuration for detecting "Server-side request forgery" vulnerabilities.
17
19
*
18
20
* This configuration has a sanitizer to limit results to cases where attacker has full control of URL.
@@ -21,7 +23,7 @@ import ServerSideRequestForgeryCustomizations::ServerSideRequestForgery
21
23
* You should use the `fullyControlledRequest` to only select results where all
22
24
* URL parts are fully controlled.
23
25
*/
24
- class FullServerSideRequestForgeryConfiguration extends TaintTracking:: Configuration {
26
+ deprecated class FullServerSideRequestForgeryConfiguration extends TaintTracking:: Configuration {
25
27
FullServerSideRequestForgeryConfiguration ( ) { this = "FullServerSideRequestForgery" }
26
28
27
29
override predicate isSource ( DataFlow:: Node source ) { source instanceof Source }
@@ -39,24 +41,51 @@ class FullServerSideRequestForgeryConfiguration extends TaintTracking::Configura
39
41
}
40
42
}
41
43
44
+ /**
45
+ * This configuration has a sanitizer to limit results to cases where attacker has full control of URL.
46
+ * See `PartialServerSideRequestForgery` for a variant without this requirement.
47
+ *
48
+ * You should use the `fullyControlledRequest` to only select results where all
49
+ * URL parts are fully controlled.
50
+ */
51
+ private module FullServerSideRequestForgeryConfig implements DataFlow:: ConfigSig {
52
+ predicate isSource ( DataFlow:: Node source ) { source instanceof Source }
53
+
54
+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof Sink }
55
+
56
+ predicate isBarrier ( DataFlow:: Node node ) {
57
+ node instanceof Sanitizer
58
+ or
59
+ node instanceof FullUrlControlSanitizer
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Global taint-tracking for detecting "Full server-side request forgery" vulnerabilities.
65
+ *
66
+ * You should use the `fullyControlledRequest` to only select results where all
67
+ * URL parts are fully controlled.
68
+ */
69
+ module FullServerSideRequestForgeryFlow = TaintTracking:: Global< FullServerSideRequestForgeryConfig > ;
70
+
42
71
/**
43
72
* Holds if all URL parts of `request` is fully user controlled.
44
73
*/
45
74
predicate fullyControlledRequest ( Http:: Client:: Request request ) {
46
- exists ( FullServerSideRequestForgeryConfiguration fullConfig |
47
- forall ( DataFlow:: Node urlPart | urlPart = request .getAUrlPart ( ) |
48
- fullConfig .hasFlow ( _, urlPart )
49
- )
75
+ forall ( DataFlow:: Node urlPart | urlPart = request .getAUrlPart ( ) |
76
+ FullServerSideRequestForgeryFlow:: flow ( _, urlPart )
50
77
)
51
78
}
52
79
53
80
/**
81
+ * DEPRECATED: Use `FullServerSideRequestForgeryFlow` module instead.
82
+ *
54
83
* A taint-tracking configuration for detecting "Server-side request forgery" vulnerabilities.
55
84
*
56
85
* This configuration has results, even when the attacker does not have full control over the URL.
57
86
* See `FullServerSideRequestForgeryConfiguration`, and the `fullyControlledRequest` predicate.
58
87
*/
59
- class PartialServerSideRequestForgeryConfiguration extends TaintTracking:: Configuration {
88
+ deprecated class PartialServerSideRequestForgeryConfiguration extends TaintTracking:: Configuration {
60
89
PartialServerSideRequestForgeryConfiguration ( ) { this = "PartialServerSideRequestForgery" }
61
90
62
91
override predicate isSource ( DataFlow:: Node source ) { source instanceof Source }
@@ -69,3 +98,21 @@ class PartialServerSideRequestForgeryConfiguration extends TaintTracking::Config
69
98
guard instanceof SanitizerGuard
70
99
}
71
100
}
101
+
102
+ /**
103
+ * This configuration has results, even when the attacker does not have full control over the URL.
104
+ * See `FullServerSideRequestForgeryConfiguration`, and the `fullyControlledRequest` predicate.
105
+ */
106
+ private module PartialServerSideRequestForgeryConfig implements DataFlow:: ConfigSig {
107
+ predicate isSource ( DataFlow:: Node source ) { source instanceof Source }
108
+
109
+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof Sink }
110
+
111
+ predicate isBarrier ( DataFlow:: Node node ) { node instanceof Sanitizer }
112
+ }
113
+
114
+ /**
115
+ * Global taint-tracking for detecting "partial server-side request forgery" vulnerabilities.
116
+ */
117
+ module PartialServerSideRequestForgeryFlow =
118
+ TaintTracking:: Global< PartialServerSideRequestForgeryConfig > ;
0 commit comments