Skip to content

Commit

Permalink
rgw: sanitize \r in s3 CORSConfiguration's ExposeHeader
Browse files Browse the repository at this point in the history
follows up on 1524d3c 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)
  • Loading branch information
cbodley committed May 11, 2021
1 parent f44a8ae commit 763aebb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/rgw/rgw_cors.cc
Expand Up @@ -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");
}
}

Expand Down

0 comments on commit 763aebb

Please sign in to comment.