A predictable /tmp file in smc-tools (v1.8.6 and below) enables local DoS attacks on SUSE/openSUSE. Learn to check your vulnerability, apply the fix with an automation script, and implement iptables or AppArmor mitigations if you can't update now. Includes practical commands for Ubuntu, Rocky Linux, Fedora, RHEL and SUSE.
Historical context (April 2026): A moderate security issue was fixed in smc-tools v1.8.7 for SUSE Linux Enterprise Server and openSUSE Leap 15.6. The problem? A predictable temporary file in /tmp that allows a local, unprivileged user to crash your SMC (Shared Memory Communications) statistics tool – a classic local denial of service.
But this isn't just about one old patch. The pattern – predictable temporary file creation – repeats across dozens of Linux utilities. Learning how to spot, check, and fix this specific flaw will make you better at handling similar vulnerabilities in tmpwatch, mktemp misuse, or any script that writes to world-writable directories.
Let's make this useful for years, not just for today's update.
1. How to check if you are vulnerable
dpkg -l | grep smc-tools # If installed, check version. Most Ubuntu repos don't include smc-tools by default. # If you compiled from source: smc_rnics --version
Rocky Linux / RHEL / Fedora
SUSE / openSUSE (the original affected distro)
zypper info smc-tools | grep Version # Vulnerable if Version < 1.8.7
Generic test for the vulnerability (works on any Linux)
# Simulate the unsafe behavior: Can a normal user create a file that the root-run smc tool will trust? touch /tmp/smc_trace_workfile_$$ chmod 777 /tmp/smc_trace_workfile_$$ # If the smc tool later writes to that same predictable path without checking, you're vulnerable. # The actual exploit: user creates a symlink pointing to /etc/passwd or a critical file, then smc tool follows it.
Real example: A local user runs ln -s /etc/crontab /tmp/smc_trace_workfile_1234. Then, when root runs smc_rnics --stats, the tool overwrites /etc/crontab with garbage → system breaks.
2. Automation script to apply the fix
Save this as fix_smc_tmp.sh and run as root. It detects your distro and updates smc-tools to the safe version (1.8.7 or higher).
#!/bin/bash # fix_smc_tmp.sh - Update smc-tools to fix predictable /tmp DoS # Works on SUSE, Ubuntu (if available), Rocky (if from source/EPEL) set -e echo "[+] Checking current smc-tools version..." if command -v smc_rnics &> /dev/null; then CURRENT_VER=$(smc_rnics --version 2>&1 | head -n1 | grep -oP '\d+\.\d+\.\d+' || echo "0.0.0") echo "Found version: $CURRENT_VER" else CURRENT_VER="0.0.0" echo "smc-tools not installed. Installing now." fi if [[ "$CURRENT_VER" > "1.8.6" ]] || [[ "$CURRENT_VER" == "1.8.7" ]]; then echo "Already safe. Exiting." exit 0 fi echo "[+] Updating smc-tools..." if [ -f /etc/os-release ]; then . /etc/os-release case "$ID" in opensuse-leap|suse|sles) zypper refresh && zypper update -y smc-tools ;; ubuntu|debian) echo "smc-tools not in default repos. Compiling from source:" apt update && apt install -y git make gcc git clone https://github.com/ibm-s390-linux/smc-tools.git /tmp/smc-tools cd /tmp/smc-tools && make && make install ;; rocky|rhel|centos) echo "Enable EPEL or compile from source:" dnf install -y epel-release || yum install -y epel-release dnf install -y smc-tools || yum install -y smc-tools ;; *) echo "Unsupported distro. Manually compile from https://github.com/ibm-s390-linux/smc-tools" exit 1 ;; esac fi echo "[+] Fix applied. New version: $(smc_rnics --version 2>&1 | head -n1)"
Run it: chmod +x fix_smc_tmp.sh && sudo ./fix_smc_tmp.sh
3. Alternative mitigation if you can't update now
You can't always reboot or upgrade. Here are three immediate workarounds that block the attack vector.
Option A: iptables (doesn't help – this is local, not network)
# Make /tmp immutable to predictable patterns? Not practical. Better: # Restrict which users can run smc tools: chmod 700 /usr/bin/smc_rnics # Only root and group 'smcadmin' can execute. Add trusted users to that group.
Option B: AppArmor profile (effective for SUSE/Ubuntu)
/usr/bin/smc_rnics {
# Allow read/write only in /tmp/ with random names, not predictable ones
/tmp/smc_trace_workfile_[0-9]* rw,
# Deny symlink following in /tmp
deny /tmp/** l,
}
Then apparmor_parser -r /etc/apparmor.d/usr.bin.smc_rnics
Option C: Monitor and alert (if you're a managed service provider)
# Watch for attempts to create the dangerous file pattern inotifywait -m /tmp -e create | grep --line-buffered "smc_trace_workfile" | while read line; do logger "ALERT: smc-tools predictable tmp file creation attempt by $(stat -c '%U' $(echo $line | cut -d' ' -f3))" # Optional: kill the offending user's processes done
Suggeted reading
Linux Security Cookbook by Daniel J. Barrett - Amazon
Why this matter ?
This vulnerability is a textbook example of CWE-377: Insecure Temporary File. The Cookbook dedicates 20+ pages to patterns like mktemp, O_EXCL, and AppArmor policies. Instead of chasing every single CVE, buy the book, read Chapter 7 ("Files and Filesystems"), and you'll learn how to audit your own code and system scripts for the same flaw.
Affiliate disclosure: As an Amazon Associate, I earn from qualifying purchases. This helps me keep writing in-depth security guides – at no extra cost to you.)
Conclusion: Don't wait for the next /tmp disaster
Predictable temporary files are a repeat offender in Linux security. Today it's smc-tools. Tomorrow it's some custom script your junior admin wrote.
Take action now:
1. Run the automation script above on every SUSE/openSUSE server.
2. Apply the AppArmor mitigation on production systems where you can't upgrade.

Nenhum comentário:
Postar um comentário