Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
C#: Fix a URL redirection from remote source false positive
When guarding the redirect with `HttpRequestBase.IsUrlLocalToHost()`
  • Loading branch information
rpmrmartin committed Nov 29, 2023
commit 66b456d3c642c6d23dd9665d1f339a0b63349ad1
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,19 @@ class HttpServerTransferSink extends Sink {
}

private predicate isLocalUrlSanitizer(Guard g, Expr e, AbstractValue v) {
g.(MethodCall).getTarget().hasName("IsLocalUrl") and
e = g.(MethodCall).getArgument(0) and
(
g.(MethodCall).getTarget().hasName("IsLocalUrl") and
e = g.(MethodCall).getArgument(0)
or
g.(MethodCall).getTarget().hasName("IsUrlLocalToHost") and
e = g.(MethodCall).getArgument(1)
) and
v.(AbstractValues::BooleanValue).getValue() = true
}

/**
* A URL argument to a call to `UrlHelper.isLocalUrl()` that is a sanitizer for URL redirects.
* A URL argument to a call to `UrlHelper.IsLocalUrl()` or `HttpRequestBase.IsUrlLocalToHost()` that
* is a sanitizer for URL redirects.
*/
class LocalUrlSanitizer extends Sanitizer {
LocalUrlSanitizer() { this = DataFlow::BarrierGuard<isLocalUrlSanitizer/3>::getABarrierNode() }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* Fixed a URL redirection from remote source false positive when guarding a redirect with `HttpRequestBase.IsUrlLocalToHost()`