Blame SOURCES/0009-Prevent-redirect-to-URLs-that-begin-with.patch

eea66f
From 42a11261b9dad2e48d70bdff7c53dd57a12db6f5 Mon Sep 17 00:00:00 2001
eea66f
From: AIMOTO Norihito <aimoto@osstech.co.jp>
eea66f
Date: Tue, 6 Jul 2021 22:57:24 +0200
eea66f
Subject: [PATCH] Prevent redirect to URLs that begin with '///'
eea66f
eea66f
Visiting a logout URL like this:
eea66f
    https://rp.example.co.jp/mellon/logout?ReturnTo=///fishing-site.example.com/logout.html
eea66f
would have redirected the user to fishing-site.example.com
eea66f
eea66f
With the patch, this URL would be rejected.
eea66f
eea66f
Fixes: CVE-2021-3639
eea66f
---
eea66f
 auth_mellon_util.c | 10 ++++++++++
eea66f
 1 file changed, 10 insertions(+)
eea66f
eea66f
diff --git a/auth_mellon_util.c b/auth_mellon_util.c
eea66f
index 2f8c9c3..6a686db 100644
eea66f
--- a/auth_mellon_util.c
eea66f
+++ b/auth_mellon_util.c
eea66f
@@ -927,6 +927,10 @@ int am_check_url(request_rec *r, const char *url)
eea66f
 {
eea66f
     const char *i;
eea66f
 
eea66f
+    if (url == NULL) {
eea66f
+        return HTTP_BAD_REQUEST;
eea66f
+    }
eea66f
+
eea66f
     for (i = url; *i; i++) {
eea66f
         if (*i >= 0 && *i < ' ') {
eea66f
             /* Deny all control-characters. */
eea66f
@@ -943,6 +947,12 @@ int am_check_url(request_rec *r, const char *url)
eea66f
         }
eea66f
     }
eea66f
 
eea66f
+    if (strstr(url, "///") == url) {
eea66f
+        AM_LOG_RERROR(APLOG_MARK, APLOG_ERR, HTTP_BAD_REQUEST, r,
eea66f
+                          "URL starts with '///'");
eea66f
+        return HTTP_BAD_REQUEST;
eea66f
+    }
eea66f
+
eea66f
     return OK;
eea66f
 }
eea66f
 
eea66f
-- 
eea66f
2.26.3
eea66f