Harden dismiss-notice AJAX handler (nonce, capability, key allow-list) - #19
Merged
Merged
Conversation
Comment on lines
+617
to
+620
| if( ! $error && ( strpos( $option_key, 'dismiss_' ) !== 0 || substr( $option_key, -7 ) !== '_notice' ) ) { | ||
| $response['error'] = __( 'Invalid key', $this->domain ); | ||
| $error = true; | ||
| } |
There was a problem hiding this comment.
There was a problem hiding this comment.
🟢 Approval recommended
The focused changes correctly implement the stated security controls without unresolved issues.
Pull request overview
Hardens the global notice-dismissal AJAX endpoint against unauthorized or arbitrary option updates.
Changes:
- Adds nonce and
manage_optionsauthorization checks. - Restricts option keys and sanitizes stored values.
- Documents the security fix for release 1.3.5.
File summaries
| File | Description |
|---|---|
lib/classes/class-bootstrap.php |
Secures and validates notice-dismissal requests. |
changes.md |
Adds the 1.3.5 security changelog entry. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Member
Author
|
Re: Devin Review's 🟥 on the
|
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.
What
Hardens the
ud_bootstrap_dismiss_noticeAJAX handler inlib/classes/class-bootstrap.php(registered atwp_ajax_ud_bootstrap_dismiss_notice):check_ajax_referer( 'ud_bootstrap_dismiss_notice', 'nonce' )— requires a valid noncecurrent_user_can( 'manage_options' )— the dismiss writes global state; previously any authenticated user (e.g. subscriber) could invoke itsanitize_key()+ must match thedismiss_*_noticepattern — the only key shapedefine_splash_pages()reads back (lines 320/364); previously any arbitrarywp_optionskey could be writtensanitize_key/sanitize_text_field)Context
check_ajax_referer()(e.g.class-errors.phpdismiss_notices()); this one was missed. 1.3.3 fixed the related handler from CVE-2024-1385.ud-dismiss.jsuses the separateud_dismissaction), so no JS changes are needed.changes.mdgets the 1.3.5 entry so the tag can be cut right after merge.Verification (live environment)
Tested on a real WP install (wp-stateless 4.4.1 active, this lib patched in):
-1, target option untouched (previously:success:1and the option was overwritten)template) → "Invalid key", option untoucheddismiss_wp_stateless_4_4_1_noticekey →success:1, dismiss flow preserved-1)