Skip to content

fix: prevent tenantId escalation via /user/update - #166

Open
carfeii wants to merge 1 commit into
jishenghua:masterfrom
carfeii:fix/user-update-tenant-id-escalation
Open

carfeii wants to merge 1 commit into
jishenghua:masterfrom
carfeii:fix/user-update-tenant-id-escalation

Conversation

@carfeii

@carfeii carfeii commented Sep 15, 2026

Copy link
Copy Markdown

Fixes #165.

UserService.updateUser deserialized the caller's raw request body directly onto the User entity with no field restriction, then persisted it via updateByPrimaryKeySelective. The global tenant SQL interceptor scopes which row an UPDATE can reach (by the caller's own tenant), but not what the SET clause writes, so a caller could set tenantId to 0 on a user they own (e.g. a sub-user created via the ordinary /user/add flow). tenantId 0 is treated by the tenant interceptor as unrestricted super-admin, no filter applied, on every later request made with that account's token: full read/write/delete access to every other tenant's data on the instance. This strips tenantId from the entity before the update so it can never be set through this endpoint.

UserService.updateUser deserialized the caller's raw request body
directly onto the User entity with no field restriction, then
persisted it via updateByPrimaryKeySelective. The global tenant SQL
interceptor scopes which row an UPDATE can reach (by the caller's
own tenant), but not what the SET clause writes, so a caller could
set tenantId to 0 on a user they own (e.g. a sub-user created via
the ordinary /user/add flow). tenantId 0 is treated by the tenant
interceptor as unrestricted super-admin, no filter applied, on
every later request made with that account's token: full read/
write/delete access to every other tenant's data on the instance.
Strip tenantId from the entity before the update so it can never
be set through this endpoint.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Privilege escalation to platform super-admin via mass assignment in /user/update

1 participant