Skip to content

dknauss/Sudo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

853 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

WP Sudo

WP Sudo

Require password confirmation before high-risk changes go through on your WordPress site β€” even from an already-authenticated admin session. WP Sudo also lets site owners define the shape of their administrative attack surface across admin UI, AJAX, REST, WP-CLI, Cron, XML-RPC, Application Passwords, and WPGraphQL. Built-in activity visibility, audit hooks, and governance controls help administrators see who is attempting sensitive actions and decide which users can manage Sudo policy.

License: GPL v2+ Security Policy Docs AI Authorship WordPress: 6.2+ PHP: 8.0+ PHPUnit Psalm Playwright Tests CodeQL Codecov Type Coverage Try latest release in Playground Try main in Playground

Playground demo credentials are admin / password. When WP Sudo asks for reauthentication, enter the same password: password.

Screenshots

WP Sudo challenge page asking the current user to confirm their identity with a password. Settings tab with policy presets, session settings, and the active sudo timer in the admin bar.
Challenge page Settings tab
Gated Actions tab showing protected operations and the surfaces where each rule applies. Rule Tester tab evaluating a representative admin request without executing it.
Gated Actions tab Rule Tester tab
Access tab for managing dedicated WP Sudo governance capabilities. Dashboard widget with active sudo sessions, policy summary, and recent privilege-action events.
Access tab Dashboard widget
Break-glass recovery mode notice on the Sudo settings screen.
Break-glass recovery notice

Features

  • Confirmation before destructive actions β€” plugin installs/deletions, user management, settings changes, core updates, and more all require a fresh password before proceeding
  • Two-factor support β€” integrates with the Two Factor plugin so the challenge includes your second factor when active
  • Short sudo window β€” one confirmation covers 1–15 minutes of related work (your choice) so admins can work without interruption following one reauthentication challenge before being challenged again
  • Per-surface policies β€” configure WP-CLI, Cron, XML-RPC, REST App Passwords, and WPGraphQL independently as Disabled, Limited, or Unrestricted
  • Governance controls β€” manage which users and roles can administer WP Sudo settings via a dedicated Access tab
  • Activity visibility β€” audit hooks fire on every gated event; works with WP Activity Log, Stream, and similar plugins
  • Multisite support β€” network-aware; super admins governed separately from per-site admins

Quick start

  1. Install and activate WP Sudo.
  2. Go to Settings β†’ Sudo.
  3. Choose a session duration.
  4. Review the default policies for non-interactive surfaces.
  5. Optionally install the bundled mu-plugin loader from the settings page for earlier hook registration.
  6. Test a covered action such as plugin activation or a protected settings change.

Recommended companion plugins

  • Two Factor β€” strongly recommended for password + second-factor challenge flows.
  • WP Activity Log or Stream β€” recommended if you want audit visibility from WP Sudo's action hooks.

What gets protected

WP Sudo gates built-in operations across categories including:

  • plugin and theme installation, activation, and deletion
  • user creation, deletion, and role changes
  • file editor access
  • critical option changes
  • WordPress core updates
  • export flows
  • WP Sudo settings themselves
  • selected Multisite network actions
  • connector credential writes via the REST settings endpoint

For the full rule list and surface counts, see docs/current-metrics.md.

Why it helps

WordPress has roles, capabilities, and authentication, but no native way to say "a logged-in session alone isn't enough for this action." WP Sudo adds that missing checkpoint for the parts of WordPress where a mistake, hijacked session, stale browser, or over-broad automation token can do the most damage.

That helps site owners, agencies, network operators, and teams with multiple administrators reduce the blast radius of privileged accounts. It is especially useful on sites where people, scripts, application passwords, WP-CLI jobs, Cron tasks, XML-RPC clients, WPGraphQL clients, or AI/agentic tooling can all reach administrative surfaces.

WP Sudo also makes privilege use more visible. The dashboard widget shows active sudo sessions, policy posture, and recent privileged activity; audit hooks and bundled bridges let logging plugins such as WP Activity Log and Stream record sudo sessions, gated requests, policy changes, and governance events.

The result is not just another password prompt. It is a way to define the shape and size of your site's administrative attack surface: close a surface entirely, limit it to non-destructive operations, require sudo for covered actions, or leave it unrestricted when that is the deliberate operational choice.

Active sudo is per browser session, not site-wide. WP Sudo works alongside your existing roles and capabilities β€” it does not replace them.

How it works

More technically, WP Sudo is a Multisite-compatible, zero-trust-aligned security-hardening plugin for WordPress. It adds action-gated reauthentication, enables attack surface definition (open, closed, or sudo-gated), gives visibility to privileged action requests, and confines Sudo administration to explicitly designated users.

Browser (wp-admin): gated actions redirect to a challenge screen. After successful reauthentication, the original request replays automatically.

AJAX and REST: blocked requests receive a sudo_required error until reauthentication occurs.

Non-interactive surfaces (WP-CLI, Cron, XML-RPC, REST App Passwords, WPGraphQL): each can be set independently to Disabled, Limited, or Unrestricted under Settings β†’ Sudo.

Before a covered high-risk action continues, the current user must reauthenticate by entering their password, followed by any active and compatible two-factor challenge. Successful reauthentication starts a short, configurable window of 1–15 minutes for additional covered actions in that browser session. WordPress core and the target feature still own their normal capability and authorization checks; WP Sudo adds the fresh-identity checkpoint before the covered action is allowed to continue.

WP Sudo gates specific operations on specific surfaces. It is not a firewall, exploit detector, malware scanner, or fix for authorization vulnerabilities inside third-party plugin code.

Sudo administration and governance

"With great power comes great responsibility," so users with the capability to change Sudo settings, view sudo session activity, kill sudo sessions, or export sudo activity logs are limited by default:

  • On single sites, the installing administrator receives all four caps. Other admins receive none until explicitly granted.
  • On multisite networks, super administrators receive all four caps at network scope by default. Per-site admins receive none until explicitly delegated.

(Export privileges are separated from view privileges because a portable export artifact is a distinct governance concern β€” SOC2/GDPR audits treat "can read" and "can take a copy offsite" differently.)

WP Sudo integrates with the Site Health tool in WordPress core for rich security diagnostics and advisory notifications.

Break glass recovery scenario

In a lost, last administrator scenario where no one has access to Sudo's settings, the break-glass mechanism is to set WP_SUDO_RECOVERY_MODE in wp-config.php. It requires filesystem access to activate, so it is not a remote-escalation vector. The grant is role-gated: while the constant is defined, the current user receives the master manage_wp_sudo capability only if they also hold manage_options (single-site) / manage_network_options (multisite), so a locked-out administrator recovers while non-admins gain nothing. A permanent non-dismissible notice appears on the Sudo settings screen while it is active, and the wp_sudo_recovery_mode_active audit hook fires so the usage is logged. The role gate does not eliminate the residual risk β€” every administrator regains full Sudo governance while the constant is set β€” so remove it the moment normal access is restored.

For developers and integrators

WP Sudo exposes a small, stable API. Custom gated rules are plain associative arrays registered via the wp_sudo_gated_actions filter, with per-surface matchers for admin, AJAX, REST, and CLI. The wp_sudo_can() helper centralizes all governance checks β€” super-admin short-circuit, recovery-mode bypass, and strict/compatibility mode β€” so integrations don't touch capability internals directly. Audit hooks fire on every session event, capability grant or revoke, tamper detection, and policy change; bridge classes for WP Activity Log and Stream are bundled. The wp_sudo_grant_session_on_login filter lets SSO and kiosk integrations suppress the automatic browser-login session grant. All of this is covered by a dual-layer test suite (unit tests + a full integration matrix) and PHPStan level 6.

Requirements

  • WordPress: 6.2+
  • PHP: 8.0+
  • Multisite: supported

For current release posture, supported lanes, and forward main notes, see docs/release-status.md.

Documentation

Start here

For developers and integrators

Verification and project status

Background and research

Development

Quick local checks:

composer install
composer test:unit
composer lint
composer analyse

For full setup, integration tests, E2E workflows, and contributor expectations, see CONTRIBUTING.md.

License

GPL-2.0-or-later.

About

Sudo for WordPress! πŸ₯ͺ Risky actions β€” activating plugins, deleting users, changing key settings β€” are gated by a required reauthentication step, regardless of user role. Time-bounded sessions, 2FA support, rate limiting, and configurable policies for REST, WP-CLI, Cron, WPGraphQL, & XML-RPC. No role escalation, no new permissions β€” just a gate. ⛩️

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors