Important security vulnerability discovered
December 23 2021 by Stian Thorgersen
A flaw (CVE-2021-4133) was found in Keycloak version from 12.0.0 and before 15.1.1 which allows an attacker with any existing user account to create new default user accounts via the administrative REST API even when new user registration is disabled.
In most situations the newly created user is the equivalent of a self-registered user, and does not have the ability to receive any additional roles or groups. However, there are some vectors that are harder to reproduce, but may result in additional privileges.
We highly recommend everyone upgrade to Keycloak 15.1.1 or 16.1.0 as soon as possible. Keycloak 16.0.0 also includes the fix, but if you are not already running this version we recommend going straight to 16.1.0.
If you are unable to upgrade we recommend mitigate the issue by blocking access to the user creation REST endpoint in the interim.
This can be achieved with the following CLI commands:
expression="(regex('^/auth/admin/realms/(.*)/users$') and method(POST))-> response-code(400)" \
This will block both valid and invalid attempts at creating new users, including requests from the Keycloak admin console.
Alternatively, the path
/auth/admin/realms/.*/users and method
/auth/admin completely, can be blocked with a firewall.