Repository navigation
GH#2125: security(sso): apply mapped-domain token policy to magic links (GH#2125) #2129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
f0ffc5e
8d75a84
0deebf0
591de0f
d57be59
949aabf
a3399f3
b9c2156
5eb02b5
c8e396b
cb028f8
d27b433
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -805,7 +805,7 @@ protected function verify_user_site_access($user_id, $site_id) { | |
| return false; | ||
| } | ||
|
|
||
| if (is_super_admin($user_id) || is_user_member_of_blog($user_id, $site_id)) { | ||
| if ((is_super_admin($user_id) || is_user_member_of_blog($user_id, $site_id)) && $this->is_site_host_token_allowed($user_id, $site_id)) { | ||
| return true; | ||
| } | ||
| // Check if the site is the dashboard site in WP Frontend Admin which the user would not be a member of. | ||
|
|
@@ -815,6 +815,32 @@ protected function verify_user_site_access($user_id, $site_id) { | |
| return false; | ||
| } | ||
|
|
||
| /** | ||
| * Apply the SSO host token policy to a site's host. | ||
| * | ||
| * Login tokens must not be minted for, or redeemed on, customer-controlled | ||
| * mapped domains for network administrators: whoever controls the domain's | ||
| * DNS could capture the token (GHSA-qh2w-5cww-9wxr). | ||
| * | ||
| * @since n.e.x.t | ||
| * | ||
| * @param int $user_id User ID. | ||
| * @param int $site_id Site ID. | ||
| * @return bool True when a token may be used for the site's host. | ||
| */ | ||
| protected function is_site_host_token_allowed($user_id, $site_id) { | ||
|
|
||
| $site = wu_get_site($site_id); | ||
|
|
||
| if ( ! $site) { | ||
| return false; | ||
| } | ||
|
|
||
| $host = (string) wp_parse_url($site->get_active_site_url(), PHP_URL_HOST); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check the receiving host when a magic link is redeemed.
Redemption must evaluate the host that received the request, not the active URL. A network admin who arrives on a customer-controlled mapped domain must be refused. The admin should be sent to that domain's login page instead. Members and network-controlled hosts must keep their current behavior.
|
||
|
|
||
| return SSO::get_instance()->can_use_cookie_less_sso_token((int) $user_id, $host); | ||
| } | ||
|
|
||
| /** | ||
| * Verify that a user owns a payable payment and its fixed checkout URL. | ||
| * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make host-policy denial apply to the dashboard exception.
If the customer-mapped site is the WP Frontend Admin dashboard, a denied super admin falls through to Line 812 and receives
true.generate_magic_link()then issues a token despite the policy denial. Redemption also accepts this result.Reject a failed host-policy check before either access-grant branch. Keep the dashboard exception only when the host policy allows the user.