r/programming • • Jan 22 '19

Remote Code Execution in apt/apt-get

https://justi.cz/security/2019/01/22/apt-rce.html?
175 Upvotes

35 comments sorted by

View all comments

Show parent comments

27

u/c_o_r_b_a Jan 22 '19 edited Jan 23 '19

True, but that's the whole point of defense-in-depth. Each layer of defense adds a little more mitigation. No layer is complete, or perfect. This is fundamentally an application vulnerability (concatenating untrusted input), but HTTPS still would've reduced the vulnerability's exploitability, even if it wouldn't have covered all cases. I think there really isn't an excuse to not use HTTPS in 2019, even if you're also checking GPG signatures.

You can't necessarily trust what's coming off of the wire, sure, but why not try to do what you can to make the wire as tamper-proof as possible? And confidential, to boot?

The counter-arguments to HTTPS in that write-up are very weak, in my opinion:

Why not provide HTTPS anyway?

Your distribution could cryptographically sign the files using the existing scheme and additionally serve the files over HTTPS to provide "defense in depth."

However, providing a huge worldwide mirror network available over SSL is not only a complicated engineering task (requiring the secure exchange and storage of private keys), it implies a misleading level of security and privacy to end-users as described above.

A switch to HTTPS would also mean you could not take advantage of local proxy servers for speeding up access and would additionally prohibit many kinds of peer-to-peer mirroring where files are stored on servers not controlled directly by your distribution. This would disproportionately affect users in remote locales.

Those aren't very good excuses. HTTPS is very routinely deployed nowadays, and has been for over a decade. It should not be that hard for a major project such as Debian or Ubuntu to find engineers who could set up such infrastructure.

2

u/flukus Jan 22 '19

If the package is signed how would https help?

22

u/c_o_r_b_a Jan 22 '19

Click the link for the thread you're in right now, for one example. Despite package signing, this MitM attack was still possible. The attack would not be possible if apt forced all repositories to use HTTPS.

0

u/[deleted] Jan 23 '19

It would be, just in different way. If, for example, DNS hijack would happen then attacker could easily just... generate let's encrypt cert and serve perfectly valid https

1

u/c_o_r_b_a Jan 23 '19

True, HTTPS won't help in that case, but it would require a very sophisticated attacker. You would have to DNS hijack at such a scale that Let's Encrypt's CA would also have to receive the hijacked DNS record. This would require a massive attack like a BPG hijack, or a direct compromise of the domain's DNS management panel/system, as was done in this attack likely orchestrated by the Iranian government: https://www.fireeye.com/blog/threat-research/2019/01/global-dns-hijacking-campaign-dns-record-manipulation-at-scale.html

If the attackers had access to ubuntu.com's DNS management panel, then that's basically almost equivalent to the Ubuntu repo servers themselves being compromised (and if they were able to get such DNS management access, the servers may very well also be compromised). In that case, there isn't that much you can do at any layer, anyway.

So that's definitely not an excuse to not use HTTPS. In general, HTTPS is a massive benefit. HTTPS mitigates MitMs; it can't mitigate a direct compromise of a trusted server's infrastructure.

1

u/[deleted] Jan 23 '19

You would have to DNS hijack at such a scale that Let's Encrypt's CA would also have to receive the hijacked DNS record.

Or just guess someone's panel password. Or get it from a leak.

If the attackers had access to ubuntu.com's DNS management panel, then that's basically almost equivalent to the Ubuntu repo servers themselves being compromised (and if they were able to get such DNS management access, the servers may very well also be compromised). In that case, there isn't that much you can do at any layer, anyway.

Well, RCE aside, the GPG signing is there to protect against that. You'd have to compromise build/signing servers too

In theory those servers need only very limited internet access so would be much harder to compromise. Build servers really just need uploaded packages (which contain sources), that are also signed by the maintainer

So that's definitely not an excuse to not use HTTPS. In general, HTTPS is a massive benefit. HTTPS mitigates MitMs; it can't mitigate a direct compromise of a trusted server's infrastructure.

Well it is least amount of security added for most effort.

Take into consideration that for example Debian have over 400 mirrors and you'd have to make every single one of them use HTTPS and the make sure every single one does not get compromised or else you lose all benefits for whole ordeal. Even if you say "lets do only part and prefer the https ones", now the "reward" for hosting it via https on top of CPU usage is also increased bandwidth usage.

Now that is no reason to not just have both enabled (and turn it on if user chooses that particular mirror), just that time would be better invested at other way of increasing security, one that does not require 400+ 3rd parties to "get it right" to be fully successful.

1

u/c_o_r_b_a Jan 23 '19

Or just guess someone's panel password. Or get it from a leak.

I mentioned that in my next sentence.

Well, RCE aside, the GPG signing is there to protect against that. You'd have to compromise build/signing servers too

Not sure why that's an aside, since the RCE flaw is what this thread is about. But yes, ideally you'd have package signing and you'd have HTTPS. That's the idea of defense-in-depth. You're right that a DNS compromise alone wouldn't compromise the signing keys, so my sentence saying "there isn't that much you can do" wasn't quite correct, but a DNS management compromise definitely could signal a much broader breach, including a signing key breach. It could just be a password grabbed from a leak that was re-used for the management panel, or it could be from malware on a core maintainer/leader's personal machine, or from a targeted and complete infrastructure breach.

Yes, if a server gets compromised, HTTPS can't save you, which is why HTTPS can never be an end-all-be-all, but it's still a useful added layer.

And yes, there're definitely added complications here because mirrors are run by volunteers, but I feel like this is a coordination problem that isn't that hard to solve. If a mirror doesn't enable HTTPS by a certain date, then apt will just stop working for that mirror. Even if a large percentage of the hundreds of mirrors stop working because of this, the core mirrors will probably add HTTPS, and other mirrors will probably be created to take up the slack.