Skip to content
Merged
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
13 changes: 13 additions & 0 deletions inc/sso/class-sso.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,19 @@
if ($this->input($sso_path) && $this->input($sso_path) !== 'done') {
return true;
}
/*

Check warning on line 393 in inc/sso/class-sso.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Empty line required before block comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add the required blank line before the block comment.

This line triggers the static-analysis warning for a missing empty line before the new comment.

🧰 Tools
🪛 GitHub Check: Code Quality Checks

[warning] 393-393:
Empty line required before block comment

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@inc/sso/class-sso.php` at line 393, Add the required empty line immediately
before the block comment near the affected code in class-sso.php, without
changing the comment or surrounding logic.

Source: Linters/SAST tools

* A request that already carries a cookie-less SSO token must not kick
* off a new SSO round-trip: handle_cookie_less_sso_token() (init:4) is
* about to consume it and set the auth cookies. Without this
* short-circuit, wp-admin URLs like customize.php?wu_sso_token=... are
* redirected to the main /login/ BEFORE consumption, the main site mints
* yet another token and the browser loops forever between customize.php
* and /login/ (~2 rounds/sec observed in production access logs). This
* mirrors the $sso_path short-circuit right above.
*/
if ('' !== (string) $this->input('wu_sso_token', '')) {
return true;
Comment on lines +403 to +404

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Reject non-string SSO tokens before bypassing authentication.

wu_sso_token[]=... is parsed as an array. The cast makes this condition true, but handle_cookie_less_sso_token() later passes the same array to validate_sso_token(string), causing a PHP TypeError instead of normal authentication handling. Validate the token type consistently in both the guard and consumer.

Proposed fix
-		if ('' !== (string) $this->input('wu_sso_token', '')) {
+		$wu_sso_token = $this->input('wu_sso_token', '');
+
+		if (is_string($wu_sso_token) && '' !== $wu_sso_token) {
 			return true;
 		}

Also make handle_cookie_less_sso_token() return early for non-string values before calling validate_sso_token().

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@inc/sso/class-sso.php` around lines 403 - 404, Update the SSO token guard to
accept only string values before bypassing authentication, without casting
arrays or other types to strings. In handle_cookie_less_sso_token(), add the
same non-string early return before invoking validate_sso_token(), while
preserving existing handling for valid string tokens.

}

$should_skip_redirect = $this->get_isset($_COOKIE, 'wu_sso_denied', false);

Expand Down
Loading