Repository navigation
Description
Describe the bug
Deleting a user in one realm can remove pending scheduled workflow steps that belong to a resource in a different realm. This happens when the deleted user has the same ID as that resource, for example a client in the other realm.
Workflow state is not stored with a realm reference. When a user is removed, the cleanup of their workflow state is matched only by resource ID, so state for a resource with the same ID in any realm is deleted too. This is the same realm-isolation gap as #50380, on a different code path: the fix for #50380 (#50381) scoped the whole-realm cleanup, but not the per-resource cleanup that runs when a user is deleted.
The impact is limited to silently dropping pending workflow steps for the affected resource. For example, a delayed "disable inactive user" step for that resource never runs. The resource itself is not deleted, no data is exposed, and no privileges are gained. To trigger it, an administrator must be able to create a user with a chosen ID in their realm (only possible through realm import or partial import, since the normal create-user endpoint always generates the ID). They must also be able to delete that user, and they must already know the exact ID of a resource in the other realm that currently has a pending workflow step.
Version
Observed on commit 0c8877ace9b20288cf2307f843969370c0b0c6a6 (main).
Expected behavior
Removing a user in one realm removes only the workflow state that belongs to that user in that realm. Workflow state for resources in other realms is unaffected, even when IDs match.
Actual behavior
Removing a user in one realm also removes the pending scheduled workflow steps of any resource in another realm that has the same ID. Those steps never run.
Anything else?
- Related: Workflow state removeAll() deletes records across all realms on realm removal #50380 (realm-unscoped workflow state cleanup on realm removal), fixed by Fix workflow state removeAll() deleting records across all realms #50381.
- Workflow state has no realm column, so a complete fix needs to add realm scoping to the stored workflow state, not only to the delete query.
This issue was originally tracked in the private repository. Migrated by @ssilvert.
Activity
Scope workflow state cleanup on user removal to the user's realm
Scope workflow state cleanup on user removal to the user's realm