Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

* Requirements: Minimum PHP raised to 8.2 and minimum WordPress to 6.7. Tested up to WordPress 7.1.

**3.11.5**

* Fix: Logins failed with "Invalid state" on hosts that only pass WordPress-style cookie names to PHP, such as Pantheon. The login cookie is now named `wp-openid_connect_generic_browser`, and the new `openid-connect-generic-browser-cookie-name` filter can change it.
* Improvement: When logging is enabled, a failed state check logs which part of the check failed.

**3.11.4**

* Security: Login state is now tied to the browser that started the login and can only be used once.
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
**Tags:** security, login, oauth2, openidconnect, apps, authentication, autologin, sso
**Requires at least:** 6.7
**Tested up to:** 7.1
**Stable tag:** 3.11.4
**Stable tag:** 3.11.5
**Requires PHP:** 8.2
**License:** GPLv2 or later
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -57,6 +57,10 @@ On the settings page for this plugin (Dashboard > Settings > OpenID Connect Gene

Requires PHP 8.2 and WordPress 6.7 or later. Check your server's PHP version before updating.

### 3.11.5 ###

Fixes logins failing with "Invalid state" on Pantheon and some other managed hosts after updating to 3.11.4.

### 3.11.4 ###

SECURITY UPDATE: Hardens login and account linking. Requires PHP 8.0. If you use Link Existing Users, review the new Link Users Without Verified Email setting after updating.
Expand All @@ -71,6 +75,11 @@ SECURITY UPDATE: 3.11.x branch - Fixes authentication vulnerabilities including

* Requirements: Minimum PHP raised to 8.2 and minimum WordPress to 6.7. Tested up to WordPress 7.1.

### 3.11.5 ###

* Fix: Logins failed with "Invalid state" on hosts that only pass WordPress-style cookie names to PHP, such as Pantheon. The login cookie is now named `wp-openid_connect_generic_browser`, and the new `openid-connect-generic-browser-cookie-name` filter can change it.
* Improvement: When logging is enabled, a failed state check logs which part of the check failed.

### 3.11.4 ###

* Security: Login state is now tied to the browser that started the login and can only be used once.
Expand Down
45 changes: 38 additions & 7 deletions includes/openid-connect-generic-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,13 @@ class OpenID_Connect_Generic_Client {
private $state_time_limit = 180;

/**
* Cookie that identifies the browser that started a login.
* Default name of the cookie that identifies the browser that started a login.
*
* Managed hosts such as Pantheon only pass cookies with WordPress-style names to PHP.
*
* @var string
*/
const BROWSER_COOKIE = 'openid-connect-generic-browser';
const BROWSER_COOKIE = 'wp-openid_connect_generic_browser';

/**
* Allow HTTP requests to internal/private network endpoints.
Expand Down Expand Up @@ -501,6 +503,7 @@ public function check_state( $state ) {

if ( ! is_string( $state ) || ! preg_match( '/^[a-f0-9]{32}$/', $state ) ) {
do_action( 'openid-connect-generic-state-not-found', $state );
$this->logger->log( 'State is malformed.', 'invalid-state' );
return false;
}

Expand All @@ -518,14 +521,25 @@ public function check_state( $state ) {
}

if ( ! $valid ) {
$this->logger->log( 'State not found or expired.', 'invalid-state' );
return false;
}

// The state must come back to the browser that started the login, and only once.
$binding = get_transient( 'openid-connect-generic-state--' . $state . '--browser' );
$browser_id = $this->get_browser_id();
if ( empty( $binding ) || empty( $browser_id ) || ! hash_equals( $binding, $this->hash_browser_id( $browser_id ) ) ) {
$reason = '';
if ( empty( $binding ) ) {
$reason = 'State is not linked to a browser.';
} elseif ( empty( $browser_id ) ) {
$reason = 'Browser cookie missing from the request.';
} elseif ( ! hash_equals( $binding, $this->hash_browser_id( $browser_id ) ) ) {
$reason = 'Browser cookie does not match the state.';
}

if ( ! empty( $reason ) ) {
do_action( 'openid-connect-generic-state-not-found', $state );
$this->logger->log( $reason, 'invalid-state' );
return false;
}

Expand Down Expand Up @@ -676,17 +690,34 @@ public function delete_state( $state ) {
delete_transient( 'openid-connect-generic-state--' . $state . '--pkce' );
}

/**
* Get the name of the browser cookie.
*
* @return string
*/
public function get_browser_cookie_name() {
/**
* Filters the name of the cookie that identifies the browser that started a login.
*
* @param string $name The cookie name.
*/
$name = apply_filters( 'openid-connect-generic-browser-cookie-name', self::BROWSER_COOKIE );

return is_string( $name ) && preg_match( '/^[A-Za-z0-9_-]+$/', $name ) ? $name : self::BROWSER_COOKIE;
}

/**
* Get the browser identifier from the browser cookie.
*
* @return string Empty when the cookie is missing or malformed.
*/
public function get_browser_id() {
if ( empty( $_COOKIE[ self::BROWSER_COOKIE ] ) || ! is_string( $_COOKIE[ self::BROWSER_COOKIE ] ) ) {
$name = $this->get_browser_cookie_name();
if ( empty( $_COOKIE[ $name ] ) || ! is_string( $_COOKIE[ $name ] ) ) {
return '';
}

$browser_id = sanitize_text_field( wp_unslash( $_COOKIE[ self::BROWSER_COOKIE ] ) );
$browser_id = sanitize_text_field( wp_unslash( $_COOKIE[ $name ] ) );

return preg_match( '/^[a-f0-9]{32}$/', $browser_id ) ? $browser_id : '';
}
Expand All @@ -708,7 +739,7 @@ public function ensure_browser_id() {

$browser_id = bin2hex( random_bytes( 16 ) );
$this->send_browser_cookie( $browser_id );
$_COOKIE[ self::BROWSER_COOKIE ] = $browser_id;
$_COOKIE[ $this->get_browser_cookie_name() ] = $browser_id;

return $browser_id;
}
Expand All @@ -731,7 +762,7 @@ protected function headers_sent() {
*/
protected function send_browser_cookie( $browser_id ) {
setcookie(
self::BROWSER_COOKIE,
$this->get_browser_cookie_name(),
$browser_id,
array(
'expires' => 0,
Expand Down
58 changes: 29 additions & 29 deletions languages/openid-connect-generic.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# This file is distributed under the GPL-2.0+.
msgid ""
msgstr ""
"Project-Id-Version: OpenID Connect Generic 3.11.4\n"
"Project-Id-Version: OpenID Connect Generic 3.11.5\n"
"Report-Msgid-Bugs-To: "
"https://github.com/oidc-wp/openid-connect-generic/issues\n"
"POT-Creation-Date: 2026-11-15 13:25:51+00:00\n"
"POT-Creation-Date: 2026-11-20 11:35:59+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
Expand All @@ -26,7 +26,7 @@ msgstr ""
"X-Generator: grunt-wp-i18n 1.0.3\n"

#: includes/openid-connect-generic-client-wrapper.php:295
#: includes/openid-connect-generic-client.php:281
#: includes/openid-connect-generic-client.php:283
msgid "Invalid state."
msgstr ""

Expand Down Expand Up @@ -74,113 +74,113 @@ msgid ""
"administrator."
msgstr ""

#: includes/openid-connect-generic-client.php:277
#: includes/openid-connect-generic-client.php:279
msgid "Missing state."
msgstr ""

#: includes/openid-connect-generic-client.php:296
#: includes/openid-connect-generic-client.php:298
msgid "Missing authentication code."
msgstr ""

#: includes/openid-connect-generic-client.php:346
#: includes/openid-connect-generic-client.php:348
msgid "Request for authentication token failed."
msgstr ""

#: includes/openid-connect-generic-client.php:379
#: includes/openid-connect-generic-client.php:381
msgid "Refresh token failed."
msgstr ""

#: includes/openid-connect-generic-client.php:394
#: includes/openid-connect-generic-client.php:396
msgid "Missing token body."
msgstr ""

#: includes/openid-connect-generic-client.php:402
#: includes/openid-connect-generic-client.php:404
msgid "Invalid token."
msgstr ""

#: includes/openid-connect-generic-client.php:463
#: includes/openid-connect-generic-client.php:465
msgid "Request for userinfo failed."
msgstr ""

#: includes/openid-connect-generic-client.php:581
#: includes/openid-connect-generic-client.php:595
msgid "Invalid nonce."
msgstr ""

#: includes/openid-connect-generic-client.php:767
#: includes/openid-connect-generic-client.php:798
msgid "Missing authentication state."
msgstr ""

#: includes/openid-connect-generic-client.php:804
#: includes/openid-connect-generic-client.php:835
msgid "No identity token."
msgstr ""

#: includes/openid-connect-generic-client.php:844
#: includes/openid-connect-generic-client.php:875
msgid "Missing identity token."
msgstr ""

#: includes/openid-connect-generic-client.php:903
#: includes/openid-connect-generic-client.php:934
msgid "Bad ID token claim."
msgstr ""

#: includes/openid-connect-generic-client.php:908
#: includes/openid-connect-generic-client.php:939
msgid "No subject identity."
msgstr ""

#: includes/openid-connect-generic-client.php:913
#: includes/openid-connect-generic-client.php:944
#: includes/openid-connect-generic-jwt-validator.php:184
msgid "Token missing expiration claim."
msgstr ""

#: includes/openid-connect-generic-client.php:916
#: includes/openid-connect-generic-client.php:947
msgid "Token has expired."
msgstr ""

#: includes/openid-connect-generic-client.php:921
#: includes/openid-connect-generic-client.php:952
#: includes/openid-connect-generic-jwt-validator.php:192
msgid "Token missing issued at claim."
msgstr ""

#: includes/openid-connect-generic-client.php:926
#: includes/openid-connect-generic-client.php:957
#: includes/openid-connect-generic-jwt-validator.php:200
msgid "Token missing audience claim."
msgstr ""

#: includes/openid-connect-generic-client.php:939
#: includes/openid-connect-generic-client.php:970
#: includes/openid-connect-generic-jwt-validator.php:217
msgid "Token audience does not match client."
msgstr ""

#: includes/openid-connect-generic-client.php:949
#: includes/openid-connect-generic-client.php:980
#: includes/openid-connect-generic-jwt-validator.php:226
msgid "Token missing issuer claim."
msgstr ""

#: includes/openid-connect-generic-client.php:964
#: includes/openid-connect-generic-client.php:995
#: includes/openid-connect-generic-jwt-validator.php:241
msgid "Token issuer does not match expected issuer."
msgstr ""

#: includes/openid-connect-generic-client.php:974
#: includes/openid-connect-generic-client.php:1005
msgid "No matching acr values."
msgstr ""

#: includes/openid-connect-generic-client.php:994
#: includes/openid-connect-generic-client.php:1025
msgid "Bad user claim."
msgstr ""

#: includes/openid-connect-generic-client.php:1014
#: includes/openid-connect-generic-client.php:1045
msgid "Invalid user claim."
msgstr ""

#: includes/openid-connect-generic-client.php:1019
#: includes/openid-connect-generic-client.php:1050
msgid "Error from the IDP."
msgstr ""

#: includes/openid-connect-generic-client.php:1028
#: includes/openid-connect-generic-client.php:1059
msgid "Incorrect user claim."
msgstr ""

#: includes/openid-connect-generic-client.php:1035
#: includes/openid-connect-generic-client.php:1066
msgid "Unauthorized access."
msgstr ""

Expand Down
4 changes: 2 additions & 2 deletions openid-connect-generic.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Plugin Name: OpenID Connect Generic
* Plugin URI: https://github.com/oidc-wp/openid-connect-generic
* Description: Connect to an OpenID Connect identity provider using Authorization Code Flow.
* Version: 3.11.4
* Version: 3.11.5
* Requires at least: 6.7
* Requires PHP: 8.2
* Author: daggerhart
Expand Down Expand Up @@ -93,7 +93,7 @@ class OpenID_Connect_Generic {
*
* @var string
*/
const VERSION = '3.11.4';
const VERSION = '3.11.5';

/**
* Option flagging the admin notice about linking users without a verified email.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openid-connect-generic",
"version": "3.11.4",
"version": "3.11.5",
"description": "OpenID Connect generic WordPress plugin.",
"main": "Gruntfile.js",
"repository": {
Expand Down
11 changes: 10 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: daggerhart, tnolte
Tags: security, login, oauth2, openidconnect, apps, authentication, autologin, sso
Requires at least: 6.7
Tested up to: 7.1
Stable tag: 3.11.4
Stable tag: 3.11.5
Requires PHP: 8.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -57,6 +57,10 @@ On the settings page for this plugin (Dashboard > Settings > OpenID Connect Gene

Requires PHP 8.2 and WordPress 6.7 or later. Check your server's PHP version before updating.

= 3.11.5 =

Fixes logins failing with "Invalid state" on Pantheon and some other managed hosts after updating to 3.11.4.

= 3.11.4 =

SECURITY UPDATE: Hardens login and account linking. Requires PHP 8.0. If you use Link Existing Users, review the new Link Users Without Verified Email setting after updating.
Expand All @@ -71,6 +75,11 @@ SECURITY UPDATE: 3.11.x branch - Fixes authentication vulnerabilities including

* Requirements: Minimum PHP raised to 8.2 and minimum WordPress to 6.7. Tested up to WordPress 7.1.

= 3.11.5 =

* Fix: Logins failed with "Invalid state" on hosts that only pass WordPress-style cookie names to PHP, such as Pantheon. The login cookie is now named `wp-openid_connect_generic_browser`, and the new `openid-connect-generic-browser-cookie-name` filter can change it.
* Improvement: When logging is enabled, a failed state check logs which part of the check failed.

= 3.11.4 =

* Security: Login state is now tied to the browser that started the login and can only be used once.
Expand Down
Loading
Loading