Skip to content

Secure way to allow Edit/Create/Delete for admin role users only without privilege escalation vulnerabilites. #5103

Answered by ganigeorgiev
flachdaniel asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, the above users Update rule is OK if you want to prevent "user->admin" updates but note that it will also prevent admins to edit their account (unless they downgrade to "user" or skip the role submission).

An alternative Update API rule could be:

// is the currently authenticated user
id = @request.auth.id &&
(
    // role is not submitted with the request, aka. no changes
    @request.data.role:isset = false ||
    // the submitted role is the same as the current record one, aka. again no changes
    @request.data.role = role
)

This will be simplified in the future as several users complained that the above is not always clear (eg. #4688) and I have it in my todo to think a little m…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@flachdaniel
Comment options

Answer selected by flachdaniel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants