Jump to content

Sudo make me a sandwhich - A bug lurking for 12 years gives attackers root on every major Linux distro

Lightwreather

Summary

Linux users on Tuesday got a major dose of bad news—a 12-year-old vulnerability in a system tool called Polkit gives attackers unfettered root privileges on machines running any major distribution of the open source operating system.

Major Linux distributors have released patches for the vulnerability, and security professionals are strongly urging administrators to prioritize installing the patch. Those who can’t patch immediately should use the chmod 0755 /usr/bin/pkexec command to remove the SUID-bit from pkexec, which prevents it from running as a binary.

 

Quotes

Quote

Previously called PolicyKit, Polkit manages system-wide privileges in Unix-like OSes. It provides a mechanism for nonprivileged processes to safely interact with privileged processes. It also allows users to execute commands with high privileges by using a component called pkexec, followed by the command.

Since 2009, pkexec has contained a memory-corruption vulnerability that people with limited control of a vulnerable machine can exploit to escalate privileges all the way to root. Exploiting the flaw is trivial and, by some accounts, 100 percent reliable. Attackers who already have a toehold on a vulnerable machine can abuse the vulnerability to ensure a malicious payload or command runs with the highest system rights available. PwnKit, as researchers are calling the vulnerability, is also exploitable even if the Polkit daemon itself isn’t running.

PwnKit was discovered by researchers from security firm Qualys in November and was disclosed on Tuesday after being patched in most Linux distributions.

In an email, Qualys Director of Vulnerability Threat Research Bharat Jogi wrote:

Quote

The most likely attack scenario is from an internal threat where a malicious user can escalate from no privileges whatsoever to full root privileges. From an external threat perspective, if an attacker has been able to gain foothold on a system via another vulnerability or a password breach, that attacker can then escalate to full root privileges through this vulnerability.

Jogi said exploits require local authenticated access to the vulnerable machine and can't be run remotely without such authentication.

For now, Qualys isn’t releasing proof-of-concept exploit code out of concern the code will prove more of a boon to black hats than to defenders. Researchers said that it’s only a matter of time until PwnKit is exploited in the wild.

“We expect that the exploit will become public soon and that attackers will start exploiting it—this is especially dangerous for any multi-user system that allows shell access to users,” Bojan Zdrnja, a penetration tester and a handler at SANS, wrote. The researcher said he successfully recreated an exploit that worked on a machine running Ubuntu 20.04.

Major Linux distributors have released patches for the vulnerability, and security professionals are strongly urging administrators to prioritize installing the patch. Those who can’t patch immediately should use the chmod 0755 /usr/bin/pkexec command to remove the SUID-bit from pkexec, which prevents it from running as a binary.

 

My thoughts

Oh bother. As if Loj4J and a number of other cross-platform backdoors weren't enough. Well, thankfully, this is relatively lower risk as one needs to have an authenticated access to the machine (Would SSH access count toward this? 'cause if so, that makes this markedly more frightening). Thankfully, patches and work-arounds have been released and so, if you run a Linux server or PC, I do recommend you patch it.

 

Sources

Arstechnica

Qualys

Sesin

SANS

"A high ideal missed by a little, is far better than low ideal that is achievable, yet far less effective"

 

If you think I'm wrong, correct me. If I've offended you in some way tell me what it is and how I can correct it. I want to learn, and along the way one can make mistakes; Being wrong helps you learn what's right.

Link to comment
Share on other sites

Link to post
Share on other sites

7 minutes ago, J-from-Nucleon said:

Would SSH access count toward this? 'cause if so, that makes this markedly more frightening

I think so; from my experience getting SSH access is basically logging into the OS as the specified user.

e.g. "authenticated access".

I wonder if iOS uses this daemon, and if so, could it be used for a jailbreak exploit?

elephants

Link to comment
Share on other sites

Link to post
Share on other sites

I bet there's more of these out there that's already discovered but nobody is reporting them.

Specs: Motherboard: Asus X470-PLUS TUF gaming (Yes I know it's poor but I wasn't informed) RAM: Corsair VENGEANCE® LPX DDR4 3200Mhz CL16-18-18-36 2x8GB

            CPU: Ryzen 9 5900X          Case: Antec P8     PSU: Corsair RM850x                        Cooler: Antec K240 with two Noctura Industrial PPC 3000 PWM

            Drives: Samsung 970 EVO plus 250GB, Micron 1100 2TB, Seagate ST4000DM000/1F2168 GPU: EVGA RTX 2080 ti Black edition

Link to comment
Share on other sites

Link to post
Share on other sites

Good grief at this point if feels like you only have two choices of security air gap the system or just leave the thing wide open for everyone

Link to comment
Share on other sites

Link to post
Share on other sites

32 minutes ago, J-from-Nucleon said:

Would SSH access count toward this?

Most likely yes, although the article mentions a "local" shell. There is virtually no difference in terms of access between an SSH remote shell and a local login so I doubt it wouldn't work.

28 minutes ago, FakeKGB said:

I wonder if iOS uses this daemon, and if so, could it be used for a jailbreak exploit?

iOS is not based on Linux.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

That's all I need to do, right? I can't patch stuff right now

662528060_Screenshot2022-01-26at18_47_02.png.8ad8b396378b798187856d3ac6ce9a07.png

macOS doesn't have pkexec so I assume it's not affected there

🙂

Link to comment
Share on other sites

Link to post
Share on other sites

Well at least this one is just a privilege escalation...so that's a good thing.  You'd effectively need already executable access already

3735928559 - Beware of the dead beef

Link to comment
Share on other sites

Link to post
Share on other sites

Was about to post this. Glad to see someone else is on top of things.

PLEASE QUOTE ME IF YOU ARE REPLYING TO ME

Desktop Build: Ryzen 7 2700X @ 4.0GHz, AsRock Fatal1ty X370 Professional Gaming, 48GB Corsair DDR4 @ 3000MHz, RX5700 XT 8GB Sapphire Nitro+, Benq XL2730 1440p 144Hz FS

Retro Build: Intel Pentium III @ 500 MHz, Dell Optiplex G1 Full AT Tower, 768MB SDRAM @ 133MHz, Integrated Graphics, Generic 1024x768 60Hz Monitor


 

Link to comment
Share on other sites

Link to post
Share on other sites

3 hours ago, Sauron said:

Most likely yes, although the article mentions a "local" shell. There is virtually no difference in terms of access between an SSH remote shell and a local login so I doubt it wouldn't work.

There is as far as polkit is concerned, assuming its configured properly. SSHD will have its own rules and polkit can tell the difference between a local shell or a remote one as it knows the current TTY PID matches the PID of an app it authorised.

 

Whether this affects anything functionally, honestly can't say. I would guess that once polkit has granted authorisation it shouldn't matter what the user does to polkit, its job is finished.

 

Edit - Remember though, SSH adds an extra barrier to entry by default since a low ranking user with local access to do a job probably won't have access to an SSH TTY at all.

Main Rig:-

Ryzen 7 3800X | Asus ROG Strix X570-F Gaming | 16GB Team Group Dark Pro 3600Mhz | Corsair MP600 1TB PCIe Gen 4 | Sapphire 5700 XT Pulse | Corsair H115i Platinum | WD Black 1TB | WD Green 4TB | EVGA SuperNOVA G3 650W | Asus TUF GT501 | Samsung C27HG70 1440p 144hz HDR FreeSync 2 | Ubuntu 20.04.2 LTS |

 

Server:-

Intel NUC running Server 2019 + Synology DSM218+ with 2 x 4TB Toshiba NAS Ready HDDs (RAID0)

Link to comment
Share on other sites

Link to post
Share on other sites

13 hours ago, Master Disaster said:

SSHD will have its own rules and polkit can tell the difference between a local shell or a remote one as it knows the current TTY PID matches the PID of an app it authorised.

Yeah that's true, I wonder if that's enough to break the exploit.

13 hours ago, Master Disaster said:

Remember though, SSH adds an extra barrier to entry by default since a low ranking user with local access to do a job probably won't have access to an SSH TTY at all.

True, although an external attacker could social engineer you out of your password - if you're a user with high enough clearance to use SSH that's not great to begin with but it's significantly worse if you can then use the shell to gain root access. I suppose SSH adds the possibility of someone outside the premises gaining root access, so remember kids: use public key authentication and disable password logins.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

39 minutes ago, Sauron said:

 so remember kids: use public key authentication and disable password logins.

Also disable port 21, move SSH/SFTP from port 22 and move RDP from port 3389, these are the first ports any hacker will look at when trying to get in (other than 80 that is).

 

39 minutes ago, Sauron said:

Yeah that's true, I wonder if that's enough to break the exploit.

I don't think it would, polkit is used to determine rights to run and access things, AFAIK once its granted you the rights to run a shell it really doesn't care if if the shell escalates itself after the fact though its possible there's some other functionality I'm not aware of.

 

If that were a thing the polkit would break sudo su since the only people able to login as root at all would need root permissions at login, I think 🙃

Main Rig:-

Ryzen 7 3800X | Asus ROG Strix X570-F Gaming | 16GB Team Group Dark Pro 3600Mhz | Corsair MP600 1TB PCIe Gen 4 | Sapphire 5700 XT Pulse | Corsair H115i Platinum | WD Black 1TB | WD Green 4TB | EVGA SuperNOVA G3 650W | Asus TUF GT501 | Samsung C27HG70 1440p 144hz HDR FreeSync 2 | Ubuntu 20.04.2 LTS |

 

Server:-

Intel NUC running Server 2019 + Synology DSM218+ with 2 x 4TB Toshiba NAS Ready HDDs (RAID0)

Link to comment
Share on other sites

Link to post
Share on other sites

Well, there goes the theory that open source is this flawless miracle and that being open ensures it's safer than "closed source" because surely someone will find and report it. If that hasn't happened for 12 years on something that causes total privilege escalation, that's a big auch.

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, RejZoR said:

Well, there goes the theory that open source is this flawless miracle and that being open ensures it's safer than "closed source" because surely someone will find and report it. If that hasn't happened for 12 years on something that causes total privilege escalation, that's a big auch.

False equivalency. If SUDO was closed source then this bug wouldn't have been discovered when it did and would still be possible right now.

 

Neither system is perfect, both have their benefits and disadvantages and anyone who seriously thinks OSS = less bugs doesn't understand how software works.

 

More chance of a bug being discovered =/= less bugs in the code to begin with.

Main Rig:-

Ryzen 7 3800X | Asus ROG Strix X570-F Gaming | 16GB Team Group Dark Pro 3600Mhz | Corsair MP600 1TB PCIe Gen 4 | Sapphire 5700 XT Pulse | Corsair H115i Platinum | WD Black 1TB | WD Green 4TB | EVGA SuperNOVA G3 650W | Asus TUF GT501 | Samsung C27HG70 1440p 144hz HDR FreeSync 2 | Ubuntu 20.04.2 LTS |

 

Server:-

Intel NUC running Server 2019 + Synology DSM218+ with 2 x 4TB Toshiba NAS Ready HDDs (RAID0)

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, RejZoR said:

Well, there goes the theory that open source is this flawless miracle and that being open ensures it's safer than "closed source" because surely someone will find and report it. If that hasn't happened for 12 years on something that causes total privilege escalation, that's a big auch.

An exploitable bug being there for the past 12 years doesn't exclusively mean that for the past 12 year it was exploited, it means it's been written that way 12 years ago with nobody noticing it for that long

If it's been used nefariously in that period that's up for debate, but at least the moment someone discovered it got patched ASAP, unlike many closed source SW houses who rather wait for it to become news before even thinking of assigning someone to patch it.

One day I will be able to play Monster Hunter Frontier in French/Italian/English on my PC, it's just a matter of time... 4 5 6 7 8 9 years later: It's finally coming!!!

Phones: iPhone 4S/SE | LG V10 | Lumia 920 | Samsung S24 Ultra

Laptops: Macbook Pro 15" (mid-2012) | Compaq Presario V6000

Other: Steam Deck

<>EVs are bad, they kill the planet and remove freedoms too some/<>

Link to comment
Share on other sites

Link to post
Share on other sites

16 minutes ago, Master Disaster said:

False equivalency. If SUDO was closed source then this bug wouldn't have been discovered when it did and would still be possible right now.

 

Neither system is perfect, both have their benefits and disadvantages and anyone who seriously thinks OSS = less bugs doesn't understand how software works.

 

More chance of a bug being discovered =/= less bugs in the code to begin with.

It's also false equivalency to assume it wouldn't be discovered if it was closed source. If it was written this way 12 years ago and being so open, one would assume someone would spot the issue by now in all this time. Yet that wasn't the case.

Link to comment
Share on other sites

Link to post
Share on other sites

8 minutes ago, RejZoR said:

It's also false equivalency to assume it wouldn't be discovered if it was closed source. If it was written this way 12 years ago and being so open, one would assume someone would spot the issue by now in all this time. Yet that wasn't the case.

Fair enough, as I said, neither system is perfect but it is true that more eyes on code means higher chance of bug being found.

 

The other consideration is the fact that people can't just view the source of closed source projects which means a lower chance of bugs being discovered at all. That's called security by obscurity and its never a good idea.

 

Edit - See EternalBlue for reference

Main Rig:-

Ryzen 7 3800X | Asus ROG Strix X570-F Gaming | 16GB Team Group Dark Pro 3600Mhz | Corsair MP600 1TB PCIe Gen 4 | Sapphire 5700 XT Pulse | Corsair H115i Platinum | WD Black 1TB | WD Green 4TB | EVGA SuperNOVA G3 650W | Asus TUF GT501 | Samsung C27HG70 1440p 144hz HDR FreeSync 2 | Ubuntu 20.04.2 LTS |

 

Server:-

Intel NUC running Server 2019 + Synology DSM218+ with 2 x 4TB Toshiba NAS Ready HDDs (RAID0)

Link to comment
Share on other sites

Link to post
Share on other sites

20 minutes ago, Master Disaster said:

Fair enough, as I said, neither system is perfect but it is true that more eyes on code means higher chance of bug being found.

 

The other consideration is the fact that people can't just view the source of closed source projects which means a lower chance of bugs being discovered at all. That's called security by obscurity and its never a good idea.

 

Edit - See EternalBlue for reference

I mean, I'd believe that and while I'm aware whole OS has quite a lot of code and most of it no one looks at for years, still, it throws away the notion that just because it's open source it's magically more secure or better because more eyes "might" spot more. It affects all distros which means all the thousands of people working on Linux projects missed this for 12 years. I'm not saying Windows is inherently better either, this is just dismissing or at least placing people who overhype Linux as perfect and secure to solid ground that it's just as flawed.

 

Which is why I always say and for which I was dismissed by many in some other thread, update your software, be it Windows, Linux, Android, iOS or something else. Security updates are there for a reason and insisting on some old versions is a very bad practice.

Link to comment
Share on other sites

Link to post
Share on other sites

5 hours ago, RejZoR said:

I mean, I'd believe that and while I'm aware whole OS has quite a lot of code and most of it no one looks at for years, still, it throws away the notion that just because it's open source it's magically more secure or better because more eyes "might" spot more. It affects all distros which means all the thousands of people working on Linux projects missed this for 12 years. I'm not saying Windows is inherently better either, this is just dismissing or at least placing people who overhype Linux as perfect and secure to solid ground that it's just as flawed.

I can argue that open source makes it less secure because everyone thinks someone else looked at the code so they don't need to check it themselves.  And whoever wrote it in the first place may have been half drunk on the weekend and not really given a shit about it.

Workstation:  14700nonk || Asus Z790 ProArt Creator || MSI Gaming Trio 4090 Shunt || Crucial Pro Overclocking 32GB @ 5600 || Corsair AX1600i@240V || whole-house loop.

LANRig/GuestGamingBox: 9900nonK || Gigabyte Z390 Master || ASUS TUF 3090 650W shunt || Corsair SF600 || CPU+GPU watercooled 280 rad pull only || whole-house loop.

Server Router (Untangle): 13600k @ Stock || ASRock Z690 ITX || All 10Gbe || 2x8GB 3200 || PicoPSU 150W 24pin + AX1200i on CPU|| whole-house loop

Server Compute/Storage: 10850K @ 5.1Ghz || Gigabyte Z490 Ultra || EVGA FTW3 3090 1000W || LSI 9280i-24 port || 4TB Samsung 860 Evo, 5x10TB Seagate Enterprise Raid 6, 4x8TB Seagate Archive Backup ||  whole-house loop.

Laptop: HP Elitebook 840 G8 (Intel 1185G7) + 3080Ti Thunderbolt Dock, Razer Blade Stealth 13" 2017 (Intel 8550U)

Link to comment
Share on other sites

Link to post
Share on other sites

37 minutes ago, AnonymousGuy said:

because everyone thinks someone else looked at the code so they don't need to check it themselves

Thats a pretty unrealistic assumption, maybe novice beginners but pros wont skip that step. It could (and usually does) bite them in the butt in the long run....

Link to comment
Share on other sites

Link to post
Share on other sites

On 1/26/2022 at 11:27 AM, williamcll said:

I bet there's more of these out there that's already discovered but nobody is reporting them.

We know for a fact that government agencies know about exploits that they keep secret.

 

We're all living in a fool's paradise.

Link to comment
Share on other sites

Link to post
Share on other sites

On 1/26/2022 at 5:11 PM, FakeKGB said:

 

I wonder if iOS uses this daemon, and if so, could it be used for a jailbreak exploit?

macOS has it’s authorisation database, and the raw configs for it (/System/Library/Security/authorization.plist) before being turned in to an SQLite database is remarkably similar to Polkit policy files the last time I compared them around 4 years ago, so I’ve always assumed there was either a branch of polkit at some point or common ancestor to both involved.

 

I can’t remember for sure if iOS has the same or similar system, I don’t do much iOS target development. 

 

As far as I understand this particular bug the flaw is in the pkexec (no real equivalent binary exists in macOS) code rather than the core of polkit, so I doubt Apple are affected if they even did use any polkit code historically. 
 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×