Validate stamp meta belongs to queried post#3093
Open
Conversation
The `stamp` query parameter accepted any post meta ID without verifying it belonged to the current post. Add an ownership check so that only meta associated with the queried post is used.
There was a problem hiding this comment.
Pull request overview
Adds a safety check when resolving stamp-based QuoteAuthorization objects so that the referenced post meta must belong to the currently queried post, preventing cross-post meta disclosure via a valid meta_id.
Changes:
- Validate
get_post_meta_by_id()result ($meta->post_id) matches the queried post ID before building aQuote_Authorization.
Comment on lines
+406
to
+409
| // Ensure the meta belongs to the queried post to prevent arbitrary meta disclosure. | ||
| if ( (int) $meta->post_id !== $post->ID ) { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
This new ownership check should be covered by a PHPUnit test: create a second post, add the stamp meta to that other post, request the first post with stamp=<meta_id_of_other_post>, and assert we fall back to the normal post object (i.e., not a QuoteAuthorization). That directly verifies the regression/security fix described in the PR.
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
Query::maybe_get_stamp()to ensure the post meta referenced by thestampquery parameter actually belongs to the queried post.Test plan
?activitypub&stamp=<valid_meta_id_for_this_post>— should work as before.?activitypub&stamp=<meta_id_belonging_to_different_post>— should now return the normal post response instead of exposing unrelated meta.