News headlines about sudo vulnerabilities come and go every few months. But the underlying problem remains the same: sudo is the central tool for privilege escalation on Linux systems.
When a flaw like CVE-2026-35535 appears, it’s crucial to treat it not as a one-time scare, but as a reason to revisit your entire security hygiene.
In May 2026, a patch (RLSA-2026:12310) was released for Rocky Linux 9 to close a privilege escalation bug in the sudo package. The vulnerability involved a failure in how sudo drops privileges (via setuid, setgid, and setgroups calls) before executing the mailer — a failure that could allow a local attacker to gain full root access.
Below is an evergreen guide to check, fix, and harden your setup against this class of sudo flaws, not just for this specific CVE, but for future vulnerabilities as well.
How to Check If You Are Vulnerable (Rocky Linux)
Perform these three checks to determine whether your system is exposed.
Step 1: Check the sudo version
The vulnerable versions are up to 1.9.5p2 (the patch version is sudo-1.9.5p2-15.el9_7).
$ sudo --version | head -n1 # Example output (vulnerable): Sudo version 1.9.5p2
This is the most reliable way to identify the risk. If your output shows 1.9.5p2 or an earlier version, you need to update immediately.
Step 2: Verify the exact installed RPM
$ rpm -q sudo # Example output (vulnerable): sudo-1.9.5p2-14.el9_7.x86\_64
The fixed version is sudo-1.9.5p2-15.el9_7 (or newer for future patches).
Step 3: (Optional) Check for security updates without installing
$ sudo dnf updateinfo list --security
This shows all security advisories available for your system. Look for an entry referencing sudo or RLSA-2026:12310.
Below is a hardened bash script that works on Rocky Linux, as well as other major RHEL-derived distributions. It checks the current status, applies the update, and logs the result — ready to be scheduled via cron.
Script: apply-sudo-security-fix.sh
#!/bin/bash # apply-sudo-security-fix.sh # A robust script to patch sudo on RHEL-derivatives (Rocky, Alma, RHEL, etc.) set -e LOG_FILE="/var/log/sudo-security-update.log" echo "=== Security update started: $(date) ===" >> "$LOG_FILE" # 1. Check current version echo " Checking current sudo version..." | tee -a "$LOG_FILE" CURRENT_VERSION=$(sudo --version | head -n1 | awk '{print $3}') echo " Current sudo version: $CURRENT_VERSION" | tee -a "$LOG_FILE" # 2. Detect if an update is available echo " Checking for latest sudo update..." | tee -a "$LOG_FILE" if sudo dnf check-update sudo >/dev/null 2>&1; then echo " Update found. Proceeding to apply patch..." | tee -a "$LOG_FILE" else echo " No update available. Version is up-to-date." | tee -a "$LOG_FILE" exit 0 fi # 3. Apply the security update echo " Applying update for sudo..." | tee -a "$LOG_FILE" sudo dnf update -y sudo >> "$LOG_FILE" 2>&1 # 4. Verify the fix NEW_VERSION=$(sudo --version | head -n1 | awk '{print $3}') echo " New sudo version: $NEW_VERSION" | tee -a "$LOG_FILE" echo "=== Security update completed: $(date) ===" >> "$LOG_FILE"
0 2 * * 1 /usr/local/bin/apply-sudo-security-fix.sh
Build Your Ultimate Linux Lab – Everything Included
Alternative Mitigation If You Can’t Update Now
If an immediate update is not feasible due to downtime restrictions or legacy dependencies, apply these temporary countermeasures to reduce the risk.
Important: These steps are not a replacement for the patch
They are defensive hardening measures that make exploitation harder.
# Avoid using NOPASSWD unless absolutely necessary # Example of a restricted rule (instead of full root access): %wheel ALL=(ALL) ALL # Allows ALL commands (best avoided) %devops ALL=(ALL) /usr/bin/systemctl restart nginx, /usr/bin/journalctl # Very narrow permissions
A poorly configured sudoers file is a common jumping-off point for privilege escalation. The principle of least privilege is your strongest ally here.
2. Disable unattended passwordless sudo
Remove any lines containing NOPASSWD: from the /etc/sudoers file. Attackers often look for these rules to escalate.
3. Monitor logs for suspicious sudo activity
Set up a simple monitoring rule to log every sudo execution:
echo "Defaults logfile=/var/log/sudo.log" >> /etc/sudoers.d/logging
4. If you rely on iptables (already configured), make sure only trusted users can login locally
Conclusion
- Run the verification script on all your Rocky Linux servers right now.
- Then schedule the automation script via cron to never miss another critical update.
- Finally, invest in a dedicated lab environment (like this Raspberry Pi Kit) to test new security patches and configurations before rolling them into production.

Nenhum comentário:
Postar um comentário