Least Privilege for Ubuntu 24.04 Standard User

Victor M

Level 12
Thread author
Verified
Top Poster
Well-known
Oct 3, 2022
576
Hi Everyone,

A standard user in Ubuntu does not automatically obey the least privilege principle.

You have to do 2 things:

a. Deny sudo. So that the user cannot use sudo to accomplish anything. In the admin account, run 'sudo visudo' and add in this line: ' user2 ALL=(ALL) !ALL ', replace the word user2 with the account name in question.

b. Gnome uses polkit to grant privileges, and it has additional action.id's which has to be controlled.
Create a file of any name inside /usr/share/polkit-1/rules.d/ . Include these lines:

polkit.addRule(function(action, subject) {
if ( ( action.id == "org.gtk.vfs.file-operations-helper" ||
action.id == "org.gtk.vfs.file-operations" ||
action.id == "org.freedesktop.policykit.exec"
)
&&
subject.user == "user2") {
return polkit.Result.NO; // Deny actions for user user2
}
});

This rule will forbid user2 from editing root owned configuration files, even if the admin password is compromised. And it will forbid user2 from accessing additional privileges.

If you wish to be extra cautious, just remove all the action.id lines and blanket ban user2 from doing anything that requires consulting polkit. This will ban things like configuring vpn's using Gnome > Settings for the account. And it will ban many other things, but surfing will still work. And, it will slow down Gnome. The primary activity of most users is to surf.
 
Last edited:

Bot

AI-powered Bot
Apr 21, 2016
4,340
Hi,

Thank you for your detailed explanation on how to apply the principle of least privilege to a standard user account in Ubuntu 24.04. This is indeed a great way to enforce stricter security measures on a system. Following these steps will certainly limit the abilities of a standard user, reducing the potential for accidental or intentional misuse of elevated privileges.
 

Victor M

Level 12
Thread author
Verified
Top Poster
Well-known
Oct 3, 2022
576
A little background on Least Privilege.

Least Privilege by definition means configuring your account to be able only to do the necessary things for daily use. So that means it should run the necessary apps like email clients and browsers and subjectively necessary apps, but nothing else. And that definitely does not include access to admin programs, package installers and the ability to change configuration files. Ubuntu, like Wndows, is designed for convenience, and your first account can use sudo to do admin things. You may think sudo offers some protection because it requires your password to execute an admin command. But when you think security, and become more aware of different ways that an attack and compromise can happen, you will arrive at the conclusion that it is better to have no admin rights accessible in your daily account. That way, should you be compromised, the exploit/attacker will be trapped in an account that can do nothing.Vulnerabilities happen - daily. Every major browser has multiple CVE registered security holes discovered with every single version ever released. They fix them but develop new features which adds another round of new security holes, and it just continues on - predictably. Your browser is a good example, particularly because you use it every day, and it is almost always running - you are always exposed. All it takes is a visit to a compromised web site, you will never notice any immediate effect. You may say you have this great anti-malware, but detection methods grow old and malware are custom coded to evade techniques used by popular protection. That's why it is a cat and mouse game. Your protections improve, and the attackers improve in turn o defeat them. So, the ultimate defense is to rely on the Least Privilege principle. Be uncompromisable. If your account can't access admin things, the attackers have little chance to take over the machine. Least Privilege is not infallible, if the attacker can reach outside of an account and modify a startup script of an admin account, for example, then she may have a chance. This attack approach is applicable to Linux and also to Windows. But it is only a 'possible' way, the opportunity may not be available.If the admin has not mistakenly configured her startup script to be world read/writable then there will not be an opening. Another way Least Privilege may fail is when there is a vulnerability in an app and the app has system wide privileges. Even Apparmor cannot hold against such a vulnerability. But there are very few of these kinds of apps - your browser is certainly not one of them.

So I have explained what the principle is, why it works, and even how it may be circumvented. It should be evident to you that it is in your best interest to apply the Least Privilege principle. It is a foundation security concept.
 
Last edited:

About us

  • MalwareTips is a community-driven platform providing the latest information and resources on malware and cyber threats. Our team of experienced professionals and passionate volunteers work to keep the internet safe and secure. We provide accurate, up-to-date information and strive to build a strong and supportive community dedicated to cybersecurity.

User Menu

Follow us

Follow us on Facebook or Twitter to know first about the latest cybersecurity incidents and malware threats.

Top