Skip to content

Any user can rename and edit any other account through PUT /api/users/{own id} #584

Open

Description

@pacmano1

PUT /api/users/{userId} is @CheckAuthorizedUserId. When userId is the caller's own id, MirthServlet.checkUserAuthorized(userId) lets the request through whatever the authorization controller says (so users can edit their own account). UserServlet.updateUser then saves the User from the request body, and that body's id is never compared with userId. So a user allowed to edit only themselves can put another account's id in the body and overwrite that account.

Without an authorization plugin everyone is allowed everything anyway, so this shows up once a plugin like RBAC restricts users. The authorization plugin can't block it either: checkUserAuthorized(userId) only throws when the controller says no and the URL id is not the caller's own.

Measured on 4.7.0, Derby, RBAC 1.3.0, as a user whose role is Viewer (no user management):

  1. PUT /api/users/12 (another user's id in the URL), body = user 12 with a new username: 403, as expected.
  2. PUT /api/users/6 (own id in the URL), same body naming user 12: 204. User 12 now has the new username and the caller's first and last name, because the body was built from the caller's own record.

UserServlet.updateUser is the same on main (dcd48b9). Fix: in updateUser, refuse a body whose id differs from userId (400), or set the body's id to userId before saving.

Co-authored with Claude Code.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions