Skip to content

Commit

Permalink
Prevent redirect to URLs that begin with '///'
Browse files Browse the repository at this point in the history
Visiting a logout URL like this:
    https://rp.example.co.jp/mellon/logout?ReturnTo=///fishing-site.example.com/logout.html
would have redirected the user to fishing-site.example.com

With the patch, this URL would be rejected.

Fixes: CVE-2021-3639
  • Loading branch information
oss-aimoto authored and jhrozek committed Jul 29, 2021
1 parent ec27b39 commit 42a1126
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions auth_mellon_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,10 @@ int am_check_url(request_rec *r, const char *url)
{
const char *i;

if (url == NULL) {
return HTTP_BAD_REQUEST;
}

for (i = url; *i; i++) {
if (*i >= 0 && *i < ' ') {
/* Deny all control-characters. */
Expand All @@ -943,6 +947,12 @@ int am_check_url(request_rec *r, const char *url)
}
}

if (strstr(url, "///") == url) {
AM_LOG_RERROR(APLOG_MARK, APLOG_ERR, HTTP_BAD_REQUEST, r,
"URL starts with '///'");
return HTTP_BAD_REQUEST;
}

return OK;
}

Expand Down

0 comments on commit 42a1126

Please sign in to comment.