Skip to content

!nshlib: Require explicit fixed login password at build time#3557

Open
Abhishekmishra2808 wants to merge 1 commit into
apache:masterfrom
Abhishekmishra2808:nsh-login-empty-password
Open

!nshlib: Require explicit fixed login password at build time#3557
Abhishekmishra2808 wants to merge 1 commit into
apache:masterfrom
Abhishekmishra2808:nsh-login-empty-password

Conversation

@Abhishekmishra2808

@Abhishekmishra2808 Abhishekmishra2808 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR is the nuttx-apps companion to apache/nuttx#19209, which adds the host mkpasswd tool and ROMFS /etc/passwd build integration. Here, runtime password handling moves from reversible TEA to one-way PBKDF2-HMAC-SHA256 using a modular crypt string stored in /etc/passwd. The change adds apps/crypto/pbkdf2 with a small self-contained SHA-256 and HMAC implementation (Mbed TLS PKCS5 is used when available), rewrites passwd_encrypt and passwd_verify with shared base64url helpers and password complexity checks, and adds pbkdf2_test for RFC 6070 SHA-256 vector coverage. The round-trip portion of that test is skipped automatically when the passwd file is read-only or when DEV_URANDOM is not enabled. NSH also changes the default fixed-login username to root and removes insecure fixed-login password defaults.

BREAKING CHANGE: TEA-encoded /etc/passwd entries no longer verify after this upgrade. Every entry must be regenerated with NSH passwd or useradd once both nuttx and nuttx-apps are updated. If CONFIG_NSH_LOGIN_FIXED=y is used, CONFIG_NSH_LOGIN_PASSWORD must be set explicitly in the board defconfig or menuconfig; there is no default password.

Impact

This change modifies existing password file behavior and is not backward compatible with TEA-encoded hashes. Users must regenerate stored passwords. The build flow itself is unchanged in nuttx-apps; the ROMFS build-time password prompt lives in the paired nuttx PR. Documentation updates are included in that nuttx PR rather than here.

Testing

Testing was done on sim:login with NSH console login against a build-time PBKDF2 hash, and login succeeded.
Login was also verified on ESP32-C3 using the esp32c3-devkit:login configuration over USB serial. Check- apache/nuttx#19209

pbkdf2_test passed the RFC 6070 SHA-256 vectors on sim:login, and the passwd encrypt/verify round-trip passed with a writable passwd path at /tmp/passwd, readonly disabled, and DEV_URANDOM enabled.
image

Comment thread nshlib/Kconfig Outdated
Comment thread nshlib/Makefile Outdated
Add apps/crypto/pbkdf2, migrate passwd encrypt/verify to modular crypt
format with complexity validation, share base64url helpers, and add
pbkdf2_test for RFC 6070 vector coverage.  Change NSH_LOGIN_USERNAME
default to root and remove fixed-login password defaults.

BREAKING CHANGE: TEA-encoded /etc/passwd entries no longer verify.
Regenerate each entry after upgrading.  Pair with the nuttx host mkpasswd
changes in apache/nuttx#19209.  When CONFIG_NSH_LOGIN_FIXED=y, set
CONFIG_NSH_LOGIN_PASSWORD in the board defconfig or menuconfig; there
is no default password.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
@Abhishekmishra2808 Abhishekmishra2808 force-pushed the nsh-login-empty-password branch from a7a4722 to 7ab3fa7 Compare June 25, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants