One character, one dead IKE daemon
TL;DR — In libreswan 4.6 through 5.3, an
unauthenticated attacker who can reach UDP 500 can crash the
pluto IKE daemon by sending a single malformed IKEv2
fragment. The bug is an off-by-one in an assertion; the fix is one
character. No remote code execution — availability only.
This page accompanies the first public proof-of-concept, validated A/B against source builds of 5.3 (crashes) and 5.3.1 (survives).
01The bug
reassemble_v2_incoming_fragments() in
programs/pluto/ikev2_message.c contains this invariant:
passert(md->digest_roof < elemsof(md->digest)); /* PAYLIMIT == 30 */
md->digest is a fixed array of PAYLIMIT
(30) payload descriptors; digest_roof is the number of
entries in use. A message carrying exactly 30 well-formed payloads is a
legal state — the parser caps at 30 — but the
assertion demands strictly less. The fix changes < to
<=:
- passert(md->digest_roof < elemsof(md->digest));
+ passert(md->digest_roof <= elemsof(md->digest));
Because the assertion lives in the fragment-reassembly path, the trigger is not simply “send 30 payloads”. It has to be an IKE fragment message that completes:
- complete an ordinary, unauthenticated IKE_SA_INIT (Diffie-Hellman only),
- negotiate IKE fragmentation (Notify 16430),
- send one IKE_AUTH message that is a single fragment
(
SKF, number 1 of 1) whose outer chain carries 29 Notify payloads plus the SKF — 30 known payloads in total.
The single fragment completes immediately, reassembly runs, and the
assertion fires. pluto aborts. A repeated stream keeps it
down.
02Why a handshake, but no credentials
The SKF payload has to decrypt and pass ICV verification, which is
why the attacker performs the IKE_SA_INIT exchange and derives
SKEYSEED, SK_ei and SK_ai per
RFC 7296. No credentials are involved: IKE_AUTH authentication happens
after the crash point.
| Parameter | Value used by the PoC |
|---|---|
| Encryption | AES-CBC-128 |
| PRF / integrity | HMAC-SHA2-256 / HMAC-SHA2-256-128 |
| DH group | MODP2048 (group 14) |
| Key schedule | SKEYSEED = prf(Ni|Nr, g^ir), then prf+ over Ni|Nr|SPIi|SPIr |
| Quirk | libreswan’s prf+ appends the counter after the seed — match the implementation, not the RFC text |
03Reproducing it
The lab is two network namespaces joined by a veth pair —
nothing touches the host’s real interfaces. Build libreswan 5.3
(vulnerable) and 5.3.1 (fixed) from source, start pluto in
one namespace, run the PoC from the other.
./lab/pluto-start.sh 5.3
sudo ip netns exec atk ./venv/bin/python poc/ikev2_frag_dos.py 10.99.0.1
./lab/pluto-alive.sh # -> DEAD
Observed on 5.3:
received IKE_AUTH request fragment 1 (1 of 1), computing DH in the background
FATAL: ASSERTION FAILED: md->digest_roof < (sizeof(md->digest) / sizeof(*(md->digest)))
(reassemble_v2_incoming_fragments() +977 programs/pluto/ikev2_message.c)
On 5.3.1 the same packet is reassembled, the bogus inner payload is
rejected with INVALID_SYNTAX, the IKE SA is deleted —
and the daemon stays up.
04Impact and mitigation
CVSS 3.1 7.5 (High):
AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H. Availability only;
the vendor states no RCE is possible. Any IKEv2 responder with
fragmentation enabled (the default) is exposed. IKEv1 is not
affected.
- Upgrade to libreswan 5.3.1 or later (fix commit
5c4369afcf). RHEL errata: ALSA-2026:46396, 46397, 46398. - If fragmentation is not needed:
fragmentation=noon IKEv2 connections. If it is needed, there is no workaround — patch. - Detection:
plutorestarts correlated with IKE traffic; log lines containingASSERTION FAILEDandreassemble_v2_incoming_fragments; IKE_AUTH messages with ~30 payloads.
05Credits
The vulnerability was reserved as CVE-2026-12413 on 2026-06-16 and
disclosed on 2026-07-02. It was found by Hu Xinyao and
fixed by the libreswan project (commit
5c4369afcfe95a924ee0a96a0b29a7204dc40504, released in
5.3.1). This writeup and the PoC are a post-disclosure reproduction:
the bug is patched, and the goal is to give defenders a concrete test
case and researchers a starting point for fragment-handling audits in
other IKE stacks.
06Resources
- Vendor advisory: libreswan.org/security/CVE-2026-12413
- PoC repository: github.com/Mohammad-Jafar-Shabib/CVE-2026-12413-libreswan-poc
- CVE record: cve.org/CVERecord?id=CVE-2026-12413