]> git.ipfire.org Git - thirdparty/shadow.git/commit
lib/chkname.c, src/: Strictly disallow really bad names
authorAlejandro Colomar <alx@kernel.org>
Mon, 23 Dec 2024 10:06:33 +0000 (11:06 +0100)
committerSerge Hallyn <serge@hallyn.com>
Fri, 26 Dec 2025 04:40:55 +0000 (22:40 -0600)
commit25aea74226152305e43213372bb26057698b0a90
tree90ec488d5c7b6ac12df454c931f8c691dc307923
parent9f8cf3370447117538985f31d75cc0ffb49fb819
lib/chkname.c, src/: Strictly disallow really bad names

Some names are bad, and some names are really bad.  '--badname' should
only allow the mildly bad ones, which we can handle.  Some names are too
bad, and it's not possible to deal with them.  Reject them
unconditionally.

-  A leading '-' is too dangerous.  It breaks things like execve(2), and
   almost every command.

-  Spaces are used for delimiting lists of users and groups.

-  '"' is special in many languages, including the shell.  Having it in
   user names would be unnecessarily dangerous.

-  '#' is used for delimiting comments in several of our config files.
   Having it in usernames could result in incorrect configuration files.

-  "'" is special in many languages, including the shell.  Having it in
   user names would be unnecessarily dangerous.

-  ',' is used for delimiting lists of users and groups.

-  '/' is used for delimiting files, and thus could result in incorrect
   handling of users and groups.

-  ':' is the main delimiter in /etc/shadow and /etc/passwd.

-  ';' is special in many languages, including the shell.  Having it in
   user names would be unnecessarily dangerous.

There are other characters that we should disallow, but they need more
research to make sure we don't introduce regressions.  This set should
be less problematic.

Acked-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Chris Hofstaedtler <zeha@debian.org>
Cc: Marc 'Zugschlus' Haber <mh+githubvisible@zugschlus.de>
Cc: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/chkname.c
src/newusers.c
src/pwck.c
src/useradd.c
src/usermod.c