]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: sanitize \r in s3 CORSConfiguration's ExposeHeader
authorCasey Bodley <cbodley@redhat.com>
Tue, 4 May 2021 12:32:58 +0000 (08:32 -0400)
committerCasey Bodley <cbodley@redhat.com>
Tue, 11 May 2021 13:06:14 +0000 (09:06 -0400)
follows up on 1524d3c0c5cb11775313ea1e2bb36a93257947f2 to escape \r as
well

Fixes: CVE-2021-3524
Reported-by: Sergey Bobrov <Sergey.Bobrov@kaspersky.com>
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 87806f48e7a1b8891eb90711f1cedd26f1119aac)

src/rgw/rgw_cors.cc

index 0b3e4f39455616b1ae0881c988af521445202bdf..bfe83d6420ed9842a5dacdc4088641ce9b938c66 100644 (file)
@@ -148,8 +148,9 @@ void RGWCORSRule::format_exp_headers(string& s) {
     if (s.length() > 0)
       s.append(",");
     // these values are sent to clients in a 'Access-Control-Expose-Headers'
-    // response header, so we escape '\n' to avoid header injection
-    boost::replace_all_copy(std::back_inserter(s), header, "\n", "\\n");
+    // response header, so we escape '\n' and '\r' to avoid header injection
+    std::string tmp = boost::replace_all_copy(header, "\n", "\\n");
+    boost::replace_all_copy(std::back_inserter(s), tmp, "\r", "\\r");
   }
 }