fix: add object-level authorization to corrections REST endpoint#4643
fix: add object-level authorization to corrections REST endpoint#4643
Conversation
The corrections save endpoint only checked `edit_posts` capability, allowing any author/editor to add, modify, or delete corrections on posts they don't own. Now checks `edit_post` for the specific post. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR tightens authorization for the Corrections REST “save” endpoint to prevent IDOR/broken-access-control by ensuring the current user can edit the specific target post.
Changes:
- Add an object-level capability check (
current_user_can( 'edit_post', $post_id )) inCorrections::rest_save_corrections. - Add a unit test ensuring an author cannot save corrections for another user’s post.
- Update test fixtures to run REST-save tests as an editor by default.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
includes/corrections/class-corrections.php |
Adds per-post authorization enforcement inside the REST save handler. |
tests/unit-tests/corrections.php |
Adds an IDOR regression test and updates setup to use an editor user. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Hey @adekbadek, good job getting this PR merged! 🎉 Now, the Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label. If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label. Thank you! ❤️ |
Summary
edit_posts(generic capability), allowing any author/editor to manage corrections on posts they don't owncurrent_user_can( 'edit_post', $post_id )check for the specific target postTest plan
n test-php --group corrections-- all 21 tests pass🤖 Generated with Claude Code