CVE-2016-5361: Improper Input Validation (CWE-20)
value: programs/pluto/ikev1.c in libreswan before 3.17 retransmits in initial-responder states, which allows remote attackers to cause a denial of service (traffic amplification) via a spoofed UDP packet. NOTE: the original behavior complies with the IKEv1 protocol, but has a required security update from the libreswan vendor; as of 2016-06-10, it is expected that several other IKEv1 implementations will have vendor-required security updates, with separate CVE IDs assigned to each.
CWE description: The product receives input or data, but it does
        not validate or incorrectly validates that the input has the
        properties that are required to process the data safely and
        correctly.
CVSS v3 base score: 7.5
Published: 2016-06-16T14:59Z
Repository: https://github.com/libreswan/libreswan
Language: C
Files changed: programs/pluto/ikev1.c
Commit date: 2016-03-27 12:31:50 -0400
Commit message: IKEv1: packet retransmit fixes for Main/Aggr/Xauth modes

- Do not schedule retransmits for inI1outR1 packets (prevent DDOS)
- Do schedule retransmits for XAUTH packets

Diff: diff --git a/programs/pluto/ikev1.c b/programs/pluto/ikev1.c
index 67734dfcae..8bc61837ac 100644
--- a/programs/pluto/ikev1.c
+++ b/programs/pluto/ikev1.c
@@ -243,11 +243,11 @@ static const struct state_microcode v1_state_microcode_table[] = {
 	 * HDR, SA --> HDR, SA
 	 */
 	{ STATE_MAIN_R0, STATE_MAIN_R1,
 	  SMF_ALL_AUTH | SMF_REPLY,
 	  P(SA), P(VID) | P(CR), PT(NONE),
-	  EVENT_v1_RETRANSMIT, main_inI1_outR1 },
+	  EVENT_NULL, main_inI1_outR1 },
 
 	/* STATE_MAIN_I1: R1 --> I2
 	 * HDR, SA --> auth dependent
 	 * SMF_PSK_AUTH, SMF_DS_AUTH: --> HDR, KE, Ni
 	 * SMF_PKE_AUTH:
@@ -392,11 +392,11 @@ static const struct state_microcode v1_state_microcode_table[] = {
 	 *           --> HDR, SA, KE, Nr, IDir, [CERT,] SIG_R
 	 */
 	{ STATE_AGGR_R0, STATE_AGGR_R1,
 	  SMF_PSK_AUTH | SMF_DS_AUTH | SMF_REPLY,
 	  P(SA) | P(KE) | P(NONCE) | P(ID), P(VID) | P(NATD_RFC), PT(NONE),
-	  EVENT_v1_RETRANSMIT, aggr_inI1_outR1 },
+	  EVENT_NULL, aggr_inI1_outR1 },
 
 	/* STATE_AGGR_I1:
 	 * SMF_PSK_AUTH: HDR, SA, KE, Nr, IDir, HASH_R
 	 *           --> HDR*, HASH_I
 	 * SMF_DS_AUTH:  HDR, SA, KE, Nr, IDir, [CERT,] SIG_R
@@ -569,16 +569,16 @@ static const struct state_microcode v1_state_microcode_table[] = {
 	  EVENT_SA_REPLACE, modecfg_inR1 },
 
 	{ STATE_XAUTH_I0, STATE_XAUTH_I1,
 	  SMF_ALL_AUTH | SMF_ENCRYPTED | SMF_REPLY | SMF_RELEASE_PENDING_P2,
 	  P(MCFG_ATTR) | P(HASH), P(VID), PT(HASH),
-	  EVENT_SA_REPLACE, xauth_inI0 },
+	  EVENT_v1_RETRANSMIT, xauth_inI0 },
 
 	{ STATE_XAUTH_I1, STATE_MAIN_I4,
 	  SMF_ALL_AUTH | SMF_ENCRYPTED | SMF_REPLY | SMF_RELEASE_PENDING_P2,
 	  P(MCFG_ATTR) | P(HASH), P(VID), PT(HASH),
-	  EVENT_SA_REPLACE, xauth_inI1 },
+	  EVENT_v1_RETRANSMIT, xauth_inI1 },
 
 #undef P
 #undef PT
 };
 

Vulnerable code: 	  EVENT_v1_RETRANSMIT, main_inI1_outR1 },
	  EVENT_v1_RETRANSMIT, aggr_inI1_outR1 },
	  EVENT_SA_REPLACE, xauth_inI0 },
	  EVENT_SA_REPLACE, xauth_inI1 },
Fixed code: 	  EVENT_NULL, main_inI1_outR1 },
	  EVENT_NULL, aggr_inI1_outR1 },
	  EVENT_v1_RETRANSMIT, xauth_inI0 },
	  EVENT_v1_RETRANSMIT, xauth_inI1 },