Summary
An improper access control flaw in Keycloak's partial import endpoint allows a limited administrator to bypass Fine-Grained Admin Permissions (FGAP).
By importing users with realm-admin role mappings, a constrained admin can escalate to full realm administrator privileges and gain broader control over the realm.
Affected context
This vulnerability arises in Keycloak deployments that use Fine-Grained Admin Permissions (FGAP) to restrict what realm administrators can do, while still allowing them access to the /admin/realms/{realm}/partialImport endpoint.
It is relevant when administrators with limited privileges are expected to manage users or configuration imports without having full realm-admin rights.
In such setups, the partial import functionality becomes a bypass path because its authorization checks do not correctly enforce FGAP rules for imported role mappings.
Exploit preconditions
- Attack surface: Keycloak admin REST API, specifically
POST /admin/realms/{realm}/partialImport. - Required access: An authenticated administrator account with limited or constrained privileges under FGAP (not already a full realm admin).
- Trigger point: Submitting a crafted partial import payload that defines or modifies users with realm-admin role mappings.
- Why exploitation is possible: The endpoint's access control does not fully honor FGAP constraints when processing imported user role assignments, allowing a limited admin to assign higher-privileged roles than their own.
Why this happens
The core issue is an authorization gap where access control logic for the partial import operation does not correctly enforce Fine-Grained Admin Permissions.
Instead of validating whether the calling administrator is allowed to assign or import high-privilege roles (such as realm-admin), the service trusts the contents of the import payload.
This maps to CWE-863: Improper Authorization, where permission checks are incomplete or applied at the wrong granularity, enabling users with restricted roles to perform actions reserved for more privileged principals.
Potential impact
- A limited administrator may escalate to full realm administrator privileges.
- An attacker with a constrained admin account could gain control over realm configuration, clients, and user management.
- Compromised or malicious limited admins can create or modify accounts with powerful roles, weakening separation of duties.
- Security controls depending on FGAP boundaries can be undermined, increasing the risk of data exposure or configuration tampering.
General mitigation guidance
Mitigation generally focuses on strengthening authorization checks and reducing assumptions about trusted administrators:
- Ensure that all administrative endpoints, including import/export operations, enforce the same fine-grained permission model used elsewhere.
- Introduce explicit checks that prevent administrators from creating or assigning roles that exceed their own effective privilege level.
- Treat import mechanisms as sensitive, limiting which administrators can invoke them and restricting the scope of what can be imported (e.g., disallow role mappings in partial imports by constrained roles).
- Apply the principle of least privilege for admin accounts, avoiding unnecessary assignment of FGAP permissions and segmenting administrative duties where possible.
How teams detect issues like this
Effective detection strategies include:
- Reviewing admin API code paths for endpoints that modify users, roles, or mappings and confirming they all invoke consistent authorization checks.
- Using static analysis or policy-as-code tools to flag controller or resource methods that bypass centralized authorization infrastructure.
- Monitoring audit logs for partial import operations, especially cases where limited admins import or modify users with elevated roles.
- Incorporating security-focused code review checklists that call out "bulk operations" and "import/export endpoints" as high-risk for authorization bypasses.

