Skip to content

Commit 8ee7654

Browse files
Spomkyclaude
andauthored
fix: enforce HTTPS scheme check in CheckAllowedOrigins fallback path (#820)
* fix: enforce HTTPS scheme check before host matching in CheckAllowedOrigins fallback path The HTTPS scheme check was unreachable in the fallback path (no allowed origins configured) because the method returned early on host match. Move the check before host comparison so it is always enforced. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: coding standards and regenerate PHPStan baseline - Break long CheckAllowedOrigins constructor calls into multi-line format - Regenerate PHPStan baseline to match current codebase state Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: remove unmatched PHPStan baseline entries for deprecated parameters Remove baseline entries for $optionStorage and $icon deprecations that no longer match reported errors in CI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 50445d6 commit 8ee7654

3 files changed

Lines changed: 22 additions & 27 deletions

File tree

phpstan-baseline.neon

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,6 @@ parameters:
1212
count: 1
1313
path: src/stimulus/src/WebauthnStimulusBundle.php
1414

15-
-
16-
rawMessage: 'Since web-auth/webauthn-lib 5.2.0: The parameter "$optionStorage" is deprecated since 5.2.0 and will be removed in 6.0.0. Please set "null" and use the global option storage instead..'
17-
identifier: todoBy.sfDeprecation
18-
count: 2
19-
path: src/symfony/src/Controller/AssertionControllerFactory.php
20-
21-
-
22-
rawMessage: 'Since web-auth/webauthn-lib 5.2.0: The parameter "$optionStorage" is deprecated since 5.2.0 and will be removed in 6.0.0. Please set "null" and use the global option storage instead..'
23-
identifier: todoBy.sfDeprecation
24-
count: 2
25-
path: src/symfony/src/Controller/AttestationControllerFactory.php
26-
2715
-
2816
rawMessage: 'Method Webauthn\Bundle\CredentialOptionsBuilder\PublicKeyCredentialCreationOptionsBuilder::getFromRequest() invoked with 3 parameters, 2 required.'
2917
identifier: arguments.count
@@ -1612,7 +1600,7 @@ parameters:
16121600
path: src/webauthn/src/Denormalizer/AuthenticationExtensionNormalizer.php
16131601

16141602
-
1615-
rawMessage: 'Parameter #1 $extensions of static method Webauthn\AuthenticationExtensions\AuthenticationExtensions::create() expects array<Webauthn\AuthenticationExtensions\AuthenticationExtension>, array given.'
1603+
rawMessage: 'Parameter #1 $extensions of static method Webauthn\AuthenticationExtensions\AuthenticationExtensions::create() expects array<Webauthn\AuthenticationExtensions\AuthenticationExtension>, array<mixed> given.'
16161604
identifier: argument.type
16171605
count: 1
16181606
path: src/webauthn/src/Denormalizer/AuthenticationExtensionsDenormalizer.php
@@ -2181,12 +2169,6 @@ parameters:
21812169
count: 1
21822170
path: src/webauthn/src/MetadataService/Statement/MetadataStatement.php
21832171

2184-
-
2185-
rawMessage: 'Since web-auth/webauthn-lib 5.1.0: The parameter "$icon" is deprecated since 5.1.0 and will be removed in 6.0.0. This value has no effect. Please set "null" instead..'
2186-
identifier: todoBy.sfDeprecation
2187-
count: 1
2188-
path: src/webauthn/src/PublicKeyCredentialEntity.php
2189-
21902172
-
21912173
rawMessage: 'Parameter #1 $extensions of static method Webauthn\AuthenticationExtensions\AuthenticationExtensions::create() expects array<Webauthn\AuthenticationExtensions\AuthenticationExtension>, array<Webauthn\AuthenticationExtensions\AuthenticationExtensions> given.'
21922174
identifier: argument.type

src/webauthn/src/CeremonyStep/CeremonyStepManagerFactory.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,11 @@ public function creationCeremony(): CeremonyStepManager
135135
new CheckChallenge(),
136136
$this->allowedOrigins === null ? new CheckOrigin(
137137
$this->securedRelyingPartyId ?? []
138-
) : new CheckAllowedOrigins($this->allowedOrigins, $this->allowSubdomains),
138+
) : new CheckAllowedOrigins(
139+
$this->allowedOrigins,
140+
$this->allowSubdomains,
141+
$this->securedRelyingPartyId ?? []
142+
),
139143
new CheckTopOrigin($this->topOriginValidator),
140144
new CheckRelyingPartyIdIdHash(),
141145
new CheckUserWasPresent(),
@@ -160,7 +164,11 @@ public function requestCeremony(): CeremonyStepManager
160164
new CheckChallenge(),
161165
$this->allowedOrigins === null ? new CheckOrigin(
162166
$this->securedRelyingPartyId ?? []
163-
) : new CheckAllowedOrigins($this->allowedOrigins, $this->allowSubdomains),
167+
) : new CheckAllowedOrigins(
168+
$this->allowedOrigins,
169+
$this->allowSubdomains,
170+
$this->securedRelyingPartyId ?? []
171+
),
164172
new CheckTopOrigin(),
165173
new CheckRelyingPartyIdIdHash(),
166174
new CheckUserWasPresent(),

src/webauthn/src/CeremonyStep/CheckAllowedOrigins.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@
3838

3939
/**
4040
* @param string[] $allowedOrigins
41+
* @param string[] $securedRelyingPartyId RP IDs that are allowed to use HTTP (e.g. localhost for development)
4142
*/
4243
public function __construct(
4344
array $allowedOrigins,
44-
private bool $allowSubdomains = false
45+
private bool $allowSubdomains = false,
46+
private array $securedRelyingPartyId = [],
4547
) {
4648
$fullOrigins = [];
4749
$hostOrigins = [];
@@ -113,6 +115,13 @@ public function process(
113115

114116
$rpId = $publicKeyCredentialOptions->rpId ?? $publicKeyCredentialOptions->rp->id ?? $host;
115117
$facetId = $this->getFacetId($rpId, $publicKeyCredentialOptions->extensions, $authData->extensions);
118+
119+
if (! in_array($facetId, $this->securedRelyingPartyId, true)) {
120+
$scheme = $parsedOrigin['scheme'] ?? '';
121+
$scheme === 'https' || throw AuthenticatorResponseVerificationException::create(
122+
'Invalid scheme. HTTPS required.'
123+
);
124+
}
116125
$facetId !== '' || throw AuthenticatorResponseVerificationException::create(
117126
'Invalid origin. Unable to determine the facet ID.'
118127
);
@@ -126,11 +135,7 @@ public function process(
126135
if (! $this->allowSubdomains && $isSubDomains) {
127136
throw AuthenticatorResponseVerificationException::create('Invalid origin. Subdomains are not allowed.');
128137
}
129-
130-
$scheme = $parsedOrigin['scheme'] ?? '';
131-
$scheme === 'https' || throw AuthenticatorResponseVerificationException::create(
132-
'Invalid scheme. HTTPS required.'
133-
);
138+
throw AuthenticatorResponseVerificationException::create('Invalid origin.');
134139
}
135140

136141
/**

0 commit comments

Comments
 (0)