What Happened? (Historical Context)
A security vulnerability (CVE-2026-5958) was discovered in GNU Sed, affecting all versions from 4.1e through 4.9. The issue was fixed in version 4.10. On May 13, 2026, Mageia released an advisory (MGASA-2026-0128) with updated packages for Mageia 9.
Understanding the Vulnerability
The flaw is a TOCTOU (Time-of-Check-Time-of-Use) race condition that occurs when Sed is invoked with both -i (in-place edit) and --follow-symlinks options.
How it works:
1. Sed resolves a symbolic link to its target and records that target
2. Then it opens the original symlink path to read the file
3. Between these two operations, an attacker can atomically replace the symlink with a different target
4. Sed then reads content from the attacker‑chosen file and overwrites the previously recorded target path
Impact: Arbitrary file overwrite with attacker‑controlled content, potentially leading to privilege escalation, configuration tampering, or data destruction.
How to Check If You Are Vulnerable
Check your current Sed version
sed --version | head -n1
rpm -q sed
Check if the security update is already applied
urpmq --list-media active
urpmi --auto-select --test
Check the specific advisory
grep -i "CVE-2026-5958" /var/log/messages
How to Apply the Fix
sudo urpmi.update -a && sudo urpmi --auto-select
This refreshes repository lists and installs all pending updates, including the patched Sed.
Option 2: Update only Sed
sudo urpmi.update -a sudo urpmi sed
Option 3: Use MageiaUpdate GUI
sudo MageiaUpdate
sed --version | head -n1 # Should show version 4.10 or higher rpm -q sed # Should show sed-4.10 or a patched 4.9 build
Automation Script to Apply the Fix
#!/bin/bash # fix-sed-vulnerability.sh # One‑click script to patch CVE-2026-5958 (GNU Sed race condition) on Mageia # Author: Security Team # Date: $(date +%Y-%m-%d) set -e echo "[*] Checking current Sed version..." CURRENT=$(sed --version | head -n1 | grep -oP '\d+\.\d+') echo " Current version: $CURRENT" if [[ "$CURRENT" == "4.10" ]] || [[ "$CURRENT" > "4.10" ]]; then echo "[✓] System already has Sed $CURRENT (>= 4.10). No update needed." exit 0 fi echo "[!] Vulnerable Sed version detected ($CURRENT < 4.10)." echo "[*] Updating package lists..." sudo urpmi.update -a echo "[*] Installing patched Sed package..." sudo urpmi sed echo "[*] Verifying update..." NEW=$(sed --version | head -n1 | grep -oP '\d+\.\d+') if [[ "$NEW" == "4.10" ]] || [[ "$NEW" > "4.10" ]]; then echo "[✓] Successfully updated to Sed $NEW" else echo "[✗] Update may have failed. Current version: $NEW" exit 1 fi echo "[✓] CVE-2026-5958 mitigation complete."
Build a dedicated test lab (recommended)
Alternative Mitigation (If You Cannot Update Now)
sudo auditctl -w /usr/bin/sed -p x -k sed_execution
sudo ausearch -k sed_execution
sudo chmod 750 /usr/bin/sed
sudo mkdir -p /etc/apparmor.d/disable sudo cat > /etc/apparmor.d/usr.bin.sed << 'EOF' #include <tunables/global> /usr/bin/sed { #include <abstractions/base> #include <abstractions/nameservice> # Allow reading from standard locations /usr/bin/sed mr, /bin/sed mr, /usr/share/** r, /etc/** r, # Deny writing to critical system files deny /etc/shadow w, deny /etc/passwd w, deny /etc/sudoers w, deny /root/** w, # Allow writing only to temporary directories /tmp/** rw, /var/tmp/** rw, # Deny symlink following entirely deny /proc/** rw, deny /sys/** rw, # Capabilities capability setuid, capability setgid, } EOF sudo apparmor_parser -r /etc/apparmor.d/usr.bin.sed sudo aa-enforce /usr/bin/sed

Nenhum comentário:
Postar um comentário