Files
tailscale/util
James Tucker 0ab8931ef7 util/osuser: validate 'id' input, reject corrupt getent passwd output
Before invoking 'id -Gz <user>', apply the same input validation as the
getent path (checkGetentInput), so a crafted username like '-u' can't be
interpreted as an option by the id command.

parseGetentUser now rejects multi-line (multiple or corrupted records)
output and validates the username and shell fields (no leading dashes,
control characters, or invalid UTF-8), the fields that are used to look
up and run a session. Also add the missing leading-dash regression test
for the 'id' call path.

The passwd format has no escaping — gecos sub-fields are comma-separated
— so an eighth colon-separated field means a stray colon in some field,
shifting every field after it: home parses as a gecos fragment and the
shell as the real home directory. Short records keep the existing
treatment (padded, with the default-shell fallback); over-long records
now fail closed like the other corrupt-output cases.

Updates tailscale/corp#50380

Signed-off-by: James Tucker <[email protected]>
(cherry picked from commit 3e61adf832)
2026-10-27 20:12:07 +00:00
..
2026-07-10 17:39:16 -07:00