A new APT flaw in Debian and Ubuntu lets attackers swap verified packages and run code as root. Learn how it works and how to protect your system.
A flaw in APT, the package manager for Debian and Ubuntu, allows an attacker who can modify package downloads to swap a checked package for their own. The attacker's code then runs as root, according to advisories that Debian, Ubuntu, and APT's developers published on November 4. The attack needs APT to retry failed downloads, which it does by default from Debian 12 and Ubuntu 23.04 onward.
### How the Attack Works
Here's the deal: APT downloads packages from repositories, and it verifies them using cryptographic signatures. But if a download fails partway through, APT retries. During that retry, an attacker who can intercept network traffic (a man-in-the-middle, or MitM) could swap the package with a malicious one. Since APT doesn't re-verify the package after the retry, the fake package gets installed. And because APT runs with root privileges, the attacker's code executes as root. Game over.
> "This is a classic race condition," says one security researcher. "The attacker has to win a narrow window, but when they do, it's a full system compromise."
### Who's at Risk?
If you're running Debian 12 or Ubuntu 23.04 (or later) with default settings, you're vulnerable. Older versions of Debian and Ubuntu don't retry downloads by default, so they're not affected. But let's be real: most people don't change default settings. So if you're on a recent version, pay attention.
### What You Can Do
- Update APT immediately. The APT developers have released a patch, and Debian and Ubuntu have pushed updates. Run `sudo apt update && sudo apt upgrade` to get the fix.
- Consider disabling automatic retries. If you can't update right away, you can set `Acquire::Retries "0";` in your APT configuration to turn off retries. But this might cause more failed downloads, so it's a trade-off.
- Use a trusted network. MitM attacks require the attacker to be on your network path. Avoid using public Wi-Fi without a VPN, especially for system updates.
- Monitor your systems. Keep an eye out for unusual activity, like unexpected processes running as root.
### The Bigger Picture
This isn't the first time package managers have had security issues, and it won't be the last. The lesson? Always keep your systems updated, and don't assume that just because a package is "verified" that it's safe. Attackers are constantly finding new ways to exploit trust.
For now, the fix is available, so go update your systems. And if you're managing Linux servers, double-check that your update process is secure. The last thing you want is a rootkit on your machine.