Account names: reject ".", ".." and control/invisible characters; make local account names unique case-insensitively #840

Closed
opened 2026-10-03 16:36:51 +00:00 by Cordy · 3 comments
Owner

Found in the #533 QA pass (2026-10-03). This covers QA findings 3 and 6.

What happens

  • Unsafe names pass validation. auth.validUsername (internal/auth/setup.go) only refuses space, /, \ and NUL. It is used both by first-run setup and by the Accounts tab (POST /api/v1/admin/local-users). The following are accepted:
    • . and ..;
    • tab, newline and other control characters;
    • invisible and bidi characters, such as U+202E RIGHT-TO-LEFT OVERRIDE.
  • What .. does. The scope layer saves the day ("scope: username is not a safe path segment"), so nothing leaked. But the account is created, signs in (204), takes a licence seat, and then every file, WebDAV and share call answers 404 or 500. A first admin named .. would be an unusable instance.
  • Log and audit forging. Control characters let a username forge lines in text logs and audit views.
  • Case variants. victim and VICTIM are two separate accounts:
    • they are indistinguishable at a glance in lists, the bell and audit;
    • their homes collide on a case-insensitive host filesystem (macOS/Windows bind mounts, some SMB/NFS exports);
    • the #557 guard against shadowing a seen directory account is exact-match, so Alice can still shadow directory alice. (Code read; worth a test.)

Research

  • Spotify 2013 (account takeover). A non-idempotent Unicode username canonicalisation let ᴮᴵᴳᴮᴵᴿᴰ take over bigbird through a password reset. Lesson: canonicalise once, idempotently, and compare canonical forms everywhere. Spotify had to stop sign-ups until it was fixed.
  • PRECIS (RFC 8265, UsernameCaseMapped).
    • It is the standard profile for this: NFC, width mapping, case folding, and it disallows control and bidi-unsafe code points.
    • Go has it in golang.org/x/text/secure/precis, precis.UsernameCaseMapped. That's a stdlib-adjacent dependency the module may already pull in transitively; to check.
  • Gitea stores LowerName next to Name: case is preserved for display, uniqueness is on the lowercase form. Its reserved-names list grew over the years (issues #13867, #6280, #18438). Reserved names are a moving target, so keep the list minimal and data-driven.
  • Nextcloud restricts login names to a-z A-Z 0-9 - _ . @ space and has had long-running pain from case and digit-only IDs (server #11197, #21313). Changing the rules after the fact is the expensive part, so we do it now while instances are few.

Plan

  1. One auth.CanonicalUsername(s) (canon string, err error):
    • Rejects: empty; longer than 64 characters; . and .. and names made of dots only; anything with a control or format code point (Cc, Cf, including bidi overrides); /, \, NUL and whitespace.
    • Then returns the canonical form: PRECIS UsernameCaseMapped, or NFC plus strings.ToLower if the dependency is unwanted.
    • Used by setup, Accounts create, the #557 directory-shadow check and the login lookup. Display keeps the name as typed.
  2. Uniqueness on the canonical form in LocalStore.Create: 409 "an account named like this already exists (case differs)".
  3. Existing instances. At boot, if two stored accounts collide canonically, or an existing name fails validation:
    • log a WARN naming them;
    • show an admin-only bell item.
    • Never auto-rename or merge. The admin decides.
  4. Login keeps matching the stored name exactly, plus a canonical fallback when unambiguous. Users who typed Alice at creation can sign in as alice.

Tests

  • table of names: ., .., ..., a\tb, a\nb, ‮evil, a b, ok.name, ok@x, ÄÖÜ;
  • case-variant create → 409;
  • shadow check case-insensitive;
  • boot-time collision warning;
  • idempotence: canon(canon(x)) == canon(x) (Spotify lesson).

Decision for Nikola

Unicode letters in local names: allow them (PRECIS) or restrict to ASCII like Nextcloud? Proposal: allow them via PRECIS. German and Swiss names with umlauts are normal in the target market.

Refs:

Found in the #533 QA pass (2026-10-03). This covers QA findings 3 and 6. ## What happens - **Unsafe names pass validation.** `auth.validUsername` (internal/auth/setup.go) only refuses space, `/`, `\` and NUL. It is used both by first-run setup and by the Accounts tab (`POST /api/v1/admin/local-users`). The following are accepted: - **`.` and `..`**; - tab, newline and other control characters; - invisible and bidi characters, such as U+202E RIGHT-TO-LEFT OVERRIDE. - **What `..` does.** The scope layer saves the day ("scope: username is not a safe path segment"), so nothing leaked. But the account is created, signs in (204), takes a licence seat, and then every file, WebDAV and share call answers 404 or 500. A first admin named `..` would be an unusable instance. - **Log and audit forging.** Control characters let a username forge lines in text logs and audit views. - **Case variants.** `victim` and `VICTIM` are two separate accounts: - they are indistinguishable at a glance in lists, the bell and audit; - their homes collide on a case-insensitive host filesystem (macOS/Windows bind mounts, some SMB/NFS exports); - the #557 guard against shadowing a seen directory account is exact-match, so `Alice` can still shadow directory `alice`. (Code read; worth a test.) ## Research - **Spotify 2013 (account takeover).** A non-idempotent Unicode username canonicalisation let `ᴮᴵᴳᴮᴵᴿᴰ` take over `bigbird` through a password reset. Lesson: canonicalise once, idempotently, and compare canonical forms everywhere. Spotify had to stop sign-ups until it was fixed. - **PRECIS (RFC 8265, UsernameCaseMapped).** - It is the standard profile for this: NFC, width mapping, case folding, and it disallows control and bidi-unsafe code points. - Go has it in `golang.org/x/text/secure/precis`, `precis.UsernameCaseMapped`. That's a stdlib-adjacent dependency the module may already pull in transitively; to check. - **Gitea** stores `LowerName` next to `Name`: case is preserved for display, uniqueness is on the lowercase form. Its reserved-names list grew over the years (issues #13867, #6280, #18438). Reserved names are a moving target, so keep the list minimal and data-driven. - **Nextcloud** restricts login names to `a-z A-Z 0-9 - _ . @ space` and has had long-running pain from case and digit-only IDs (server #11197, #21313). Changing the rules after the fact is the expensive part, so we do it now while instances are few. ## Plan 1. One `auth.CanonicalUsername(s) (canon string, err error)`: - **Rejects:** empty; longer than 64 characters; `.` and `..` and names made of dots only; anything with a control or format code point (Cc, Cf, including bidi overrides); `/`, `\`, NUL and whitespace. - **Then returns the canonical form:** PRECIS UsernameCaseMapped, or NFC plus `strings.ToLower` if the dependency is unwanted. - Used by setup, Accounts create, the #557 directory-shadow check and the login lookup. Display keeps the name as typed. 2. **Uniqueness** on the canonical form in `LocalStore.Create`: 409 "an account named like this already exists (case differs)". 3. **Existing instances.** At boot, if two stored accounts collide canonically, or an existing name fails validation: - log a WARN naming them; - show an admin-only bell item. - Never auto-rename or merge. The admin decides. 4. **Login** keeps matching the stored name exactly, plus a canonical fallback when unambiguous. Users who typed `Alice` at creation can sign in as `alice`. ### Tests - table of names: `.`, `..`, `...`, `a\tb`, `a\nb`, `‮evil`, `a b`, `ok.name`, `ok@x`, `ÄÖÜ`; - case-variant create → 409; - shadow check case-insensitive; - boot-time collision warning; - idempotence: `canon(canon(x)) == canon(x)` (Spotify lesson). ### Decision for Nikola Unicode letters in local names: allow them (PRECIS) or restrict to ASCII like Nextcloud? Proposal: allow them via PRECIS. German and Swiss names with umlauts are normal in the target market. Refs: - https://engineering.atspotify.com/2013/06/creative-usernames - https://www.rfc-editor.org/rfc/rfc8265 - https://pkg.go.dev/golang.org/x/text/secure/precis - https://github.com/go-gitea/gitea/pull/18438 - https://github.com/nextcloud/server/issues/21313
Author
Owner

Process note (Nikola, 2026-10-03): the "Decision for Nikola" above (Unicode letters in local account names, or ASCII only) gets asked when this issue is worked on, not before.

Process note (Nikola, 2026-10-03): the "Decision for Nikola" above (Unicode letters in local account names, or ASCII only) gets asked when this issue is worked on, not before.
Author
Owner

Deep research: Unicode vs ASCII in local account names (2026-10-07)

What went wrong elsewhere, and how it was fixed

  1. Spotify, 2013: account takeover through Unicode names.
    • A user registered ᴮᴵᴳᴮᴵᴿᴰ, which canonicalised to BIGBIRD the first time and to bigbird the second.
    • A password reset therefore landed on the real bigbird.
    • The cause was a library bug (Twisted's nodeprep) plus invalid input, so canonicalisation was not idempotent.
    • They had to stop sign-ups while fixing it. The fix: validate input strictly and assert canon(canon(x)) == canon(x).
    • Spotify engineering
  2. Nextcloud: umlauts in names keep breaking clients, years later.
    • Login with umlauts works in the browser but fails in the Talk desktop app with "Login successful, but something went wrong" (talk-desktop#1360).
    • An umlaut in the device name blocks the auth token (server#11177, ios#1800).
    • Polls breaks on names with umlauts (polls#1310).
    • The manual says such characters aren't allowed, but the code never enforced it (server#21313). The result is a long tail of client bugs that are fixed one app at a time.
  3. HTTP Basic auth has no agreed charset. This matters most to us, because WebDAV uses Basic.
    • RFC 7617 leaves the default encoding undefined. Clients send ISO-8859-1 or UTF-8; servers guess.
    • Firefox switched from Latin-1 to UTF-8 only in 2017 (bmo 1419658, bmo 41489).
    • Real-world fixes still go both ways, e.g. bConnect #228: UTF-8 sent, Latin-1 decoded, so umlaut passwords fail.
    • The remedy is to announce charset="UTF-8" in WWW-Authenticate and normalise to NFC (RFC 7617 §2.1). Older WebDAV clients (Windows mini-redirector, some sync tools) ignore it.
    • This hits umlaut passwords as well as usernames.
  4. NFC vs NFD, the macOS problem.
    • The same visible name can be two different byte sequences.
    • Old HFS+ and some sync tools write NFD, while Linux and Windows write NFC. Two folders then look identical but are distinct.
    • rclone and Syncthing added normalisation handling only recently (Syncthing forum, Resilio forum).
    • Cairn names home directories after the username, so a non-ASCII username becomes a non-ASCII path on whatever filesystem or bind mount sits underneath.
  5. Look-alike names (confusables).
    • Django closed the homoglyph report as wontfix in core (ticket 36476).
    • The protection lives in django-registration's validate_confusables, which rejects mixed-script names containing confusable characters (docs).
    • Discourse keeps Unicode usernames off by default, behind an allowlist setting, and later had to block invisible characters even with the allowlist off (meta 263032).
  6. What the big platforms chose.
    • GitLab usernames: letters, digits, _ - . only, with no accented or non-Latin characters (gitlab#429283).
    • GitHub is ASCII-only for the same URL and tooling reasons (wezm on usernames).
    • Keycloak always lowercases usernames and accepts any case at login (Red Hat KB, keycloak forum). So canonical lowercase matches what the IdP side already does.

What this means for Cairn

  • Cairn already separates the login name (the account name) from the display name (#729). "Jürg Müller" can be the display name while the login name is jmueller. That's also the common AD sAMAccountName convention.
  • Directory users (LDAP and Keycloak) are not affected either way; their names come from the IdP. This decision only covers names created in Cairn: the wizard, the Accounts tab and auth.users.
  • Loosening is cheap, tightening is expensive. Nextcloud's lesson: moving from ASCII to Unicode later is a pure addition, but going from Unicode to ASCII later breaks existing accounts.

Revised recommendation (changes my earlier proposal)

ASCII login names for local accounts: a-z, 0-9, . _ - @.

  • Case-insensitive and unique; stored and compared in lowercase, like Keycloak.
  • No leading or trailing dot, and not made of dots only.
  • Umlauts go in the display name.

Also, independently of the name decision: announce charset="UTF-8" on Basic challenges, NFC-normalise, and fall back to Latin-1 decoding when the bytes aren't valid UTF-8, so umlaut passwords work across WebDAV clients. This needs a check of what Cairn does today.

The alternative is Unicode via PRECIS UsernameCaseMapped plus NFC, mixed-script/confusable rejection, and the Basic charset work. It's doable, but it adds a permanent compatibility surface, for little gain while display names exist.

## Deep research: Unicode vs ASCII in local account names (2026-10-07) ### What went wrong elsewhere, and how it was fixed 1. **Spotify, 2013: account takeover through Unicode names.** - A user registered `ᴮᴵᴳᴮᴵᴿᴰ`, which canonicalised to `BIGBIRD` the first time and to `bigbird` the second. - A password reset therefore landed on the real `bigbird`. - The cause was a library bug (Twisted's nodeprep) plus invalid input, so canonicalisation was **not idempotent**. - They had to **stop sign-ups** while fixing it. The fix: validate input strictly and assert `canon(canon(x)) == canon(x)`. - [Spotify engineering](https://engineering.atspotify.com/2013/6/creative-usernames) 2. **Nextcloud: umlauts in names keep breaking clients, years later.** - Login with umlauts works in the browser but fails in the Talk desktop app with "Login successful, but something went wrong" ([talk-desktop#1360](https://github.com/nextcloud/talk-desktop/issues/1360)). - An umlaut in the device name blocks the auth token ([server#11177](https://github.com/nextcloud/server/issues/11177), [ios#1800](https://github.com/nextcloud/ios/issues/1800)). - Polls breaks on names with umlauts ([polls#1310](https://github.com/nextcloud/polls/issues/1310)). - The manual says such characters aren't allowed, but the code never enforced it ([server#21313](https://github.com/nextcloud/server/issues/21313)). The result is a long tail of client bugs that are fixed one app at a time. 3. **HTTP Basic auth has no agreed charset. This matters most to us, because WebDAV uses Basic.** - RFC 7617 leaves the default encoding undefined. Clients send ISO-8859-1 or UTF-8; servers guess. - Firefox switched from Latin-1 to UTF-8 only in 2017 ([bmo 1419658](https://bugzilla.mozilla.org/show_bug.cgi?id=1419658), [bmo 41489](https://bugzilla.mozilla.org/show_bug.cgi?id=41489)). - Real-world fixes still go both ways, e.g. [bConnect #228](https://github.com/baramundisoftware/bConnect-MCP/issues/228): UTF-8 sent, Latin-1 decoded, so umlaut passwords fail. - The remedy is to announce `charset="UTF-8"` in `WWW-Authenticate` and normalise to NFC ([RFC 7617 §2.1](https://www.rfc-editor.org/rfc/rfc7617.html)). Older WebDAV clients (Windows mini-redirector, some sync tools) ignore it. - **This hits umlaut passwords as well as usernames.** 4. **NFC vs NFD, the macOS problem.** - The same visible name can be two different byte sequences. - Old HFS+ and some sync tools write NFD, while Linux and Windows write NFC. Two folders then look identical but are distinct. - rclone and Syncthing added normalisation handling only recently ([Syncthing forum](https://forum.syncthing.net/t/german-umlaute-like-aou-seems-to-make-trouble/16804/45), [Resilio forum](https://forum.resilio.com/topic/25472-utf-8-nfd-vs-nfc-when-syncing-with-os-x)). - Cairn names home directories after the username, so a non-ASCII username becomes a non-ASCII path on whatever filesystem or bind mount sits underneath. 5. **Look-alike names (confusables).** - Django **closed** the homoglyph report as wontfix in core ([ticket 36476](https://code.djangoproject.com/ticket/36476)). - The protection lives in django-registration's `validate_confusables`, which rejects mixed-script names containing confusable characters ([docs](https://django-registration.readthedocs.io/en/3.4/validators.html)). - Discourse keeps Unicode usernames **off by default**, behind an allowlist setting, and later had to block invisible characters even with the allowlist off ([meta 263032](https://meta.discourse.org/t/any-unicode-character-can-be-exploited-onto-the-users-name/263032)). 6. **What the big platforms chose.** - GitLab usernames: letters, digits, `_ - .` only, with no accented or non-Latin characters ([gitlab#429283](https://gitlab.com/gitlab-org/gitlab/-/issues/429283)). - GitHub is ASCII-only for the same URL and tooling reasons ([wezm on usernames](https://www.wezm.net/v2/posts/2022/usernames/)). - **Keycloak always lowercases usernames** and accepts any case at login ([Red Hat KB](https://access.redhat.com/node/3349641), [keycloak forum](https://forum.keycloak.org/t/login-german-username-with-case-insensitive/12278)). So canonical lowercase matches what the IdP side already does. ### What this means for Cairn - Cairn already separates the **login name** (the account name) from the **display name** (#729). "Jürg Müller" can be the display name while the login name is `jmueller`. That's also the common AD `sAMAccountName` convention. - Directory users (LDAP and Keycloak) are **not affected** either way; their names come from the IdP. This decision only covers names created in Cairn: the wizard, the Accounts tab and `auth.users`. - **Loosening is cheap, tightening is expensive.** Nextcloud's lesson: moving from ASCII to Unicode later is a pure addition, but going from Unicode to ASCII later breaks existing accounts. ### Revised recommendation (changes my earlier proposal) **ASCII login names for local accounts:** `a-z`, `0-9`, `. _ - @`. - Case-insensitive and unique; stored and compared in lowercase, like Keycloak. - No leading or trailing dot, and not made of dots only. - Umlauts go in the display name. Also, independently of the name decision: announce `charset="UTF-8"` on Basic challenges, NFC-normalise, and fall back to Latin-1 decoding when the bytes aren't valid UTF-8, so **umlaut passwords** work across WebDAV clients. This needs a check of what Cairn does today. The alternative is Unicode via PRECIS UsernameCaseMapped plus NFC, mixed-script/confusable rejection, and the Basic charset work. It's doable, but it adds a permanent compatibility surface, for little gain while display names exist.
Author
Owner

Decision (Nikola, 2026-10-07): ASCII login names plus display names.

  • Local account names (wizard, Accounts tab, auth.users) may use a-z 0-9 . _ - @.
  • They're case-insensitive, unique, and stored and compared in lowercase.
  • No leading or trailing dot, and not made of dots only. Maximum 64 characters.
  • Umlauts go in the display name (#729).
  • Include the WebDAV/Basic umlaut-password fix: charset="UTF-8", NFC, and a Latin-1 fallback.
  • Existing accounts that break the rule or collide are reported (WARN plus an admin bell item), never renamed automatically.
**Decision (Nikola, 2026-10-07): ASCII login names plus display names.** - Local account names (wizard, Accounts tab, `auth.users`) may use `a-z 0-9 . _ - @`. - They're case-insensitive, unique, and stored and compared in lowercase. - No leading or trailing dot, and not made of dots only. Maximum 64 characters. - Umlauts go in the display name (#729). - Include the WebDAV/Basic umlaut-password fix: `charset="UTF-8"`, NFC, and a Latin-1 fallback. - Existing accounts that break the rule or collide are reported (WARN plus an admin bell item), never renamed automatically.
Cordy closed this issue 2026-10-07 18:33:04 +00:00
Sign in to join this conversation.
No labels
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Cordy/Cairn#840
No description provided.