Skip to content

Require ASCII inputs for expectedRPID and expectedOrigin - #824

Merged
MasterKale merged 10 commits into
masterfrom
enforce-ascii-inputs
Nov 6, 2026
Merged

MasterKale merged 10 commits into
masterfrom
enforce-ascii-inputs

Conversation

@MasterKale

@MasterKale MasterKale commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

This PR adds a requirement that the expectedRPID and expectedOrigin arguments be ASCII values when calling verifyRegistrationResponse() and verifyAuthenticationResponse().

Browsers normalize origins and RP IDs with UTF-8 values (e.g. "mïllërtïmë.dev") to ASCII punycode representations (e.g. "xn--mllrtm-rvad3af.dev") before passing them to authenticators and RPs. RPs with such domains should intentionally set the punycode form of their domains when calling these methods to make it explicit what values are being used for comparison.

Calls to verifyRegistrationResponse() and verifyAuthenticationResponse() with UTF-8 values in expectedRPID or expectedOrigin will raise SimpleWebAuthnError with a suggestion about how to fix the problem.

Fixes #823.

Invalid expectedRPID

import { verifyRegistrationResponse } from '@simplewebauthn/server';

const verified = await verifyRegistrationResponse({
  // ...
  expectedRPID: 'local.mïllërtïmë.dev',
});
error: Uncaught (in promise) SimpleWebAuthnError: "local.mïllërtïmë.dev" is not
a valid expected RP ID. Replace it with its ASCII punycode representation
"local.xn--mllrtm-rvad3af.dev" and try again
    throw new SimpleWebAuthnError({
          ^
    at assertASCIIRPID (.../helpers/assertASCIIRPID.ts:12:11)
    at matchExpectedRPID (.../helpers/matchExpectedRPID.ts:18:5)
    at verifyRegistrationResponse (.../registration/verifyRegistrationResponse.ts:183:25)

Invalid expectedOrigin

import { verifyRegistrationResponse } from '@simplewebauthn/server';

const verified = await verifyRegistrationResponse({
  // ...
  expectedOrigin: 'https://local.mïllërtïmë.dev',
});
error: Uncaught (in promise) SimpleWebAuthnError: "https://local.mïllërtïmë.dev" is not
a valid expected origin. Replace it with its ASCII punycode representation
"https://local.xn--mllrtm-rvad3af.dev" and try again
    throw new SimpleWebAuthnError({
          ^
    at assertASCIIOrigin (.../helpers/assertASCIIOrigin.ts:17:11)
    at matchExpectedOrigin (.../helpers/matchExpectedOrigin.ts:18:5)
    at verifyRegistrationResponse (.../registration/verifyRegistrationResponse.ts:138:3)

@MasterKale
MasterKale merged commit 60c34a1 into master Nov 6, 2026
15 checks passed
@MasterKale
MasterKale deleted the enforce-ascii-inputs branch November 6, 2026 18:23
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.

Tweak matchExpectedRPID() to handle UTF-8 RP IDs?

1 participant