Shostack + Friends Blog

 

Secure updates: A threat model

[no description provided] Software updates

Post-Petya there have been a number of alarming articles on insecure update practices. The essence of these stories is that tax software, mandated by the government of Ukraine, was used to distribute the first Petya, and that this can happen elsewhere. Some of these stories are a little alarmist, with claims that unnamed "other" software has also been used in this way. Sometimes the attack is easy because updates are unsigned, other times its because they're also sent over a channel with no security.

The right answer to these stories is to fix the damned update software before people get more scared of updating. That fear will survive long after the threat is addressed. So let me tell you, [as a software publisher] how to do secure upadtes, in a nutshell.

The goals of an update system are to:

  1. Know what updates are available
  2. Install authentic updates that haven't been tampered with
  3. Strongly tie updates to the organization whose software is being updated. (Done right, this can also enable whitelisting software.)

Let me elaborate on those requirements. First, know what updates are available — the threat here is that an attacker stores your message "Version 3.1 is the latest revision, get it here" and sends it to a target after you've shipped version 3.2. Second, the attacker may try to replace your update package with a new one, possibly using your keys to sign it. If you're using TLS for channel security, your TLS keys are only as secure as your web server, which is to say, not very. You want to have a signing key that you protect.

So that's a basic threat model, which leads to a system like this:

  1. Update messages are signed, dated, and sequenced. The code which parses them carefully verifies the signatures on both messages, checks that the date is later than the previous message and the sequence number is higher. If and only if all are true does it...
  2. Get the software package. I like doing this over torrents. Not only does that save you money and improve availability, but it protects you against the "Oh hello there Mr. Snowden" attack. Of course, sometimes a belief that torrents have the "evil bit" set leads to blockages, and so you need a fallback. [Note this originally called the belief "foolish," but Francois politely pointed out that that was me being foolish.]
  3. Once you have the software package, you need to check that it's signed with the same key as before.
    Better to sign the update and the update message with a key you keep offline on a machine that has no internet connectivity.
  4. Since all of the verification can be done by software, and the signing can be done with a checklist, PGP/GPG are a fine choice. It's standard, which means people can run additional checks outside your software, it's been analyzed heavily by cryptographers.

What's above follows the four-question framework for threat modeling: what are we working on? (Delivering updates securely); what can go wrong? (spoofing, tampering, denial of service); what are we going to do about it? (signatures and torrents). The remaining question is "did we do a good job?" Please help us assess that! (I wrote this quickly on a Sunday morning. Are there attacks that this design misses? Defenses that should be in place?)