Skip to content

Commit 66b456d

Browse files
committed
C#: Fix a URL redirection from remote source false positive
When guarding the redirect with `HttpRequestBase.IsUrlLocalToHost()`
1 parent fefc02d commit 66b456d

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

csharp/ql/lib/semmle/code/csharp/security/dataflow/UrlRedirectQuery.qll

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,19 @@ class HttpServerTransferSink extends Sink {
116116
}
117117

118118
private predicate isLocalUrlSanitizer(Guard g, Expr e, AbstractValue v) {
119-
g.(MethodCall).getTarget().hasName("IsLocalUrl") and
120-
e = g.(MethodCall).getArgument(0) and
119+
(
120+
g.(MethodCall).getTarget().hasName("IsLocalUrl") and
121+
e = g.(MethodCall).getArgument(0)
122+
or
123+
g.(MethodCall).getTarget().hasName("IsUrlLocalToHost") and
124+
e = g.(MethodCall).getArgument(1)
125+
) and
121126
v.(AbstractValues::BooleanValue).getValue() = true
122127
}
123128

124129
/**
125-
* A URL argument to a call to `UrlHelper.isLocalUrl()` that is a sanitizer for URL redirects.
130+
* A URL argument to a call to `UrlHelper.IsLocalUrl()` or `HttpRequestBase.IsUrlLocalToHost()` that
131+
* is a sanitizer for URL redirects.
126132
*/
127133
class LocalUrlSanitizer extends Sanitizer {
128134
LocalUrlSanitizer() { this = DataFlow::BarrierGuard<isLocalUrlSanitizer/3>::getABarrierNode() }
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Fixed a URL redirection from remote source false positive when guarding a redirect with `HttpRequestBase.IsUrlLocalToHost()`

0 commit comments

Comments
 (0)