Skip to content

Dashboard password validation depends on the shell locale #4453

Backlog

Description

@pithead-developer

What's the problem

lib/pithead/28-parse-and-validate-config.sh:356 checks the dashboard password with grep -qE '^[[:print:]]{8,128}$', which depends on the locale. The onion length floor at line 394 uses wc -c, which counts bytes, not characters.
Under a C locale, GNU grep rejects any byte over 127. In a UTF-8 locale it accepts them.

What it impacts

A password with a letter like ä passes apply from a UTF-8 shell, but the same config can fail from a root runner or unit with no locale, with the message "must be 8-128 printable characters", which is misleading.
Separately, 8 two-byte characters pass the "16+ characters" onion check.
Unknown: whether the control runner or boot units really run in the C locale; that needs a check of the unit environment on a machine.

How I found it

Reproduced the locale split with GNU grep on a laptop: pässwörd-12345 is rejected under LC_ALL=C and accepted under en_US.UTF-8 and C.UTF-8. The runner environment part is inferred.

Code references are from develop at 32d9834a. Checked for an existing issue: none found.

How important is it

P2-correctness: the same config gives different results depending on who runs apply.

Acceptance criteria

  • A test runs the validation with LC_ALL=C and with a UTF-8 locale on the same non-ASCII password and asserts the same verdict. It fails today.
  • The error message says what is accepted.

Possible solutions

  • Smallest: LC_ALL=C grep -qE '^[ -~]{8,128}$' plus the same fix for the byte count, and say "ASCII" in the message.
  • Alternative: accept UTF-8 explicitly and count characters in both checks.

Activity

  1. added this to the v2.0.5 milestone on Nov 24, 2026
  2. added
    bug
    setup
    P2-correctness
    on Nov 24, 2026
  3. added
    operator-hold
    on Nov 24, 2026
  4. pithead-developer commented on Nov 24, 2026

    @pithead-developer
    ContributorAuthor

    Scope of the fix in #4484, and one decision it leaves open.

    Fixed: the 8 to 128 check and the repeated-character check now count characters the same way in every locale.

    Left as it is: the onion floor of 16 still counts bytes, so 8 two-byte letters still pass it. That check never depended on the locale. Counting characters there would refuse an existing install whose onion password has 8 to 15 non-ASCII letters: apply would stop until the operator changes the password. Whether to tighten it is a decision, with that upgrade cost.

    Found on the way: a password longer than 72 bytes passes validation and then fails at hashing with a message about Docker. I am filing it separately.

  5. removed
    operator-hold
    on Nov 24, 2026
  6. pithead-developer commented on Nov 24, 2026

    @pithead-developer
    ContributorAuthor

    Note for the next round on #4484, from the author of its first commit. Tested on a copy of head d78bbf11 in the Linux test image (jq 1.7.1).

    • Control characters (first finding). The jq password check alone accepts them, but they never reach it. parse_and_validate_config first calls validate_config_control_characters (lib/pithead/22a-config-document.sh), which refuses any config string that matches [[:cntrl:]]. A tab, 0x01, 0x7f and U+0085 inside an otherwise valid password are refused under LC_ALL=C and LC_ALL=C.UTF-8, with the "containing a control character" message. No jq change is needed. Not refused: format characters that are not controls, such as U+2028.
    • No test (second finding). Real. The patch adds the four control-character cases, a CJK password and the 8 and 128 bounds to dash_pw_cases. The new label uses a loop variable, so the patch also adds its row to tests/stack/lib/verdict-label-determinism.sh; without that row stack block 1 fails.
    • Message (third finding). The patch extends it to "... 8–128 printable characters (letters of any language are accepted) with no double-quotes." Its start is unchanged, so existing assertions still match.

    Result: the fragment gives PASS=43 FAIL=0. With the control check removed from both of its callers it gives PASS=35 FAIL=8, and all eight are the new cases.

    Tested patch, applies to head d78bbf1
    --- a/lib/pithead/28-parse-and-validate-config.sh
    +++ b/lib/pithead/28-parse-and-validate-config.sh
    @@ -344,7 +344,7 @@
                 error "dashboard.auth.username must be 1–64 chars of letters, digits, and . _ @ - (got \"$DASHBOARD_AUTH_USER\")."
             fi
             if ! printf '%s' "$dash_pw" | jq -Rse 'length >= 8 and length <= 128 and (contains("\"") | not)' >/dev/null; then
    -            error "dashboard.auth.password must be 8–128 printable characters with no double-quotes."
    +            error "dashboard.auth.password must be 8–128 printable characters (letters of any language are accepted) with no double-quotes."
             fi
             DASHBOARD_AUTH_PW_FP=$(printf '%s' "$dash_pw" | sha256_hex)
             local prev_fp prev_hash
    --- a/tests/stack/dashboard/test-onion-apply-password.sh
    +++ b/tests/stack/dashboard/test-onion-apply-password.sh
    @@ -20,8 +20,20 @@
         assert_contains "7 characters are rejected, whatever their byte count" "$out" "dashboard.auth.password must be 8–128 printable characters"
         out=$(dash_pw_apply "$loc" "$(printf 'a%.0s' $(seq 129))")
         assert_contains "129 characters are rejected" "$out" "dashboard.auth.password must be 8–128 printable characters"
    +    assert_contains "the message says non-ASCII letters are accepted" "$out" "letters of any language are accepted"
         out=$(dash_pw_apply "$loc" 'pässwörd-"12345')
         assert_contains "a double-quote is rejected" "$out" "dashboard.auth.password must be 8–128 printable characters"
    +    local ctl
    +    for ctl in '\t' '\001' '\177' '\302\205'; do
    +        out=$(dash_pw_apply "$loc" "$(printf "pässwörd${ctl}12345")")
    +        assert_contains "control character $ctl is rejected" "$out" "containing a control character"
    +    done
    +    out=$(dash_pw_apply "$loc" "密码密码密码密码密码")
    +    assert_not_contains "CJK password is accepted" "$out" "dashboard.auth.password must be"
    +    out=$(dash_pw_apply "$loc" "$(printf 'a%.0s' $(seq 8))")
    +    assert_not_contains "8 characters are accepted" "$out" "dashboard.auth.password must be"
    +    out=$(dash_pw_apply "$loc" "$(printf 'ä%.0s' $(seq 128))")
    +    assert_not_contains "128 characters are accepted" "$out" "dashboard.auth.password must be"
         out=$(dash_pw_apply "$loc" "$(printf 'ä%.0s' $(seq 16))" onion)
         assert_contains "onion: 16 identical two-byte characters are a repeated character" "$out" "single repeated character"
     }
    --- a/tests/stack/lib/verdict-label-determinism.sh
    +++ b/tests/stack/lib/verdict-label-determinism.sh
    @@ -158,6 +158,7 @@
     test-doctor.sh|ip
     test-grub-hugepages.sh|mode
     test-grub-hugepages.sh|param
    +test-onion-apply-password.sh|ctl
     test-payout-wallet-pairs.sh|chain
     test-payout-wallet-pairs.sh|field
     test-payout-wallet-pairs.sh|k
  7. pithead-developer commented on Nov 27, 2026

    @pithead-developer
    ContributorAuthor

    Blocked on #4502. Blocked on pithead#4502 for the tier4-e2e proof of PR #4484. Job 1103@8e99b9029e31a2c43af60919ac42bfc959d5876d (submitted as 4632) ran 272 pass, 4 fail, 9 skip. The four failing rows are backup restore round-trip succeeded, pre-move dashboard rows readable, encrypted restore after config-reset starts the stack and restore original config and healthy stack. The log's own error on that path is "This backup's configuration was written by pithead 2.0.4; this machine runs 2.0.3": the base develop-v2.0.5 carries VERSION 2.0.3 while the bench runs 2.0.4, which is #4502's known mismatch. The rows that exercise the dashboard password passed. I have not confirmed that pre-move dashboard rows readable is a cascade of the version error, because it was logged earlier in the run than that error; I will check it on the rerun. Everything else is finished: the fix, tests, docs, builder, and green GitHub checks on this head. I commented on the PR and put the unedited evidence block in its body. Once the operator closes #4502, merge the base in and rerun the targeted job. Downtime history was unavailable, so I did not classify the failure as a bench outage and filed nothing on bench-ci.

    The runner resumes this issue when that one closes.

  8. added
    blocked
    on Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2-correctnessblockedbugsetup

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions