Repository navigation
Security: Require a nonce-protected POST to delete a custom role (GO-54) - #2942
Merged
Merged
Conversation
The delete confirm step was a GET link, so any page could delete a custom role by sending an admin to ?action=delete&role=<slug>&confirm=1. The confirm view now posts a form carrying a role_delete_<slug> nonce, and the handler only deletes after verifying it; a GET or a bad nonce shows the confirm view.
ReviewHigh: none. Medium: none. I traced
I did not run the code or tests; this is from reading the diff and surrounding code. The PR looks ready to merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Deleting a custom role (Settings (D.T) → Roles) was a state-changing GET: once
confirmwas in the query string,delete_action()removed the role fromdt_custom_roleswith only adelete_rolescapability check. An admin who opened a link or loaded an image pointing atadmin.php?page=dt_options&tab=roles&action=delete&role=<slug>&confirm=1would delete that role, and every user holding it would lose its capabilities.role_delete_<slug>nonce (wp_nonce_field).delete_action()deletes only when that nonce verifies for the role in the URL. A GET (includingconfirm=1) shows the confirm view. A missing or wrong nonce, including one minted for a different role, shows "Unauthorized" plus the confirm view.Internal ref: GO-54.
Verification
php -landvendor/bin/phpcspass on the changed file.GET …&action=delete&role=custom_go54_test&confirm=1deleted the role.🤖 Generated with Claude Code