Submitted via IRC for TheMightyBuzzard
A bug in Linux's systemd init system causes root permissions to be given to services associated with invalid usernames, and while this could pose a security risk, exploitation is not an easy task.
A developer who uses the online moniker "mapleray" last week discovered a problem related to systemd unit files, the configuration files used to describe resources and their behavior. Mapleray noticed that a systemd unit file containing an invalid username – one that starts with a digit (e.g. "0day") – will initiate the targeted process with root privileges instead of regular user privileges.
Systemd is designed not to allow usernames that start with a numeric character, but Red Hat, CentOS and other Linux distributions do allow such usernames.
"It's systemd's parsing of the User= parameter that determines the naming doesn't follow a set of conventions, and decides to fall back to its default value, root," explained developer Mattias Geniar.
While this sounds like it could be leveraged to obtain root privileges on any Linux installation using systemd, exploiting the bug in an attack is not an easy task. Geniar pointed out that the attacker needs root privileges in the first place to edit the systemd unit file and use it.
[...] Systemd developers have classified this issue as "not-a-bug" and they apparently don't plan on fixing it. Linux users are divided on the matter – some believe this is a vulnerability that could pose a serious security risk, while others agree that a fix is not necessary.
See, this is why we can't have nice init systems.
Source: http://www.securityweek.com/linux-systemd-gives-root-privileges-invalid-usernames
(Score: 2) by unauthorized on Tuesday July 04 2017, @12:29AM (12 children)
Unit files are usually hand-written files installed along with the distribution or a package. In the typical use-case they only change with package updates unless an admin manually edits them.
(Score: 3, Interesting) by Arik on Tuesday July 04 2017, @12:53AM (11 children)
But how do they figure it's not a bug? Is there any conceivable, theoretical case where this behavior is expected and desired?
If laughter is the best medicine, who are the best doctors?
(Score: 5, Insightful) by vux984 on Tuesday July 04 2017, @01:02AM (5 children)
This Exactly.
Throw/log an error and don't start the process should be the default behavior. Starting as root if the user name is invalid is beyond the pale.
(Score: 2) by kaszz on Tuesday July 04 2017, @02:59AM (1 child)
No log as it binary.. remember? total clusterfuck. Shit like this is what forces administrators to do late nighter to clean up after the braindamage writes code that scriptkids use. (which usually some pointy haired type decided must be used..)
(Score: 2) by butthurt on Tuesday July 04 2017, @08:57PM
> No log as it binary.. remember?
The binary "journal" is a log.
(Score: 2) by SDRefugee on Tuesday July 04 2017, @01:06PM (1 child)
Sounds like something that bunch of psychos in Redmond, Washington would do...
America should be proud of Edward Snowden, the hero, whether they know it or not..
(Score: 0) by Anonymous Coward on Tuesday July 04 2017, @07:48PM
Software requirements specification met!
(Score: 2) by Thexalon on Tuesday July 04 2017, @07:51PM
At the very least, if I were going to default to anything at all, I'd default to "nobody".
The only thing that stops a bad guy with a compiler is a good guy with a compiler.
(Score: 3, Interesting) by Jesus_666 on Tuesday July 04 2017, @05:13PM (3 children)
Simple: The observed behavior is in line with how systemd was designed and therefore obviously correct. Since usernames can't begin with a digit and every major Linux distribution has been breaking the standard for years before it was even conceived it's not systemd's problem but that of everyone else. The fix to that problem is obvious: All distros should ban numeric usernames immediately (this is security-relevant, after all) and everyone who uses them should rename the offending users before installing any package updates. Also, they should be ashamed of themselves for being bad at Unix.
At least that's how I imagine the systemd team sees it.
(Score: 2) by vux984 on Tuesday July 04 2017, @06:20PM (2 children)
Probably. But EVEN if that's how they see it they STILL have a bug.
If the systemd team wants to enforce a policy of no usernames that start with a digit, fine, that would be in keeping with their arrogance and ego... but at the very least they should properly reject those credentials as invalid.
The failure mode for attempting to run a process with "invalid" credentials should NEVER be "run it as root".
(Score: 3, Touché) by maxwell demon on Tuesday July 04 2017, @06:43PM (1 child)
Nah, if Poettering implements this that way, it's obviously exactly the right thing. To follow his lead, I'm going to patch login with the following code:
SCNR :-)
The Tao of math: The numbers you can count are not the real numbers.
(Score: 2) by DECbot on Wednesday July 05 2017, @04:40PM
I understand it to be a little more complex than that...
cats~$ sudo chown -R us /home/base
(Score: 3, Interesting) by FatPhil on Wednesday July 05 2017, @08:03AM
OK it requires social engineering to get people to install/try/uninstall, but still, I'd put that as a "fix right now" kind of bug. The brute force "unrecognised user name" = "don't run" solution sounds (a) like a fix to the bug; and (b) like what would have been the sensible default in the first place. If that's more than a trivial 10 line change to the code (I can barely imagine it being more than 3), then it's a code base that needs nuking from orbit.
Great minds discuss ideas; average minds discuss events; small minds discuss people; the smallest discuss themselves