Skip to content

Commit

Permalink
🐛 Do not follow redirect responses in logout calls
Browse files Browse the repository at this point in the history
Block following redirect responses from programmatically calling the
logout operation, for two reasons:

* they may be incomplete endpoints, e.g. the Redirect URI but without
  state parameter or token or anything, which would fail anyway. These
  can cause HTTP 500 errors in downstream projects (as seen in Open
  Forms).
* they can lead to SSRF issues if we don't validate the redirect target
  URL - a malicious/bad OpenID Provider could be a part of a larger
  chain of exploits
  • Loading branch information
sergei-maertens committed Jun 17, 2024
1 parent a275b08 commit de6aa48
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mozilla_django_oidc_db/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ def do_op_logout(config: OpenIDConnectConfigBase, id_token: str) -> None:
if not logout_endpoint:
return

response = requests.post(logout_endpoint, data={"id_token_hint": id_token})
response = requests.post(
logout_endpoint,
data={"id_token_hint": id_token},
allow_redirects=False,
)
if not response.ok:
logger.warning(
"Failed to log out the user at the OpenID Provider. Status code: %s",
Expand Down

0 comments on commit de6aa48

Please sign in to comment.