ikev2: Only accept initial messages in specific states
The previous code allowed an attacker to slip in an IKE_SA_INIT with both SPIs and MID 1 set when an IKE_AUTH would be expected instead. References #816.
This commit is contained in:
@@ -1304,17 +1304,16 @@ METHOD(task_manager_t, process_message, status_t,
|
|||||||
{
|
{
|
||||||
if (mid == this->responding.mid)
|
if (mid == this->responding.mid)
|
||||||
{
|
{
|
||||||
/* reject initial messages once established */
|
/* reject initial messages if not received in specific states */
|
||||||
if (msg->get_exchange_type(msg) == IKE_SA_INIT ||
|
if ((msg->get_exchange_type(msg) == IKE_SA_INIT &&
|
||||||
msg->get_exchange_type(msg) == IKE_AUTH)
|
this->ike_sa->get_state(this->ike_sa) != IKE_CREATED) ||
|
||||||
|
(msg->get_exchange_type(msg) == IKE_AUTH &&
|
||||||
|
this->ike_sa->get_state(this->ike_sa) != IKE_CONNECTING))
|
||||||
{
|
{
|
||||||
if (this->ike_sa->get_state(this->ike_sa) != IKE_CREATED &&
|
DBG1(DBG_IKE, "ignoring %N in IKE_SA state %N",
|
||||||
this->ike_sa->get_state(this->ike_sa) != IKE_CONNECTING)
|
exchange_type_names, msg->get_exchange_type(msg),
|
||||||
{
|
ike_sa_state_names, this->ike_sa->get_state(this->ike_sa));
|
||||||
DBG1(DBG_IKE, "ignoring %N in established IKE_SA state",
|
return FAILED;
|
||||||
exchange_type_names, msg->get_exchange_type(msg));
|
|
||||||
return FAILED;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!this->ike_sa->supports_extension(this->ike_sa, EXT_MOBIKE))
|
if (!this->ike_sa->supports_extension(this->ike_sa, EXT_MOBIKE))
|
||||||
{ /* with MOBIKE, we do no implicit updates */
|
{ /* with MOBIKE, we do no implicit updates */
|
||||||
|
|||||||
Reference in New Issue
Block a user