Running .NET 9 on Linux? Unpatched runtimes expose your servers to remote code execution. This guide shows you how to check your systems, apply the fix with a universal bash script, and block attacks with iptables if you cannot reboot today. Includes automation for Ubuntu, Rocky, and SUSE.
Updated: April 2026 – In late April 2026, Oracle released an important update for .NET 9 (SDK 9.0.116 / Runtime 9.0.15). That specific date doesn’t matter. What matters is that any unpatched .NET runtime on Linux is a reliable way to get owned.
This isn't about one CVE. It's about building a repeatable habit. Below you’ll find the exact commands to check your servers, a single script to patch across major distros, and a fallback mitigation if your next maintenance window is two weeks away.
1. How to check if you are vulnerable (right now)
# Check installed .NET packages dpkg -l | grep dotnet # Verify specific runtime version dotnet --list-runtimes # If you see 9.0.14 or lower → vulnerable
# List .NET packages rpm -qa | grep dotnet # Show detailed version dnf list installed | grep dotnet # Vulnerable if runtime < 9.0.15 or SDK < 9.0.116
# Check installed dotnet packages zypper search --installed-only dotnet # Verify runtime version rpm -qi dotnet-runtime-9.0 | grep Version
if dotnet --list-runtimes 2>/dev/null | grep -q "Microsoft.NETCore.App 9.0.1[0-4]"; then echo "VULNERABLE"; elif dotnet --list-runtimes 2>/dev/null | grep -q "Microsoft.NETCore.App 9.0.15"; then echo "OK"; else echo "No .NET 9 found"; fi
2. Automation script to apply the fix (bash, distro-agnostic)
#!/bin/bash # patch-dotnet9.sh - Updates .NET 9 to safe version (Runtime 9.0.15 / SDK 9.0.116) # Run as root or with sudo set -e echo "Detecting OS..." if [ -f /etc/os-release ]; then . /etc/os-release OS=$ID else echo "Cannot detect OS. Exiting." exit 1 fi case $OS in ubuntu|debian) echo "Using apt update..." apt update apt install -y dotnet-sdk-9.0 dotnet-runtime-9.0 aspnetcore-runtime-9.0 ;; rocky|almalinux|rhel|ol) echo "Using dnf update..." dnf update -y dotnet-sdk-9.0 dotnet-runtime-9.0 aspnetcore-runtime-9.0 ;; sles|opensuse-leap) echo "Using zypper update..." zypper refresh zypper update -y dotnet-sdk-9.0 dotnet-runtime-9.0 aspnetcore-runtime-9.0 ;; *) echo "Unsupported OS: $OS" exit 1 ;; esac echo "Verifying update..." dotnet --list-runtimes echo "Patch complete. Restart your .NET services now."
chmod +x patch-dotnet9.sh sudo ./patch-dotnet9.sh
3. Alternative mitigation if you can't update now
# Allow your office IP (change to your actual IP) iptables -A INPUT -p tcp -s 203.0.113.55 --dport 5000 -j ACCEPT # Allow internal Kubernetes/load balancer subnet iptables -A INPUT -p tcp -s 10.0.0.0/8 --dport 5000 -j ACCEPT # Drop everything else on port 5000 iptables -A INPUT -p tcp --dport 5000 -j DROP # Save rules (distro-specific) # Ubuntu: netfilter-persistent save # Rocky: service iptables save # SUSE: iptables-save > /etc/sysconfig/iptables
# Install apparmor-utils if missing apt install apparmor-utils -y # Ubuntu/Debian # or zypper install apparmor-utils # Put .NET in complain mode (logs violations but doesn't block) aa-complain /usr/share/dotnet/dotnet
Suggested reading:
- Chapter 9: Bash Vulnerability Patching & Patch Management – Exactly what your .NET security update is about, but generalized to all Linux services
- Chapter 6: Network Security – Covers iptables, TCP Wrapper, and firewalls (your mitigation section)
- Chapter 7: Security Tools – Port Sentry, Squid Proxy, Shorewall

Nenhum comentário:
Postar um comentário