Summary
A privilege escalation flaw in Immich allows low-privilege API keys to update their own permissions using an exposed update endpoint.
When exploited, this behavior enables a non-admin API key to grant itself full administrative rights and take over management of the Immich instance.
Affected context
This vulnerability appears in Immich deployments where API keys are used to authenticate and authorize access to backend functionality.
The issue manifests specifically in the API key update endpoint, where the system does not adequately restrict which permissions an API key may assign to itself.
Environments that expose these management APIs to users or service integrations, especially over the network, are more likely to be at risk if a low-privilege key is compromised or misused.
Exploit preconditions
- Attack surface: Immich API, specifically the API key update endpoint.
- Required access: Possession of a valid but low-privilege API key.
- Trigger point: Calling the API key update endpoint to modify the permissions associated with the same API key.
- Why exploitation is possible: The authorization logic fails to distinguish between actions performed by privileged administrators and actions performed by low-privilege keys, allowing self-servicing of higher privileges without an independent privilege check.
Why this happens
The root cause is insufficient privilege enforcement when updating API key permissions, mapping to CWE-269: Improper Privilege Management.
Instead of enforcing a strict policy that only appropriately privileged identities (e.g., admins) may modify or grant high-level permissions, the system allows an API key to modify its own privilege set.
This design breaks the expected authorization boundary by trusting the caller's current identity without verifying that it is allowed to perform elevation-related operations.
Conceptually, the bug is that permission mutation operations are not guarded by privilege checks that are stronger than the permissions being requested.
Potential impact
- A low-privilege API key can grant itself full administrative capabilities.
- Unauthorized full control over user accounts, albums, photos, and videos.
- Ability to change configuration, manage users, or alter system settings via admin-level endpoints.
- Potential exposure, modification, or deletion of all stored media and associated metadata.
- Use of the compromised instance as a foothold for broader infrastructure attacks if integrated with other systems.
General mitigation guidance
Effective mitigation focuses on enforcing strict authorization boundaries around permission-changing operations.
Recommended patterns include:
- Require that only identities already holding high-level or administrative roles can modify API key permissions, especially for elevation to admin-equivalent scopes.
- Implement server-side checks that compare the caller's current privileges against the requested changes, rejecting any operation that results in privilege elevation beyond the caller's own level.
- Separate "self-management" actions (e.g., key rotation, description updates) from "privilege management" operations and apply stricter controls to the latter.
- Apply the principle of least privilege by designing role and scope models where API keys are issued with the minimal required capabilities and cannot independently expand their scope.
- Log and review all permission changes and administrative actions to discourage misuse and support incident response.
How teams detect issues like this
Detection can focus on both code-level patterns and runtime signals:
- Static analysis and code review:
- Identify endpoints that modify roles, scopes, or permissions and verify they enforce strict authorization checks beyond simple authentication.
- Look for update or "self-service" APIs where the subject can modify attributes that directly control privilege level.
- Flag any logic that ties authorization to "who is calling" without separately validating "what privilege level is required" for the operation.
- Policy enforcement:
- Define and enforce security policies requiring explicit privilege checks for role- or permission-changing operations.
- Integrate automated checks into CI/CD pipelines to detect missing or inconsistent authorization decorators/middleware on sensitive endpoints.
- Runtime monitoring:
- Log all changes to API key permissions, including caller identity, previous scopes, and new scopes.
- Alert on suspicious patterns, such as low-privilege keys acquiring admin-level permissions or frequent permission changes from the same key or IP.

