Reject initial exchange messages early once IKE_SA is established
authorMartin Willi <martin@revosec.ch>
Thu, 2 Aug 2012 10:50:31 +0000 (12:50 +0200)
committerMartin Willi <martin@revosec.ch>
Thu, 2 Aug 2012 11:04:54 +0000 (13:04 +0200)
src/libcharon/sa/ike_sa.c

index a13a7a3..7f5accc 100644 (file)
@@ -1205,6 +1205,24 @@ METHOD(ike_sa_t, process_message, status_t,
        {       /* do not handle messages in passive state */
                return FAILED;
        }
+       switch (message->get_exchange_type(message))
+       {
+               case ID_PROT:
+               case AGGRESSIVE:
+               case TRANSACTION:
+               case IKE_SA_INIT:
+               case IKE_AUTH:
+                       if (this->state != IKE_CREATED &&
+                               this->state != IKE_CONNECTING)
+                       {
+                               DBG1(DBG_IKE, "ignoring %N in established IKE_SA state",
+                                        exchange_type_names, message->get_exchange_type(message));
+                               return FAILED;
+                       }
+                       break;
+               default:
+                       break;
+       }
        if (message->get_major_version(message) != this->version)
        {
                DBG1(DBG_IKE, "ignoring %N IKEv%u exchange on %N SA",