Skip to content

Fix OIDC issuer domain spoofing in B2C host validation#896

Merged
4gust merged 2 commits intodevfrom
4gust/fix-oidc-issue
Apr 7, 2026
Merged

Fix OIDC issuer domain spoofing in B2C host validation#896
4gust merged 2 commits intodevfrom
4gust/fix-oidc-issue

Conversation

@4gust
Copy link
Copy Markdown
Contributor

@4gust 4gust commented Apr 7, 2026

Problem

The OIDC issuer validation in has_valid_issuer() used endswith(domain) to check B2C hosts, which allows malicious domains to pass validation #891:

# Before: fakeb2clogin.com passes because it endswith("b2clogin.com")
issuer_host.endswith(h)  # h = "b2clogin.com"

Fix

Require a dot separator to ensure only true subdomains match:

issuer_host.endswith("." + h)  # Only matches *.b2clogin.com

Tests

Added 5 tests covering spoofing scenarios (fakeb2clogin.com, evilb2clogin.com, b2clogin.com.evil.com, fakeciamlogin.com) and valid subdomain acceptance.

@4gust 4gust requested a review from a team as a code owner April 7, 2026 08:04
Copilot AI review requested due to automatic review settings April 7, 2026 08:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens OIDC issuer validation for B2C/CIAM authorities by preventing domain-suffix spoofing in Authority.has_valid_issuer(), aligning issuer-host checks with safer subdomain matching.

Changes:

  • Strengthened B2C/CIAM issuer host validation to require a dot-separated suffix match (e.g., *.b2clogin.com).
  • Added unit tests covering multiple spoofed-domain scenarios plus a valid subdomain acceptance case.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
msal/authority.py Updates issuer-host validation logic to prevent endswith(domain) spoofing.
tests/test_authority.py Adds regression tests for spoofed issuer hosts and valid B2C subdomain behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@gladjohn gladjohn left a comment

Choose a reason for hiding this comment

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

🚢

@4gust 4gust merged commit a3ba722 into dev Apr 7, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants