Preventing quantum downgrade attacks against IPsec Cloudflare worked with the IETF to develop and has released in beta across its IPsec products a mitigation against quantum downgrade attacks on IPsec, addressing a design flaw it rediscovered that lets a quantum attacker decrypt all traffic between post-quantum-capable endpoints. The attack requires a quantum computation performed in real time during the protocol handshake, unlike harvest-now-decrypt-later attacks, and Cloudflare has moved up its post-quantum transition deadline to 2029 as quantum resource estimates for breaking public key cryptography have dropped dramatically. Preventing quantum downgrade attacks against IPsec For Birthday Week, Cloudflare is helping one of the Internet’s core security protocols develop stronger protections against quantum downgrade attacks. To protect our customers and the Internet at large, we worked with the IETF to develop a mitigation against downgrade attacks on IPsec, which we’ve implemented and made available in beta across our IPsec products. The world is racing to build the first generation of quantum computers. These new machines hold great promise, but they also create a new threat: early quantum computers will be capable of cracking cryptography we've relied on for secure communication. To address this, it is necessary to migrate to post-quantum PQ cryptography: cryptography we believe even quantum computers cannot break. Diffie-Hellman key agreement will have to be replaced by PQ key agreement mechanisms such as ML-KEM; classical signature schemes, like ECDSA and RSA, will have to be replaced by PQ schemes such as ML-DSA; and so on. The PQ migration is well underway, and we’re helping the migration along by making post-quantum encryption the default in our products https://developers.cloudflare.com/ssl/post-quantum-cryptography/pqc-cloudflare-products/ , open-sourcing part of our internal cryptography discovery tool http://blog.cloudflare.com/ai-driven-cryptography-discovery , launching new post-quantum visibility features http://blog.cloudflare.com/post-quantum-visibility , and leading the way in the web’s migration to post-quantum certificates. Still, it will take years before all clients and servers on the Internet have been upgraded to post-quantum cryptography. In the meantime, it will be necessary for modern devices to maintain support for classical cryptography in order to connect with today’s endpoints. The need for backwards compatibility creates its own risk. In a downgrade attack , an on-path attacker between a client and server tricks the endpoints into using weaker crypto than they support. It does so by manipulating the messages sent between client and server, making it appear to one party that its peer does not support PQ at all. In other words, a downgrade attack eliminates the protection provided by PQ cryptography by downgrading the victims back to classical, so it can be attacked by a quantum computer. What this means is that merely adding support for the cryptographic primitives themselves is not sufficient to head off the quantum threat. The next frontier in the PQ migration is to prevent active attackers from bypassing PQ by downgrading the connection. In this post, we focus on the IPsec protocol, a central component of a variety of Cloudflare products, namely Cloudflare IPsec, Cloudflare WAN, and Magic Transit. Like all secure channel protocols, including TLS, IPsec is vulnerable to the following simple downgrade attack as long as both classical and post-quantum authentication are supported. An attacker can impersonate a party by cracking its classical credentials and can pretend the party doesn't support PQ. However, several months ago, we discovered — or rather rediscovered, as we'll explain — a design flaw in IPsec that admits a more sophisticated attack that works regardless of which authentication method is used. The vulnerability allows a quantum attacker to decrypt all traffic between PQ-capable endpoints. The attack is relatively hard to pull off, as it requires a quantum computation to be carried out in real time during the protocol handshake. This is different from a harvest-now, decrypt-later attack, where the quantum computation is entirely offline. We don't yet know if and when this attack will be feasible, but recent trends give us ample reason to be cautious: at the time of writing, resource estimates for quantum attacks on public key cryptography have decreased dramatically, leading Cloudflare to move up our transition deadline to 2029. To inoculate IPsec to this threat, we helped the IETF develop an extension https://datatracker.ietf.org/doc/draft-ietf-ipsecme-ikev2-downgrade-prevention/ that adds a downgrade protection mechanism to IPsec. Both parties must support this extension for it to be effective: for our part, Cloudflare has rolled out beta support in Cloudflare WAN and Magic Transit, which customers can now enable by requesting the account managers to turn on the ipsec downgrade protection flag for their accounts. We hope to see the rest of the IPsec ecosystem follow suit in short order. IPsec's place on the Internet Frequent readers of the Cloudflare blog are likely already familiar with the TLS and QUIC protocols. Between them, TLS/QUIC secure virtually all the web traffic transiting the Internet today. Both operate at the transport layer of the network stack: TLS runs over TCP https://www.cloudflare.com/learning/ddos/glossary/tcp-ip/ , while QUIC runs over UDP https://www.cloudflare.com/learning/ddos/glossary/user-datagram-protocol-udp/ . IPsec serves a similar function, but operates at the IP layer. Because IPsec operates at an even lower layer of the network stack than TLS and QUIC, it is deeply rooted in modern network infrastructure. Cloudflare IPsec allows organizations to extend their IPsec connections over Cloudflare’s global anycast network without expensive multiprotocol label switching MPLS https://www.cloudflare.com/learning/network-layer/what-is-mpls/ connections. IPsec is also part of Cloudflare’s Magic Transit https://developers.cloudflare.com/magic-transit/ product. With Magic Transit, Cloudflare’s global anycast network sits in front of an organization’s IP range to shield it from attacks and threats like Distributed Denial of Service DDoS attacks, and then hands the scrubbed traffic back to the organization via IPsec tunnels. Despite being so deeply rooted in today's Internet infrastructure, the IPsec protocol continues to evolve. It has seen many important upgrades in the past several years, including the addition of PQ key agreement https://blog.cloudflare.com/post-quantum-ipsec/ . IPsec is also on track to adopt PQ authentication on about the same timeline as TLS/QUIC. In fact, IPsec is actually further along, depending on how it's configured. A pre-shared key is frequently used for authentication in IPsec, and this is already fully PQ This suggests that the IPsec ecosystem is more than capable of adapting to shifting threats. Background on IPsec Let's now take a peek into the protocol details that are relevant to the downgrade attack. "IPsec" refers to the mechanism used to encrypt IP packets. Before encryption can begin, the endpoints must first perform an authenticated key agreement . They do so using the IKEv2 https://datatracker.ietf.org/doc/rfc7296/ protocol. IKEv2 typically has two phases, called exchanges . In the initial exchange, the initiator advertises the parameters it supports and sends a Diffie-Hellman key share. The responder completes the initial exchange by telling the initiator which parameters it selected and sending its own key share. After the initial exchange, the initiator and responder derive an encryption key from the key shares and encrypt all subsequent exchanges. The key shares are not yet authenticated, meaning each endpoint has no way of knowing where the key share came from. This is accomplished in the authentication exchange, in which the initiator identifies itself to its peer and sends a signature of its key share and advertised parameters. The responder uses the identity to resolve the initiator's credentials and verifies the signature before accepting the new connection. The responder does the same in the authentication message it sends in reply. One crucial detail to point out here: each party only signs its outbound messages , rather than the entire handshake transcript, as in more modern protocols like TLS 1.3. This means the authenticating party never confirms to the relying party that they've observed the same sequence of messages. This will be crucial for the attack. Encrypting handshake messages has two purposes. First, it hides the identity of the endpoints from the network. TLS/QUIC don't have this feature by default, but can enable it using the Encrypted Client Hello https://datatracker.ietf.org/doc/rfc9849/ extension. Second, it allows the endpoints to begin using IPsec's packet fragmentation mechanism, making transmission of long messages over multiple packets more reliable. This is especially relevant to handling large ML-KEM key exchange messages. This protocol relies on classical Diffie-Hellman key exchange, meaning a quantum attacker will eventually be able to derive the encryption key from the exchanged key shares. To mitigate this threat, IKEv2 includes an option https://datatracker.ietf.org/doc/rfc9242/ to run an intermediate exchange following the initial exchange using ML-KEM as the key exchange algorithm: Backwards compatibility. Crucially, this exchange is only performed if the initiator advertises support for it in the initial exchange and the responder agrees to use it. This allows for backwards compatibility with endpoints that don't yet support PQ. In particular, if the responder selects a classical-only key agreement, then the initiator will assume the responder doesn't support PQ and fall back to classical-only. Likewise, if the initiator doesn't advertise support for PQ key agreement, then the responder will assume the initiator doesn't support it. Hello my name is Mallory Let's think about how to exploit this parameter negotiation behavior. We'll start with a simple idea that doesn't quite work, and see what it takes to make it work. Suppose there's an attacker between the endpoints — let's call them Mallory — who has a quantum computer. Mallory can make it appear to the responder that the initiator doesn't support PQ by intercepting the initiator's initial key exchange message, rewriting it to advertise classical-only, and forwarding the modified message to the responder. This would cause the authentication exchange to fail. The initiator signs the message it sent , but the responder verifies the message it received . Since the message received is different from the message sent, verification of the signature would fail, unless the attacker also manages to forge a signature that the responder would accept. That's not all, however: in IKEv2, the authentication messages are encrypted , which means Mallory also needs to compute the encryption key. But this is precisely what the downgrade attack enables: Mallory has already convinced the endpoints to fall back to classical-only, and they can use their quantum computer to recover the encryption key from the Diffie-Hellman key shares. Still, there's no obvious way to forge a signature from the honest initiator, unless Mallory has compromised the initiator's authentication key. A paper from 2016 https://eprint.iacr.org/2016/072 observes the following: because the responder only signs its own outbound messages, it doesn't actually confirm to its peer which initiator identity it accepted. This means the responder will accept an authentication message from any initiator it trusts, not just the initiator of the connection. Suppose Mallory themself is an initiator whose credentials the responder will accept. In this case, Mallory can produce a valid signature using their own credentials . The responder will complete the connection, believing it's talking to Mallory, who is identified by ID in the figure below. Meanwhile, the initiator