sudo-check is a standalone, statically compiled security auditing utility for sudoers configuration policies and target systems written in Go.
It scans raw sudoers configuration files (including #include/@include and #includedir/@includedir drop-ins) or pre-converted cvtsudoers JSON policies for dangerous defaults, privilege escalation vectors, compliance violations (ANSSI BP-028, CIS Benchmarks, DISA STIG), and executable binaries in the GTFObins catalog.
- Native Sudoers Parser &
cvtsudoersParity:- Parses raw
/etc/sudoersand/etc/sudoers.d/*configurations directly using a built-in native Go parser (pkg/parser) or acceptscvtsudoers -f jsonpolicy dumps. - Supports
#include/#includedir(@include/@includedir), global and scopedDefaults,User_Alias/Runas_Alias/Host_Alias/Cmnd_Alias,User_Specrules, tags, SHA-2 digests, ASN.1GeneralizedTimetimestamps (NOTBEFORE/NOTAFTER), and POSIX ERE regular expressions. - Tracks included files during directory scans to avoid duplicate auditing of drop-ins when a root
sudoersfile is present, while preserving exact per-fileContextand line number attribution. - Validated for differential parity against
cvtsudoers -f jsonacross a 105-file real-world test corpus (testdata/corpus/).
- Parses raw
- GTFObins Matching:
- Resolves recursive
inheritchains (e.g.,vim,systemctl,journalctl,git,crontab) and binary aliases. - Normalizes versioned and distribution-specific binary names (e.g.,
python3.11,vim.basic,gawk,nc.openbsd). - Consolidates findings to one finding per
(rule, binary, function)with function-accuratenoexecmitigation awareness (shell/commandvs.library-load,file-read,file-write,suid,sudo,capabilities).
- Resolves recursive
- Defaults Auditing (Global & Scoped):
- Evaluates
Defaultssequentially usingsudo's last-match-wins semantics (=,+=,-=,!flag) across global and scoped (Defaults@host,Defaults:user,Defaults!cmnd,Defaults>runas) bindings. - Audits
secure_path,env_reset,use_pty,noexec,requiretty,umask,ignore_dot,visiblepw,pwfeedback,!authenticate,setenv,sudoedit_follow,!sudoedit_checkdir,timestamp_timeout,passwd_timeout,timestamp_type=global,runchroot,runcwd=*, and 90+ dangerous environment variables/prefixes inenv_keep,env_check, andenv_delete.
- Evaluates
- Allowed Commands & Alias Expansion:
- Expands
User_Aliases,Host_Aliases,Runas_Aliases, andCommand_Aliasesrecursively. - Detects
ALLcommand rules, wildcard/glob rules, negated commands (!cmd) and negated identities (!user,!host,!runas), missing argument restrictions, direct text editor execution, sensitivesudoedittargets, relative or user-writable/temporary command paths, per-commandSETENV/FOLLOW/CHROOT/CWD=*overrides, and weaksha224digests.
- Expands
- System Verification:
- Checks the target host's active
sudoversion against known vulnerabilities:CVE-2019-14287,CVE-2019-18634(pwfeedbackoverflow),CVE-2021-3156("Baron Samedit"),CVE-2022-43995,CVE-2023-22809(sudoeditarbitrary file write),CVE-2023-27320(chrootdouble-free),CVE-2025-32462(-hhost option), andCVE-2025-32463(chrootnsswitch.conf). - Validates permissions and
root:rootownership on/etc/sudoers,/etc/sudoers.dand its drop-in files,/usr/bin/sudo(including SUID bit verification), and target binaries and parent directories referenced in the policy.
- Checks the target host's active
- Actionable Remediation & Multi-Format Exporters:
- Every finding emits a deterministic, copy-pasteable
RemediationCodesnippet (sudoerspolicy directive or shell command) separated from proseRemediationandExploitPoCreference commands. - HTML (Example Report): Self-contained, 100% offline-safe responsive dark/light report organized into three toggleable WAI-ARIA tabs:
- Audit Report: Interactive triage dashboard featuring multi-file, rule, and principal breakdown panels, adaptive grouping (
SEVERITY,FILE,RULE,USER), pseudo-sudoersrule previews, one-click copyable remediation blocks, print/PDF-ready layout, andcontent-visibility: autodeferred rendering. - Reference Frameworks: Verbatim requirements, security rationale, required directives, and live violation counts across ANSSI BP-028 v2.0 (
R38–R44, English with French translation), CIS Linux Benchmarks Section 5.2 (5.2.1–5.2.7), DISA STIG, and MITRE ATT&CK (T1548.003), with one-click cross-filtering to triggered findings. - Hardened Reference Template: Annotated, copy-pasteable
/etc/sudoersbaseline policy (verified in unit tests to produce zerosudo-checkfindings),/etc/sudoers.d/drop-in example, root-owned wrapper script pattern, host permission remediation runbook, and a complete 33-rule Traceability Matrix.
- Audit Report: Interactive triage dashboard featuring multi-file, rule, and principal breakdown panels, adaptive grouping (
- Text: Terminal output with optional
--no-color/NO_COLORsupport, clean ANSI-free file export, and indentedExample Fix/Referenceblocks. - JSON: Structured JSON report including
remediation_code,exploit_poc, and compliance mappings for automation. - SARIF: Static Analysis Results Interchange Format v2.1.0 with GitHub Code Scanning
security-severity, remediation snippets, compliance tags, and source file/line regions. - PDF: Programmatically formatted vector report with dedicated remediation code and exploit/verification reference boxes.
- Every finding emits a deterministic, copy-pasteable
| Category | Rule IDs | Scope |
|---|---|---|
| Defaults Rules | SUDO-DEF-001 – SUDO-DEF-016 |
Global and scoped Defaults (secure_path, use_pty, env_keep/env_check/env_delete, visiblepw, pwfeedback, noexec, requiretty, umask, ignore_dot, env_reset, !authenticate, setenv, sudoedit_follow/!sudoedit_checkdir, timestamp_timeout/passwd_timeout/timestamp_type, runchroot/runcwd) |
| Command Rules | SUDO-CMD-001 – SUDO-CMD-013 |
Negated commands (!cmd), ALL privileges (PASSWD & NOPASSWD), wildcards, passwordless specific commands, missing argument restrictions, direct editor execution, negated User/Host/Runas specs, per-command SETENV/FOLLOW/CHROOT/CWD=*, sensitive sudoedit targets, relative or writable paths, weak sha224 digests, and missing TYPE=/ROLE= SELinux context elevation on administrator-grade rules (DISA STIG V-272484, INFO) |
| GTFObins Rules | SUDO-GTFO-001 – SUDO-GTFO-003 |
Authenticated GTFObins binaries (HIGH), passwordless NOPASSWD GTFObins binaries (CRITICAL), and NOEXEC-mitigated shell/command binaries (LOW) |
| System & File Permissions | SUDO-SYS-001, SUDO-SYS-PERM-001 – SUDO-SYS-PERM-013 |
sudo version parsing, /etc/sudoers and /etc/sudoers.d/* permissions and root:root ownership, sudo binary SUID bit and ownership, and permitted target binary/directory write permissions |
| Sudo CVEs | CVE-2019-14287, CVE-2019-18634, CVE-2021-3156, CVE-2022-43995, CVE-2023-22809, CVE-2023-27320, CVE-2025-32462, CVE-2025-32463 |
Active sudo --version vulnerability range matching |
Prebuilt static binaries (linux/amd64, linux/arm64, darwin/amd64, darwin/arm64, windows/amd64), SHA256SUMS, and CycloneDX SBOMs are available on the GitHub Releases page.
Requires Go 1.27 or later:
git clone https://github.com/Harvester57/sudo-check.git
cd sudo-check
CGO_ENABLED=0 go build -ldflags="-s -w" -trimpath -o sudo-checksudo-check [command] [flags]
Analyze a raw sudoers file, a sudoers.d directory, a directory containing a root sudoers file and drop-ins, or cvtsudoers JSON policy files:
./sudo-check scan /path/to/sudoers -o reports/Enforce a CI/CD severity gate (exits with status code 2 if any finding meets or exceeds the threshold):
./sudo-check scan /path/to/sudoers -f sarif --fail-on HIGHAudit the local host autonomously (uses cvtsudoers if installed, or automatically falls back to the built-in native parser):
sudo ./sudo-check system -o reports/Fetch the latest database snapshot from https://gtfobins.org/api.json and save it locally:
./sudo-check update-db -p gtfobins.jsonPrint the build version, commit hash, and build date:
./sudo-check version-o, --output-dir <string>: Directory to save generated reports (if omitted,text,json, orsarifreports are written tostdout).-f, --formats <string>: Comma-separated list of report formats (text,json,sarif,pdf,html) (default:"text,sarif,pdf,html").--fail-on <severity>: Exit with non-zero status code (2) if any finding meets or exceeds the specified severity (CRITICAL,HIGH,MEDIUM,LOW,INFO).--no-color: Disable ANSI color codes in terminal text output (also respectsNO_COLOR).--gtfobins-path <string>: Path to a customgtfobins.jsondatabase file.--cvtsudoers-path <string>: Path to a customcvtsudoersbinary.
--sudoers-file <string>: Path to target sudoers file (default"/etc/sudoers").
For codebase architecture details, cross-compilation configurations, and test setup, please refer to AGENTS.md and CHANGELOG.md.