What is privilege escalation and how is it prevented in Linux?
Published on 2026-10-20 by frfrand
What is privilege escalation in Linux and how to avoid it: least privilege, restricted sudo, SUID binaries, service accounts, and access review.

Short answer: privilege escalation occurs when an account or process obtains more permissions than it should have, for example, going from a limited user to root. It is prevented with the principle of least privilege: applications with their own users, scoped sudo, reviewed file permissions, and updated packages.
In Linux it can mean going from a limited user to administrative capabilities or accessing resources that belong to another account.
It is an important topic because not all security problems start with full access. An attacker can first obtain reduced access and try to exploit errors to expand their control.
The hotel example
A guest receives a card that opens their room. That card should not allow entering other rooms, modifying reservations, or accessing the hotel's administration panel.
Privilege escalation is similar to making that card allow more than authorized. The problem is not always in the card: it can be in a defective lock, an employee who trusts too much, or a poorly defined policy.
On a server, those errors can correspond to file permissions, misconfigured services, or software vulnerabilities.
Normal users and root
Linux allows creating different accounts with separate permissions. The root account has broad administrative capabilities, so running the entire application with those privileges increases the consequences of a failure.
A web server that only needs to read certain files and listen on a configured port should not have unlimited access to the entire machine.
The principle of least privilege consists of granting what is necessary for a task, and nothing more.
What role does sudo play?
sudo allows authorized users to execute certain operations with elevated permissions. It is useful, but requires careful rules.
It is not a good idea to grant permissions for any command to a service account if it only needs to restart a specific process. It is also advisable to review which programs can be executed with special privileges.
Security is easily broken when someone thinks "add administrator permissions and done" every time an access error appears.
What are SUID and other mechanisms?
Linux has mechanisms to execute certain operations with specific capabilities or privilege contexts. They are necessary for different system functions, but an incorrect configuration can expand the risk surface.
In a defensive audit, it is advisable to review which programs really need those permissions and keep the packages that provide them updated. There is no need to turn that analysis into an exploitation guide to understand the risk.
An example with a web application
An API runs with an account that should only read its configuration and access a specific database. For convenience, someone changes the account so that all processes run as root.
If the application has a vulnerability, the potential damage increases enormously. Keeping the process under a limited user does not guarantee immunity, but it can reduce the scope of an incident.
It is also important not to store credentials for all clients in a place that any process can access.
How to reduce risk?
Apply security updates, separate service accounts, review file permissions, limit privileged commands, and use appropriate access controls.
In containers and VPS, isolation, system capabilities, and host configurations must also be considered. An incorrectly isolated application can affect more resources than intended.
Additionally, record administrative changes and periodically check who retains access. Temporary permissions that no one revokes end up becoming permanent.
How to detect a dangerous configuration?
A defensive example consists of checking whether an application uses the root account unnecessarily, whether a sensitive directory can be modified by inappropriate users, or whether an automation has overly broad credentials.
Not every elevated permission is a vulnerability: many legitimate operations require administration. The goal is that each capability has a clear reason and proportionate controls.
What about ArduMaker?
In ArduMaker, a Company admin can create Linux users on a VPS with their own private home folder and optional sudo, and remove the sudo later. A Company Member uses the terminal with their own Linux user, not as root. Applications deployed from GitHub run by default with a Linux user specific to each app and not as root, unless their deployment configuration requests it. And the VPS is an unprivileged LXD container: the root inside is not root of the physical server.
The infrastructure facilitates that separation, but permission design remains the responsibility of those who operate the projects.
To remember: privilege escalation means obtaining undue capabilities. Reducing privileges before an incident usually limits damage better than trying to fix it afterwards.
Frequently asked questions
How do I see who has sudo on a server? With getent group sudo on Ubuntu and Debian, and by reviewing /etc/sudoers and the files in /etc/sudoers.d/ with sudo visudo or sudo -l -U <user>.
What is a SUID binary? A program that runs with the permissions of its owner, often root, regardless of who launches it. Some are necessary, such as passwd; an unnecessary or vulnerable one is a classic privilege escalation vector. They are listed with find / -perm -4000 -type f 2>/dev/null.
Related: Why we don't use root for everything.
Sources: OWASP: Access Control · Linux capabilities.
