| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -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>; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,14 +12,14 @@ | |||
| 12 | 12 | ||
| 13 | 13 | import python | |
| 14 | 14 | import semmle.python.security.dataflow.ServerSideRequestForgeryQuery | |
| 15 | - import DataFlow::PathGraph | ||
| 15 | + import FullServerSideRequestForgeryFlow::PathGraph | ||
| 16 | 16 | ||
| 17 | 17 | from | |
| 18 | - FullServerSideRequestForgeryConfiguration fullConfig, DataFlow::PathNode source, | ||
| 19 | - DataFlow::PathNode sink, Http::Client::Request request | ||
| 18 | + FullServerSideRequestForgeryFlow::PathNode source, | ||
| 19 | + FullServerSideRequestForgeryFlow::PathNode sink, Http::Client::Request request | ||
| 20 | 20 | where | |
| 21 | 21 | request = sink.getNode().(Sink).getRequest() and | |
| 22 | - fullConfig.hasFlowPath(source, sink) and | ||
| 22 | + FullServerSideRequestForgeryFlow::flowPath(source, sink) and | ||
| 23 | 23 | fullyControlledRequest(request) | |
| 24 | 24 | select request, source, sink, "The full URL of this request depends on a $@.", source.getNode(), | |
| 25 | 25 | "user-provided value" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,14 +12,14 @@ | |||
| 12 | 12 | ||
| 13 | 13 | import python | |
| 14 | 14 | import semmle.python.security.dataflow.ServerSideRequestForgeryQuery | |
| 15 | - import DataFlow::PathGraph | ||
| 15 | + import PartialServerSideRequestForgeryFlow::PathGraph | ||
| 16 | 16 | ||
| 17 | 17 | from | |
| 18 | - PartialServerSideRequestForgeryConfiguration partialConfig, DataFlow::PathNode source, | ||
| 19 | - DataFlow::PathNode sink, Http::Client::Request request | ||
| 18 | + PartialServerSideRequestForgeryFlow::PathNode source, | ||
| 19 | + PartialServerSideRequestForgeryFlow::PathNode sink, Http::Client::Request request | ||
| 20 | 20 | where | |
| 21 | 21 | request = sink.getNode().(Sink).getRequest() and | |
| 22 | - partialConfig.hasFlowPath(source, sink) and | ||
| 22 | + PartialServerSideRequestForgeryFlow::flowPath(source, sink) and | ||
| 23 | 23 | not fullyControlledRequest(request) | |
| 24 | 24 | select request, source, sink, "Part of the URL of this request depends on a $@.", source.getNode(), | |
| 25 | 25 | "user-provided value" | |
| Back | FazBrowse Home | New Git URL |
0 commit comments