Security: add a CSRF nonce to the setup/installer AJAX action#1374
Security: add a CSRF nonce to the setup/installer AJAX action#1374vuckro wants to merge 2 commits into
Conversation
wu_setup_install ran privileged installers (plugin install/activation, network creation, wp-config writes) gated only by a capability check, with no nonce. A logged-in admin could be tricked by a cross-site request into executing installer steps. Add a 'wu_setup_install' nonce: created in the shared wu_setup_settings localization, sent by the installer AJAX call (source and minified JS), and verified in both setup_install() handlers (network setup wizard and the pre-multisite installer), mirroring the existing ajax_network_activate nonce flow. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR adds CSRF nonce protection to the setup wizard AJAX endpoints and hardens the CI workflow with defensive path checks. The nonce is generated server-side, localized to the client, included in installer requests, and validated on both setup endpoints before processing continues. ChangesSetup Wizard CSRF Nonce Protection
CI Workflow Defensive Checks
Sequence DiagramsequenceDiagram
participant Wizard as Wizard Page
participant Client as Setup Wizard JS
participant Server as Setup Install Handler
Wizard->>Wizard: wp_create_nonce('wu_setup_install')
Wizard->>Client: localize install_nonce
Client->>Server: AJAX POST with _wpnonce
Server->>Server: check_ajax_referer()
alt Nonce Valid
Server->>Server: process installer step
else Nonce Invalid
Server->>Client: JSON error (bad-nonce)
end
🎯 2 (Simple) | ⏱️ ~8 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Permission check failed for this PR (HTTP 200 from collaborator permission API). Unable to determine if @vuckro is a maintainer or external contributor. A maintainer must review and merge this PR manually. This is a fail-closed safety measure — the pulse will not auto-merge until the permission API succeeds. aidevops.sh v3.20.46 automated scan. |
Summary
wu_setup_installruns privileged installers (plugin install/activation, networkcreation, wp-config writes) gated only by a capability check, with no nonce.
A logged-in admin could be induced by a cross-site request to execute installer
steps (CSRF).
Changes
Introduce a
wu_setup_installnonce, following the existingajax_network_activatepattern:wu_setup_settingslocalization,setup-wizard.jsand its builtsetup-wizard.min.js),setup_install()handlers (network setup wizard and thepre-multisite installer).
Compatibility
The wizard JS now sends the nonce, so the normal setup flow is unaffected. Both
handlers verify the same action.
Part of a small series of focused security hardening PRs. Full technical detail
is available privately to the maintainers on request (coordinated disclosure).
Summary by CodeRabbit
Bug Fixes
Chores