Blame SOURCES/0002-Fix-redirect-URL-validation-bypass.patch

8b0a0c
From 62041428a32de402e0be6ba45fe12df6a83bedb8 Mon Sep 17 00:00:00 2001
8b0a0c
From: Olav Morken <olav.morken@uninett.no>
8b0a0c
Date: Tue, 19 Mar 2019 13:42:22 +0100
8b0a0c
Subject: [PATCH] Fix redirect URL validation bypass
8b0a0c
8b0a0c
It turns out that browsers silently convert backslash characters into
8b0a0c
forward slashes, while apr_uri_parse() does not.
8b0a0c
8b0a0c
This mismatch allows an attacker to bypass the redirect URL validation
8b0a0c
by using an URL like:
8b0a0c
8b0a0c
  https://sp.example.org/mellon/logout?ReturnTo=https:%5c%5cmalicious.example.org/
8b0a0c
8b0a0c
mod_auth_mellon will assume that it is a relative URL and allow the
8b0a0c
request to pass through, while the browsers will use it as an absolute
8b0a0c
url and redirect to https://malicious.example.org/ .
8b0a0c
8b0a0c
This patch fixes this issue by rejecting all redirect URLs with
8b0a0c
backslashes.
8b0a0c
---
8b0a0c
 auth_mellon_util.c | 7 +++++++
8b0a0c
 1 file changed, 7 insertions(+)
8b0a0c
8b0a0c
diff --git a/auth_mellon_util.c b/auth_mellon_util.c
8b0a0c
index 0fab309..fd442f9 100644
8b0a0c
--- a/auth_mellon_util.c
8b0a0c
+++ b/auth_mellon_util.c
8b0a0c
@@ -927,6 +927,13 @@ int am_check_url(request_rec *r, const char *url)
8b0a0c
                           "Control character detected in URL.");
8b0a0c
             return HTTP_BAD_REQUEST;
8b0a0c
         }
8b0a0c
+        if (*i == '\\') {
8b0a0c
+            /* Reject backslash character, as it can be used to bypass
8b0a0c
+             * redirect URL validation. */
8b0a0c
+            AM_LOG_RERROR(APLOG_MARK, APLOG_ERR, HTTP_BAD_REQUEST, r,
8b0a0c
+                          "Backslash character detected in URL.");
8b0a0c
+            return HTTP_BAD_REQUEST;
8b0a0c
+        }
8b0a0c
     }
8b0a0c
 
8b0a0c
     return OK;
8b0a0c
-- 
8b0a0c
2.19.2
8b0a0c