WEBAUTHN_ORIGIN with an internationalized domain never matches the browser Origin

Open
#86 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
fastapi, python

Research direction

Start with canonical_origin in server/orcaster_server/config.py and the existing tests in server/tests/test_config_webauthn_origin.py; check how the current URL parsing handles Unicode hosts, ports, and empty query or fragment markers. Add coverage for the listed acceptance criteria, then update the WEBAUTHN_ORIGIN description in the user manual and add an Unreleased changelog entry. Done means the Unicode and punycode origins match, invalid IDNA conversion reports WEBAUTHN_ORIGIN, and the existing ASCII, IP, and empty suffix behavior is covered.

Written by the indexing model from the issue text.

Description

bug P1 question server

Problem

canonical_origin normalizes WEBAUTHN_ORIGIN once at startup (server/orcaster_server/config.py:21-72, config.py:265-269). The result is compared for exact equality with the Origin header and with the origin in the WebAuthn client data (config.py:24-31).

For a host with non-ASCII characters, canonical_origin keeps the Unicode form and only lowercases it (config.py:60, via urlsplit(...).hostname). Browsers send the ASCII (punycode) form of the host in Origin. So a value such as https://bücher.example is accepted at startup but never matches. Passkey login fails and every cookie-authenticated write answers 403, which is exactly the silent failure that canonical_origin was written to prevent.

A smaller inconsistency: an empty query or fragment (https://host?, https://host#) is accepted and silently dropped, because urlsplit reports it as absent (config.py:54-57). https://host/? is rejected as a path. The behavior is harmless but not tested or documented.

Steps to reproduce

  1. Set WEBAUTHN_ORIGIN=https://bücher.example (any internationalized domain that resolves to the server).
  2. Start the server. It starts without error.
  3. Try a passkey login from a browser on that origin. The server rejects it, because the browser sends Origin: https://xn--bcher-kva.example.

Proposed change

  1. In canonical_origin, convert the host to its ASCII form with IDNA processing that matches browsers (Unicode UTS 46, non-transitional), then lowercase it. Hosts that are already ASCII and IP literals are unchanged.
  2. If the conversion fails, fail startup with the existing _bad_origin message and the reason.
  3. Keep accepting an empty ? or # suffix and drop it, as today. Pin this with a test and mention it in the docstring.
  4. Update the WEBAUTHN_ORIGIN description in the user manual: an internationalized domain may be written in Unicode or punycode.

Compatibility

  • Values that are ASCII today produce the same canonical origin as before. Existing deployments see no change.
  • Values with a Unicode host start as before and now work for login.
  • Values with an empty ? or # keep starting, with the same result. No value that starts today is refused after this change, except a Unicode host that cannot be converted, which never worked.

Acceptance criteria

  • canonical_origin("https://Bücher.Example", ...) returns https://xn--bcher-kva.example.
  • A punycode value and its Unicode spelling give the same canonical origin.
  • ASCII hosts, IPv4 and IPv6 literals and ports give the same results as before (existing tests in server/tests/test_config_webauthn_origin.py pass unchanged).
  • A host that cannot be converted fails startup with a message that names WEBAUTHN_ORIGIN.
  • Tests pin that https://host? and https://host# give https://host.
  • Existing deployments keep working without config changes.
  • CHANGELOG entry under Unreleased.

Open questions

  • WEBAUTHN_RP_ID (config.py:99) is used as given. The relying party ID of an internationalized domain must also be in ASCII form. Should it get the same conversion in this issue? Converting only when the value is not ASCII keeps existing deployments working.
Dominant language
Python
Stars
0
Forks
0
Avg merge
1d 1h
Merged PRs (30d)
10

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AInvirion/orcaster

All issues in AInvirion/orcaster

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.