xwp / stream

🗄️ Stream plugin for WordPress
https://wordpress.org/plugins/stream/
GNU General Public License v2.0
407 stars 116 forks source link

Check authorization on 'save_new_alert' AJAX action #1391

Closed schlessera closed 1 year ago

schlessera commented 1 year ago

The logic in save_new_alert AJAX action does only check for a valid nonce, but not for authorization. This makes it possible to reuse a valid nonce and trigger the save_new_alert with an unauthorized or unauthenticated user.

This PR adds an authorization check to save_new_alert (as well as to get_new_alert_triggers_notifications, which could be used to retrieve a nonce as an authenticated but unauthorized user), and adds corresponding tests to ensure both wanted and unwanted requests behave as expected with regards to alert creation.

Props to @marcS0H for the report.

Checklist