<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: DeaconGuard Security</title>
    <description>The latest articles on DEV Community by DeaconGuard Security (@shellctl).</description>
    <link>https://dev.to/shellctl</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4254260%2Fef44ddbb-8542-4fd6-8463-4e7a8920093a.png</url>
      <title>DEV Community: DeaconGuard Security</title>
      <link>https://dev.to/shellctl</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shellctl"/>
    <language>en</language>
    <item>
      <title>8 ways a normal Linux account becomes root (and how to check your servers)</title>
      <dc:creator>DeaconGuard Security</dc:creator>
      <pubDate>Thu, 19 Nov 2026 17:18:39 +0000</pubDate>
      <link>https://dev.to/shellctl/8-ways-a-normal-linux-account-becomes-root-and-how-to-check-your-servers-52cj</link>
      <guid>https://dev.to/shellctl/8-ways-a-normal-linux-account-becomes-root-and-how-to-check-your-servers-52cj</guid>
      <description>&lt;p&gt;Most server break-ins don't start as root. They start with one ordinary account: a web app user, a CI deploy user, a leaked SSH key for &lt;code&gt;deploy&lt;/code&gt;. What happens next depends on one question: &lt;strong&gt;how far is it from that account to root?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;On a lot of servers the answer is "one command". Not because of a clever kernel exploit, but because of ordinary setup choices that made sense at the time.&lt;/p&gt;

&lt;p&gt;Here are the ones I see most, how to check each by hand, and what to do about it.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. A sudo rule without a password
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="na"&gt;deploy ALL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;ALL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="no"&gt;NOPASSWD&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;ALL&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Many cloud images add exactly this line for their default user (&lt;code&gt;ubuntu&lt;/code&gt;, &lt;code&gt;ec2-user&lt;/code&gt;, &lt;code&gt;admin&lt;/code&gt;). Anyone who gets that account, through a stolen key or a hole in an app running as it, is root with &lt;code&gt;sudo -i&lt;/code&gt;. No password needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo grep -rn NOPASSWD /etc/sudoers /etc/sudoers.d/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; remove &lt;code&gt;NOPASSWD&lt;/code&gt; for accounts that log in remotely, or limit the rule to the few commands that really need it.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. A sudo rule for "just one program"
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="na"&gt;deploy ALL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="no"&gt;NOPASSWD&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;usr&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;bin&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;vim&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;etc&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;nginx&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;nginx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;conf&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This looks narrow. It isn't. &lt;code&gt;vim&lt;/code&gt; can run a shell (&lt;code&gt;:!sh&lt;/code&gt;), and that shell is root. The same goes for &lt;code&gt;less&lt;/code&gt;, &lt;code&gt;find&lt;/code&gt;, &lt;code&gt;python3&lt;/code&gt;, &lt;code&gt;tar&lt;/code&gt;, &lt;code&gt;awk&lt;/code&gt;, &lt;code&gt;cp&lt;/code&gt; and many others: if the program can start a shell or write any file, the rule gives full root.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check:&lt;/strong&gt; read the rules for each account and ask, for every program listed, "can this run a command or write anywhere?"&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo -l -U deploy    &lt;span class="c"&gt;# run as root, or as an admin with sudo&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; use &lt;code&gt;sudoedit&lt;/code&gt; for editing files. It edits a copy as the user and writes it back, so no editor runs as root.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. The docker, lxd or disk group
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;getent group docker lxd disk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Being in the &lt;code&gt;docker&lt;/code&gt; group means you can start a container that mounts &lt;code&gt;/&lt;/code&gt; from the host, which is root in all but name. &lt;code&gt;lxd&lt;/code&gt; is the same. &lt;code&gt;disk&lt;/code&gt; gives raw read and write access to the disks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; treat these groups like sudo. Only admins belong in them. For rootless containers, look at rootless Docker or Podman.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. A container socket other accounts can use
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -l /var/run/docker.sock /run/podman/podman.sock /run/containerd/containerd.sock 2&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the socket is writable by everyone, or by a group many accounts are in, every one of those accounts can do what root can, through the container engine.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; the socket should be &lt;code&gt;root:docker&lt;/code&gt; and &lt;code&gt;srw-rw----&lt;/code&gt;, and see point 3 for who is in &lt;code&gt;docker&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. A file root runs that someone else can change
&lt;/h2&gt;

&lt;p&gt;Root runs scripts from cron (&lt;code&gt;/etc/crontab&lt;/code&gt;, &lt;code&gt;/etc/cron.d&lt;/code&gt;, &lt;code&gt;/etc/cron.daily&lt;/code&gt;) and services from systemd. If another account can edit one of those scripts, &lt;strong&gt;or the folder it's in&lt;/strong&gt;, it can add a line and wait.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check:&lt;/strong&gt; for each script root runs, look at the file and its folders:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ls -l /etc/cron.daily/
namei -l /opt/backup/run.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;namei -l&lt;/code&gt; shows the permissions of every folder along the path. A writable &lt;code&gt;/opt/backup&lt;/code&gt; is enough, even if &lt;code&gt;run.sh&lt;/code&gt; itself is locked down: the account can replace the file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; scripts root runs, and every folder above them, should be owned by root and not writable by anyone else.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. A writable folder in root's PATH
&lt;/h2&gt;

&lt;p&gt;If root's PATH includes a folder another account can write to, that account can put a program named &lt;code&gt;ls&lt;/code&gt; or &lt;code&gt;tar&lt;/code&gt; there. The next time root, or a root cron job, runs that command, it runs theirs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo grep secure_path /etc/sudoers
&lt;span class="k"&gt;for&lt;/span&gt; d &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"$PATH"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; tr : &lt;span class="s1"&gt;' '&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; ls -ld &lt;span class="s2"&gt;"$d"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(Run the second line as root, so you see root's PATH.)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; remove such folders from PATH, or make them root-only.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. A setuid program that opens a shell
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;sudo&lt;/code&gt;, &lt;code&gt;su&lt;/code&gt; and &lt;code&gt;passwd&lt;/code&gt; are setuid root on purpose. &lt;code&gt;find&lt;/code&gt;, &lt;code&gt;python3&lt;/code&gt; or &lt;code&gt;bash&lt;/code&gt; should never be, but sometimes are, left over from a quick fix years ago.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;find /usr/bin /usr/sbin /bin /sbin -perm -4000 -user root 2&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; &lt;code&gt;chmod u-s&lt;/code&gt; on anything that isn't meant to be setuid.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. File capabilities that give root
&lt;/h2&gt;

&lt;p&gt;Capabilities split root into pieces. Some pieces are root again: &lt;code&gt;cap_setuid&lt;/code&gt; lets a program become any user, &lt;code&gt;cap_dac_override&lt;/code&gt; lets it read and write any file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;getcap -r /usr/bin /usr/sbin /usr/local/bin 2&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; remove capabilities that a program doesn't need (&lt;code&gt;setcap -r&lt;/code&gt;), especially on interpreters such as &lt;code&gt;python3&lt;/code&gt; or &lt;code&gt;perl&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus: secrets the wrong people can read
&lt;/h2&gt;

&lt;p&gt;Becoming root isn't the only goal. A readable &lt;code&gt;~/.ssh/id_ed25519&lt;/code&gt;, &lt;code&gt;~/.aws/credentials&lt;/code&gt;, &lt;code&gt;~/.kube/config&lt;/code&gt; or an app's &lt;code&gt;.env&lt;/code&gt; file can be worth more than root on that one machine, because it opens other machines.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sudo find /home /root /srv /opt /var/www -maxdepth 4 \
  \&lt;span class="o"&gt;(&lt;/span&gt; -name &lt;span class="s1"&gt;'id_*'&lt;/span&gt; ! -name &lt;span class="s1"&gt;'*.pub'&lt;/span&gt; -o -name credentials -o -name .env -o -name config.json -o -name .git-credentials \&lt;span class="o"&gt;)&lt;/span&gt; \
  -perm /o+r 2&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And one more: if the &lt;strong&gt;same SSH key&lt;/strong&gt; is trusted in &lt;code&gt;authorized_keys&lt;/code&gt; on many machines, one laptop, CI secret or old backup with that key opens all of them at once.&lt;/p&gt;

&lt;h2&gt;
  
  
  Doing this on every server, every week
&lt;/h2&gt;

&lt;p&gt;Checking one server by hand takes ten minutes. Checking twenty, again after every change, doesn't happen. That's why I added an "attack paths" check to &lt;a href="https://github.com/Cloudopsshell/deaconguard" rel="noopener noreferrer"&gt;DeaconGuard&lt;/a&gt;, a free, MIT-licensed security scanner you host yourself.&lt;/p&gt;

&lt;p&gt;It runs all of the checks above on each machine and shows each finding as a chain, for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;deploy &amp;gt; sudo rule without a password &amp;gt; root
every account &amp;gt; reads /home/deploy/.ssh/id_rsa &amp;gt; logs in where deploy's key is trusted
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each finding has the evidence (the sudo line, the file and its permissions) and what to do about it. A few things it is careful about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;It only reads.&lt;/strong&gt; It never runs an exploit or tries a password. For secrets it reads only the path, owner and permissions, never the contents.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SSH keys are compared by fingerprint.&lt;/strong&gt; The agent sends the server each key's SHA256 fingerprint, never the key, and the server spots keys trusted on three or more machines.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It's light.&lt;/strong&gt; The check is three short shell scripts at the lowest CPU priority; on a test machine it took about a tenth of a second.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Try it on a spare Linux box:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -fsSL https://get.deaconguard.io &lt;span class="o"&gt;|&lt;/span&gt; sudo sh -
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It needs root, verifies the release's signature before installing, and scans its own server straight away. Docs for this check: &lt;a href="https://docs.deaconguard.io/usage/attack-paths" rel="noopener noreferrer"&gt;docs.deaconguard.io/usage/attack-paths&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you know a path to root that's common on real servers and isn't on this list, tell me in the comments. I'd like to add it.&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>linux</category>
      <category>security</category>
    </item>
  </channel>
</rss>
