Skip to content

Credential fixes: empty passwords, line overflow, truncated names - #187

Merged
douglasmun merged 1 commit into
mainfrom
fix/credential-fixes
Oct 11, 2026
Merged

douglasmun merged 1 commit into
mainfrom
fix/credential-fixes

Conversation

@douglasmun

Copy link
Copy Markdown
Owner

PR 5 of 7 from the audit.

Fixes

  • F1 Empty passwords. passwd with two empty lines passed the compare (equal lengths) and stored the hash of ""; useradd took an empty password too. Now refused in the primitives (user_set_password, user_create → USER_ERR_EMPTY_PASSWORD), with readable messages in passwd/useradd.
  • F2 su password overflow. The su loop stopped reading once its 64-byte buffer was full. The rest of the line stayed in the keyboard ring and the kernel shell ran it as a command. Every credential prompt now goes through one read_line(), which always reads through to the newline.
  • F3 Login-name overflow. The same loop bug meant a 38-char login name logged in as its 31-char prefix, with the tail read as the password. Over-long names are now refused ("Login name too long"); the first-boot wizard does the same.
  • F4 Truncated duplicate. user_create ran the duplicate check on the full name and then stored it truncated. Kernel-shell useradd with a 32-char name therefore created a second account under an existing 31-char name. It now refuses (USER_ERR_NAME_TOO_LONG). Ring 3 never reached this: SYS_CRED already returns -ENAMETOOLONG at the boundary.
  • F5 False spray alert. The IDS spray table stores names truncated but compared them with strcmp against the full name. Three failed sus of one 40-char name read as 3 distinct names and raised a "Credential spray" alert. It now compares only the stored prefix.
  • /etc/issue no longer claims root/root and user/user exist. This is dead code: user_create_etc_structure() has no caller, so the harness has no leg for it.

Verification

verify/verify-cred-fixes.sh (one boot):

  • unfixed tree: FAIL, 6 assertions (F1 ×2, F2, F3, F4, F5)
  • fixed tree: PASS

The build stays -Werror clean.

🤖 Generated with Claude Code

- user_set_password()/user_create() refuse an empty password
  (USER_ERR_EMPTY_PASSWORD); passwd and useradd say so. Two empty lines
  used to "match" and store the hash of "".
- One read_line() for every credential prompt, always consuming the line
  to its newline. The su password and login-name loops stopped at a full
  buffer: an over-long su password's tail ran as a kernel-shell command,
  and an over-long login name logged in as its 31-char prefix with the
  tail read as the password. Over-long login/wizard names are refused.
- user_create() refuses names that do not fit (USER_ERR_NAME_TOO_LONG)
  instead of truncating after the full-name duplicate check, which let
  kernel-shell useradd store a second account under an existing name.
- IDS spray table compares only the stored (truncated) prefix, so one
  over-long name failing three times no longer reads as 3 distinct names.
- Drop /etc/issue's nonexistent root/root, user/user hints (dead code:
  user_create_etc_structure() has no caller).

verify/verify-cred-fixes.sh: unfixed tree FAIL (6 assertions), fixed PASS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@douglasmun
douglasmun merged commit 6e2b90a into main Oct 11, 2026
2 checks passed
@douglasmun
douglasmun deleted the fix/credential-fixes branch October 11, 2026 07:50
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.

1 participant