Skip to content

Validate stamp meta belongs to queried post#3093

Open
pfefferle wants to merge 3 commits intotrunkfrom
fix/stamp-meta-ownership-check
Open

Validate stamp meta belongs to queried post#3093
pfefferle wants to merge 3 commits intotrunkfrom
fix/stamp-meta-ownership-check

Conversation

@pfefferle
Copy link
Member

Summary

  • Adds an ownership check in Query::maybe_get_stamp() to ensure the post meta referenced by the stamp query parameter actually belongs to the queried post.
  • Without this check, any valid meta ID could be used regardless of which post was being requested.

Test plan

  • Request a post with ?activitypub&stamp=<valid_meta_id_for_this_post> — should work as before.
  • Request a post with ?activitypub&stamp=<meta_id_belonging_to_different_post> — should now return the normal post response instead of exposing unrelated meta.

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.
Copilot AI review requested due to automatic review settings March 25, 2026 10:28
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 a Quote_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;
}
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants