Skip to content

Cap remote recipient fetches per incoming activity#3094

Open
pfefferle wants to merge 8 commits intotrunkfrom
fix/cap-remote-recipient-fetches
Open

Cap remote recipient fetches per incoming activity#3094
pfefferle wants to merge 8 commits intotrunkfrom
fix/cap-remote-recipient-fetches

Conversation

@pfefferle
Copy link
Copy Markdown
Member

@pfefferle pfefferle commented Mar 25, 2026

Summary

  • Limits the number of outbound HTTP requests triggered by remote recipient URLs in to/cc/bcc fields of incoming activities.
  • Defaults to 5 remote fetches per activity, filterable via activitypub_max_remote_recipient_fetches.
  • Detects the actor's followers collection URL from cached metadata (the Remote_Actors post) instead of fetching it, so it never counts against the remote fetch cap.
  • Prevents abuse where a crafted activity with many remote recipients could trigger unlimited outbound requests from the server.

Test plan

  • Send an activity with fewer than 5 remote recipients in to/cc/bcc — all should be resolved as before.
  • Send an activity with more than 5 remote recipients — only the first 5 should trigger outbound fetches, the rest should be skipped.
  • Verify local (same-domain) recipients are unaffected by the cap.
  • Send an activity with the actor's followers collection URL in cc — followers should be resolved without an HTTP fetch, even if the cap is already reached.
  • Verify cross-domain followers URLs (e.g., WordPress.com where actor and collection domains differ) are still detected from cached metadata.

Limit the number of outbound HTTP requests triggered by remote
recipient URLs in to/cc/bcc fields to prevent abuse. Defaults to 5,
filterable via `activitypub_max_remote_recipient_fetches`.
Copilot AI review requested due to automatic review settings March 25, 2026 10:38
Copy link
Copy Markdown

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

This PR mitigates abuse of the shared inbox endpoint by limiting how many outbound HTTP fetches can be triggered from remote recipient URLs embedded in incoming ActivityPub activities.

Changes:

  • Add a per-activity cap (default: 5) on remote recipient lookups, filterable via activitypub_max_remote_recipient_fetches.
  • Skip additional remote recipient fetches once the cap is reached while continuing to process same-domain recipients.
  • Add a patch-level changelog entry documenting the fix.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
includes/rest/class-inbox-controller.php Adds the remote-recipient fetch cap (and introduces a new filter) inside get_local_recipients().
.github/changelog/fix-cap-remote-recipient-fetches Documents the change as a patch “fixed” item.

Instead of always fetching remote recipient URLs to check if they are
collections, compare them against the actor's known followers URL from
the cached Remote_Actors post. This avoids consuming a remote fetch
slot for the most common collection URL and ensures followers are
resolved even when the fetch cap is reached.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants