Debian and its derivatives don’t rely on TLS to secure package delivery, they rely on OpenPGP key signatures, using keys already on the system (set up during installation or added by the system administrator). This covers metadata and package contents; see How is the authenticity of Debian packages guaranteed? for details.
The other commonly-requested feature provided by TLS is confidentiality, i.e. that anyone able to spy on your traffic can’t determine what you’re doing. I don’t have the links handy but it turns out that TLS isn’t sufficient to hide package download activity meaningfully — transfer sizes are sufficient to determine which packages are being downloaded in most cases.
So TLS adds integrity, which Debian already provides, and could add confidentiality, but doesn’t in practice. It also adds some overhead and makes it more complicated to cache data (which is extremely useful for distribution package repositories); so Debian doesn’t configure it by default.
There is one feature of TLS which isn’t supported in all cases in Debian repositories: resistance to replay attacks. In a man-in-the-middle scenario, without TLS, a client can be served older versions of repository metadata and associated packages, which could be used to keep a system vulnerable. Debian repositories with frequent updates (notably, the “updates” and security suites) produce metadata which is only valid for a week, preventing replays beyond that; but stable point releases are valid until their signing key expires, so a target system could be artificially kept on an older point-release. (However in its default configuration it would still see security updates in this type of scenario.)
Of course, defense in depth is better, and there have been vulnerabilities in the past which would have been mitigated by TLS; so TLS can be enabled with most repositories.
As far as best practices go:
- for Debian (or Ubuntu) repositories, the default setup is good enough as long as you pay attention to
apt
errors (but don’t let me stop you enabling TLS if you want to);
- for third-party repositories, you should use TLS if possible (this is easier as a blanket rule than checking whether each repository is configured correctly).
apt-get --print-uris download foo
instead ofapt-get download foo
: it will provide the http URL to download the packagefoo
as well as the checksum validating it (without having to deal with the PGP part already done by apt-get). – A.B Nov 06 '23 at 14:51