GHSA-875x-g8p7-5w27

Suggest an improvement
Source
https://github.com/advisories/GHSA-875x-g8p7-5w27
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/07/GHSA-875x-g8p7-5w27/GHSA-875x-g8p7-5w27.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-875x-g8p7-5w27
Aliases
Published
2024-07-15T16:37:49Z
Modified
2024-07-15T22:24:12.104140Z
Severity
  • 5.3 (Medium) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N CVSS Calculator
  • 6.9 (Medium) CVSS_V4 - CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N CVSS Calculator
Summary
The FIDO2/Webauthn Support for PHP library allows enumeration of valid usernames
Details

Summary

The ProfileBasedRequestOptionsBuilder method returns allowedCredentials without any credentials if no username was found.

Details

When WebAuthn is used as the first or only authentication method, an attacker can enumerate usernames based on the absence of the allowedCredentials property in the assertion options response. This allows enumeration of valid or invalid usernames.

Proposal how to resolve it:

return $this->publicKeyCredentialRequestOptionsFactory->create(
            $this->profile,
            count($allowedCredentials) <= 0 ? self::getRandomCredentials(): $allowedCredentials,
            $optionsRequest->userVerification,
            $extensions
);

private static function getRandomCredentials(): array
{
        $credentialSources = [];
        for ($i = 0; $i <= rand(0,1); $i++) {
            $credentialSources[] = new PublicKeyCredentialSource(
                random_bytes(32),
                "public-key",
                [],
                "basic",
                new EmptyTrustPath(),
                Uuid::v7(),
                random_bytes(77),
                Uuid::v7()->__toString(),
                rand(0, 6000),
                null
            );
        }
        return array_map(
            static fn (PublicKeyCredentialSource $credential): PublicKeyCredentialDescriptor => $credential->getPublicKeyCredentialDescriptor(),
            $credentialSources
        );
}

PoC

curl https://example.com/assertion/options \ -H 'content-type: application/json' \ --data-raw '{"username":"NotMeRandomUsername123"}'

Impact

By knowing which usernames are valid, attackers can focus their efforts on a smaller set of potential targets, increasing the efficiency and likelihood of successful attacks.

Database specific
{
    "nvd_published_at": "2024-07-15T20:15:03Z",
    "cwe_ids": [
        "CWE-204"
    ],
    "severity": "MODERATE",
    "github_reviewed": true,
    "github_reviewed_at": "2024-07-15T16:37:49Z"
}
References

Affected packages

Packagist / web-auth/webauthn-lib

Package

Name
web-auth/webauthn-lib
Purl
pkg:composer/web-auth/webauthn-lib

Affected ranges

Type
ECOSYSTEM
Events
Introduced
4.5.0
Fixed
4.9.0

Affected versions

4.*

4.5.0
4.5.1
4.5.2
4.6.0
4.6.1
4.6.2
4.6.3
4.6.4
4.7.0
4.7.1
4.7.2
4.7.3
4.7.4
4.7.5
4.7.6
4.7.7
4.7.8
4.7.9
4.8.0
4.8.1
4.8.2
4.8.3
4.8.4
4.8.5
4.8.6
4.8.7

Packagist / web-auth/webauthn-framework

Package

Name
web-auth/webauthn-framework
Purl
pkg:composer/web-auth/webauthn-framework

Affected ranges

Type
ECOSYSTEM
Events
Introduced
4.5.0
Fixed
4.9.0

Affected versions

4.*

4.5.0
4.5.1
4.5.2
4.6.0
4.6.1
4.6.2
4.6.3
4.6.4
4.7.0
4.7.1
4.7.2
4.7.3
4.7.4
4.7.5
4.7.6
4.7.7
4.7.8
4.7.9
4.8.0
4.8.1
4.8.2
4.8.3
4.8.4
4.8.5
4.8.6
4.8.7