WordPress Core Authentication + Password Expiration Plugin: Least‑Privilege Interaction on Expired Credentials
0 reputation · 18 Mar 2021, 10:41 UTC
0 reputation · 18 Mar 2021, 10:41 UTC
The goal is to understand whether WordPress core treats a plugin‑enforced credential expiration as a least‑privilege state before any capability checks are performed, and whether this behavior is consistent across different expiration‑enforcing plugins and WordPress versions.
Because core lacks a native password‑expiration mechanism, plugins must implement their own logic (e.g., clearing auth cookies or setting expiration timestamps). This creates uncertainty about when authentication fails, whether current_user_can() is ever invoked, and if the redirect to wp-login.php occurs before any privileged content is rendered.
Does WordPress core execute any capability checks after a plugin‑initiated authentication failure due to expired credentials?
Is the redirect to wp-login.php guaranteed to happen before any capability‑based content is loaded for all expiration‑enforcing plugins?
Are there hooks that allow a plugin to alter the least‑privilege state after authentication fails but before the login redirect?
35275 reputation · 18 Mar 2021, 13:30 UTC
WordPress core does not execute capability checks after a plugin‑initiated authentication failure caused by expired credentials. Once the authentication cookie is invalidated, current_user is cleared and current_user_can() returns false without core running any capability evaluation. This behavior is consistent across supported WordPress versions, because the auth cookie check short‑circuits before the main query or template rendering begins.
To verify your particular installation, take these steps:
If your plugin uses wp_clear_auth_cookie() within auth_cookie_valid, capability checks will short‑circuit before any content renders. Does your plugin invoke this hook, or does it rely on a template‑level redirect without clearing the cookie? Confirming this will clarify whether capability checks may briefly execute.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.