Skip to content

External OpenID Connect Account Takeover by E-Mail Change

Moderate
renchap published GHSA-vm39-j3vx-pch3 Feb 14, 2024

Package

No package listed

Affected versions

all

Patched versions

4.2.6, 4.1.14, 4.0.14, 3.5.18

Description

Summary

Dominik George and Pingu from Teckids discovered that Mastodon allows new identities from configured authentication providers (CAS, SAML, OIDC) to attach to existing local users with the same e-mail address. This results in a possible account takeover if the authentication provider allows changing the e-mail address or multiple authentication providers are configured.

Details

When a user logs in through an external authentication provider for the first time, Mastodon checks the e-mail address passed by the provider to find an existing account.

However, using the e-mail address alone means that if the authentication provider allows changing the e-mail address of an account, the Mastodon account can immediately be hijacked.

PoC

  1. Install an OIDC provider, like Keycloak
  2. Connect Mastodon to the OIDC provider
  3. Create two accounts in Keycloak, foo and bar. Assign the e-mail addresses foo@example.com and bar@example.com, respectively
  4. Login to Mastodon with foo
  5. Logout in Mastodon
  6. Swap the e-mail addresses in Keycloak
  7. Login in Mastodon again

Impact

All users logging in through external authentication providers are affected. The severity is medium, as it also requires the external authentication provider to misbehave.

However, some well-known OIDC providers (like Microsoft Azure) make it very easy to accidentally allow unverified e-mail changes. Moreover, OpenID Connect also allows dynamic client registration.

Severity

Moderate

CVE ID

CVE-2024-25618

Weaknesses

Credits