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

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