Skip to content

fix: normalize host-only allowed origins to https:// scheme#822

Merged
Spomky merged 2 commits into5.2.xfrom
fix/host-only-origin-https-normalization
Mar 23, 2026
Merged

fix: normalize host-only allowed origins to https:// scheme#822
Spomky merged 2 commits into5.2.xfrom
fix/host-only-origin-https-normalization

Conversation

@Spomky
Copy link
Contributor

@Spomky Spomky commented Mar 23, 2026

Summary

  • Host-only entries in allowed_origins (e.g. example.com without scheme) were matched only against the incoming origin's host, bypassing scheme and port validation. This allowed origins like https://example.com:8443 or https://example.com:9999 to pass validation when only example.com was configured.
  • Since WebAuthn requires TLS, host-only entries are now normalized to https://{host} in the constructor and go through the full origin match (scheme + host + port), closing this bypass.
  • The $hostOrigins property and isSubdomain() helper method are removed as they are no longer needed.

Fixes #817

Test plan

  • Existing tests pass — host-only entries like spomky-labs.com with allowSubdomains=true still correctly match subdomains via full origin matching
  • Verify that example.com in allowed_origins only matches https://example.com (not https://example.com:8443 or http://example.com)
  • Verify that http://localhost explicitly configured still works for development

🤖 Generated with Claude Code

Host-only entries in allowed_origins (e.g. "example.com") were matched
against the incoming origin's host without checking the scheme or port,
allowing origins like https://example.com:8443 to bypass validation.

Since WebAuthn requires TLS, host-only entries are now normalized to
https://{host} in the constructor and go through the full origin match
(scheme + host + port), closing this bypass.

Fixes #817

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Spomky Spomky self-assigned this Mar 23, 2026
@Spomky Spomky added the bug Something isn't working label Mar 23, 2026
@Spomky Spomky added this to the 5.2.6 milestone Mar 23, 2026
@Spomky Spomky linked an issue Mar 23, 2026 that may be closed by this pull request
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Spomky Spomky merged commit bf3baac into 5.2.x Mar 23, 2026
13 of 14 checks passed
@Spomky Spomky deleted the fix/host-only-origin-https-normalization branch March 23, 2026 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CheckAllowedOrigins host only behavior

1 participant