-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Version the issue has been seen with
Used distribution
Ubuntu 20.04 LTS
Expected behaviour you didn't see
loginctl show-user $(id -u)UID=1000 GID=1000 Name=0x2b3bfa0 Timestamp=Sat 2020-05-30 23:37:28 CEST TimestampMonotonic=405537243 RuntimePath=/run/user/1000 Service=user@1000.service Slice=user-1000.slice Display=2 State=active Sessions=16 2 IdleHint=no IdleSinceHint=1590909501087020 IdleSinceHintMonotonic=5138907865 Linger=no
Unexpected behaviour you saw
loginctl show-user $(id -u)Failed to get user: User ID 1000 is not logged in or lingering
Steps to reproduce the problem
- Create a user whose name starts with
0xor0X(exempli gratia:0x2b3bfa0).- Log in with that user name and run
loginctl show-user $(id -u).- Check the unexpected behavior above.
Affected code
Line 717 in d904afc
| if (parse_uid(u, NULL) >= 0) /* Something that parses as numeric UID string is valid exactly when the |
Line 52 in d904afc
| r = safe_atou32(s, &uid); |
systemd/src/basic/parse-util.h
Line 53 in d904afc
| return safe_atou32_full(s, 0, (unsigned*) ret_u); |
systemd/src/basic/parse-util.h
Line 49 in d904afc
| return safe_atou_full(s, base, (unsigned*) ret_u); |
systemd/src/basic/parse-util.c
Line 375 in d904afc
| l = strtoul(s, &x, base); |
Problem description
As per the strtoul(3) man page, when the base argument is 0, the string can also be interpreted as an hexadecimal or octal number:
If
baseis zero or 16, the string may then include a "0x" prefix, and the number will be read in base 16; otherwise, a zerobaseis taken as 10 (decimal) unless the next character is '0', in which case it is taken as 8 (octal).
Vulnerability
CVE-2020-13776: systemd through v245 mishandles numerical usernames such as ones composed of decimal digits or 0x followed by hex digits, as demonstrated by use of root privileges when privileges of the 0x0 user account were intended.
Related issues