Restrict notification subscriptions and harden the webhook sender - #987
Merged
Conversation
GaryJones
force-pushed
the
vipplug-20-notifications-hardening
branch
from
June 8, 2026 15:15
04924c3 to
626c367
Compare
Fixes VIPPLUG-20.
GaryJones
force-pushed
the
vipplug-20-notifications-hardening
branch
from
June 8, 2026 15:21
626c367 to
16daf4f
Compare
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
Two pieces of defence-in-depth in the notifications module.
The subscription picker only ever offers users who can
publish_posts, but both save paths — the AJAX handler and the post-save form handler — stored whatever user IDs arrived in the request. An authorised editor could therefore add arbitrary users (a plain subscriber, say) as followers of a post. Both paths now intersect the submitted IDs with that samepublish_postscandidate set before saving, so only users the picker would offer can be subscribed. The users auto-subscribed by the plugin (the current user and the post author) go through a separate path and are unaffected.Separately,
send_to_webhook()sent the payload withwp_remote_post()and, on failure, calledprint_ajax_response()which ends inwp_die(). That notification fires on post transitions and editorial-comment insertion, which are not always AJAX requests, so a failing webhook could abort an otherwise valid save. It now useswp_safe_remote_post()— which validates the URL and rejects private, loopback and link-local hosts (SSRF) — and on failure fires anef_notification_webhook_failedaction for logging and returns rather than dying.Fixes VIPPLUG-20.
Test plan
composer test:integration -- --filter NotificationsTest— a user the picker would not offer is not subscribed; a failed webhook returns without aborting.Notifications*classes).php -lclean.