1. Paste your sudoers files
Name each block like its path. A block named sudoers is read first, and its @includedir /etc/sudoers.d pulls in every block named sudoers.d/something in sorted order, skipping names with a dot, the way sudo does. On the server, sudo cat /etc/sudoers /etc/sudoers.d/* shows them.
Paste at least one sudoers file above and click Check.
Findings
| File : Line | Type | Risk | Fix |
|---|
Who can become root
Every rule that grants ALL as root, or a command this tool rates a root shell. Group members are not expanded: check them with getent group sudo.
What it checks
- High:
NOPASSWD: ALL;ALLfor every user;ALLminus a command; editors (vim,nano), pagers (less,man,journalctl) and interactive clients with a shell escape; shells, interpreters and tools likefind,tar,systemctl,dockerwith open arguments; file writers liketee,cp,chownwith open arguments; programs or scripts under/home,/tmp,/var/www; a directory or pattern as the command;SETENV;!env_reset;env_keepofLD_PRELOAD,PYTHONPATH,BASH_ENVand similar;!authenticate;Defaults setenv. - Medium: file readers like
catwith open arguments; other wildcard arguments;env_keepofPATHwithoutsecure_path;timestamp_timeoutbelow zero. A rule whose target user is not root drops one level. - Low: a
NOPASSWDrule a later rule overrides; asudoers.dfilesudoskips; nosecure_path; shared or long credential caching;!use_pty;visiblepw;pwfeedback.
The parser reads the grammar the way sudo does: aliases, tag and runas inheritance, : Host = groups, escapes, digests, option specs, regular-expression arguments and include order. On 41 test cases its reading matches cvtsudoers, sudo's own parser (1.9.15p5). Which programs give a shell is our own list; GTFOBins catalogues the exact escapes, and this tool is not affiliated with it. Every type, with the sudo behaviour behind it: sudoers mistakes explained.
Prefer a CLI, or want this in your own CI?
Same engine, zero dependencies, Node 18 or later:
sudo node check.mjs /etc/ # /etc/sudoers and /etc/sudoers.d/*
node check.mjs ./sudoers.d/90-app # one drop-in from your repo
node check.mjs /etc --format json # machine-readable
node check.mjs . --fail-on-risk # exit 2 on any high or medium finding
Get check.mjs and scan.mjs from the repo: nothing to install, no network calls, and it never runs sudo. Run visudo -cf as well, for syntax.
Common questions
Why does my NOPASSWD rule in sudoers not work?
sudo uses the last rule that matches, not the most specific one. If your NOPASSWD line sits above %sudo ALL=(ALL:ALL) ALL (or %wheel) and you are in that group, the group rule matches later and asks for a password. Put the NOPASSWD rule after the group rule, which a file in /etc/sudoers.d does, because the @includedir line comes at the end of /etc/sudoers.
Why is my file in /etc/sudoers.d ignored?
sudo skips every file in an @includedir directory whose name contains a dot or ends in a tilde, so /etc/sudoers.d/deploy.conf is never read and none of its rules apply. Rename it to deploy or 90-deploy and check it with visudo -cf.
Is ALL, !/bin/su a safe way to stop a user becoming root?
No. The sudoers manual says subtracting commands from ALL is generally not effective: the user can copy su to another name, or start a shell from an editor or script. List the commands the user needs instead.
Why is allowing vim, less or find through sudo dangerous?
Those programs can start a shell or write any file. vim runs :!sh and can save over /etc/sudoers, less and man run !sh, and find runs any command with -exec, all as root. Use sudoedit for editing, a group such as adm or systemd-journal for reading logs, and pinned arguments or a root-owned wrapper script for the rest.
Does a clean result mean my sudo setup is secure?
No. It reads only the patterns listed on this page. It does not know your group memberships, the contents or permissions of the programs a rule allows, your sudo version, or LDAP and SSSD rules. Have a qualified person review anything that protects valuable data.