111 Commits

Author SHA1 Message Date
Tobias Brunner
8ce78e43a4 ikev2: Add task that verifies a peer's certificate
On failure the SA is deleted and reestablished as configured.  The task
is activated after the REAUTH_COMPLETE task so a make-before-break reauth
is completed before the new SA might get torn down.
2016-03-10 11:07:15 +01:00
Tobias Brunner
034a462901 ikev2: Initiate other tasks after a no-op task 2016-03-10 11:07:14 +01:00
Tobias Brunner
fb7cc16d67 ikev2: Allow tasks to verify request messages before processing them 2016-03-04 16:03:00 +01:00
Tobias Brunner
4b83619310 ikev2: Allow tasks to verify response messages before processing them 2016-03-04 16:03:00 +01:00
Tobias Brunner
0840385b27 ike-redirect: Add task to redirect active IKE_SAs 2016-03-04 16:02:59 +01:00
Tobias Brunner
1507647434 unknown-payload: Use a new private payload type and make original type available
This fixes a DoS and potential remote code execution vulnerability that was
caused because the original payload type that was returned previously was
used to cast such payload objects to payloads of the indicated type (e.g.
when logging notify payloads with a payload type for the wrong IKE version).

Fixes CVE-2015-3991.
2015-06-01 09:42:11 +02:00
Martin Willi
799f4c5db9 ikev2: Don't set old IKE_SA to REKEYING state during make-before-break reauth
We are actually not in rekeying state, but just trigger a separate, new IKE_SA
as a replacement for the current IKE_SA. Switching to the REKEYING state
disables the invocation of both IKE and CHILD_SA updown hooks as initiator,
preventing the removal of any firewall rules.

Fixes #885.
2015-03-11 14:48:08 +01:00
Tobias Brunner
dd0ebb5483 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.
2015-03-04 13:47:53 +01:00
Tobias Brunner
eb25190629 ikev2: Don't destroy the SA if an IKE_SA_INIT with unexpected MID is received
This reverts 8f727d800751 ("Clean up IKE_SA state if IKE_SA_INIT request
does not have message ID 0") because it allowed to close any IKE_SA by
sending an IKE_SA_INIT with an unexpected MID and both SPIs set to those
of that SA.

The next commit will prevent SAs from getting created for IKE_SA_INIT messages
with invalid MID.

Fixes #816.
2015-03-04 13:47:53 +01:00
Martin Willi
3676023e54 ikev2: Schedule a make-before-break completion task to delete old IKE_SA 2015-02-20 13:34:57 +01:00
Martin Willi
52bd3b8ef9 ikev2: Allow task to skip exchange by setting undefined exchange type 2015-02-20 13:34:57 +01:00
Martin Willi
349f7f2412 ikev2: Trigger make-before-break reauthentication instead of reauth task 2015-02-20 13:34:57 +01:00
Tobias Brunner
fac310a467 ike: Make check for known payloads depend on IKE version 2014-12-05 15:41:46 +01:00
Tobias Brunner
f1aa18b2e8 ikev2: Send retransmits using the latest known addresses
For instance, if a DPD exchange is initiated by the gateway when a
mobile client is roaming and it then gets a new IP address and sends
an address update via MOBIKE, the DPD retransmits would still be sent
to the old address and the SA would eventually get closed.
2014-10-10 09:32:41 +02:00
Tobias Brunner
b678d9e14f ikev2: Send and receive fragmented IKE messages
If a fragmented message is retransmitted only the first packet is passed
to the alert() hook.
2014-10-10 09:32:41 +02:00
Tobias Brunner
9e3ab0d114 ikev2: Reorder task activation for established IKE SAs
We now prefer MOBIKE tasks over delete tasks then the rest.
2014-09-25 10:16:45 +02:00
Tobias Brunner
b3a7ba14f1 Revert "ikev2: Insert MOBIKE tasks at the front of the queue"
This reverts commit 3293d146289d7c05e6c6089ae1f7cdbcea378e63.

The position of tasks in the queue does not actually determine the order
in which they are activated.  Instead this is determined by the
statements in task_manager_v2_t.initiate().
2014-09-25 10:16:45 +02:00
Tobias Brunner
22949c590f ikev2: Don't treat initial messages as MOBIKE exchanges
The MOBIKE task is active during the initial exchanges but we don't want
to treat them as actual MOBIKE exchanges (i.e. there is no path probing).
2014-09-16 15:05:12 +02:00
Tobias Brunner
acd69fc291 ikev2: Reduce timeout if path probing was enabled 2014-09-12 10:29:37 +02:00
Tobias Brunner
de6ab8e85a ikev2: Defer MOBIKE updates if no path is available 2014-09-12 10:29:37 +02:00
Tobias Brunner
10bad0fc23 ikev2: Defer path probing if no path is currently available
We do the same before initiating the task, so we should probably do it
too when we already initiated it, not just time out and destroy the SA.
2014-09-12 10:29:37 +02:00
Tobias Brunner
1b17f647a5 ikev2: Enable path probing for currently active MOBIKE task
This might not be the case if e.g. an address appeared but the old one
is still available but not actually usable.  Without this the MOBIKE
task would eventually time out even though we might be able to switch
to a working address.
2014-09-12 10:29:36 +02:00
Tobias Brunner
3293d14628 ikev2: Insert MOBIKE tasks at the front of the queue
In case we have no usable path to the other peer there is no point in
initiating any other tasks (like rekeying).
2014-09-12 10:29:36 +02:00
Martin Willi
3ecfc83c6b payload: Use common prefixes for all payload type identifiers
The old identifiers did not use a proper namespace and often clashed with
other defines.
2014-06-04 15:53:03 +02:00
Martin Willi
8503077175 ikev2: Reject CREATE_CHILD_SA exchange on unestablished IKE_SAs
Prevents a responder peer to trick us into established state by starting
IKE_SA rekeying before the IKE_SA has been authenticated during IKE_AUTH.

Fixes CVE-2014-2338.
2014-04-14 13:29:49 +02:00
Tobias Brunner
d223fe807a libcharon: Use lib->ns instead of charon->name 2014-02-12 14:34:32 +01:00
Thomas Egerer
b190899473 ike_sa: Defer task manager destruction after child destruction
This patch exports the task manager's flush to allow flushing of all
queues with one function call from ike_sa->destroy. It allows the
access of intact children during task destructoin (see git-commit
e44ebdcf) and allows the access of the task manager in
child_state_change hook.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2014-01-16 14:16:13 +01:00
Tobias Brunner
1dd58b0e21 Fixed some typos 2013-10-29 11:44:23 +01:00
Tobias Brunner
561f94ae58 ikev2: Force an update of the host addresses on the first response
This is especially useful on Android where we are able to send messages
even if we don't know the correct local address (this is possible
because we don't set source addresses in outbound messages).  This way
we may learn the correct local address if it e.g. changed right before
reestablishing an SA.

Updating the local address later is tricky without MOBIKE as the
responder might not update the associated IPsec SAs properly.
2013-09-23 11:50:12 +02:00
Tobias Brunner
4dc8978000 ikev2: Only schedule half-open-timeout delete job after successfully handling IKE_SA_INIT
We want to avoid this allocation if the initial message is invalid (e.g.
if the message ID is != 0).
2013-07-29 11:25:43 +02:00
Tobias Brunner
68db844f99 ike: Migrate queued CHILD_SA-creating tasks when reestablishing an IKE_SA 2013-07-17 18:16:58 +02:00
Martin Willi
6207fadb6c ikev2: replace linked lists by arrays in task manager
Eliminates another three lists, 0.5KB per IKE_SA.
2013-07-17 17:20:18 +02:00
Martin Willi
ca74bf7a06 ikev2: close an established IKE_SA when receiving AUTHENTICATION_FAILED
RFC 5996 compatible implementations MAY send an INFORMATIONAL message
with an AUTHENTICATION_FAILED if the initiator failed to authenticate us.
Handle such a message like a DELETE for an IKE_SA.
2013-06-11 15:54:26 +02:00
Martin Willi
bee6515a28 Defer CHILD_SA rekeying if allocating an SPI fails 2013-04-03 12:25:27 +02:00
Martin Willi
8f727d8007 Clean up IKE_SA state if IKE_SA_INIT request does not have message ID 0 2013-03-11 11:30:47 +01:00
Martin Willi
cdf75a39e3 Move initial message dropping to task manager
When the last request message of the initial tunnel setup is retransmitted,
we must retransmit the response instead of ignoring the request.

Fixes #295.
2013-02-25 12:12:19 +01:00
Tobias Brunner
2ec3552fce Fix check-in of IKE_SA when IKE_SA_INIT fails and hash table is enabled
Setting the responder SPI to 0 can only be done while generating the
response, otherwise we'd fail to check in the IKE_SA again in case the
hash table is enabled.  That's because we use the responder SPI as hash
value since 5.0.0.
2013-01-24 19:13:40 +01:00
Martin Willi
3c79b7b7db Add alerts for sent/received message retransmissions and timeout 2012-11-29 10:22:51 +01:00
Martin Willi
418f4bc7a5 Raise a bus alert when IKE message body parsing fails 2012-10-24 11:34:30 +02:00
Martin Willi
7910116384 Respect IKE version while selecting an ike_cfg as responder 2012-10-24 10:19:33 +02:00
Tobias Brunner
48651d8d02 Ensure UNSUPPORTED_CRITICAL_PAYLOAD notify contains correct payload type 2012-09-28 22:31:06 +02:00
Tobias Brunner
3babde90bb Trigger ike_updown event caused by retransmits only after reestablish() has been called
This allows listeners to migrate to the new IKE_SA with the
ike_reestablish event without having to worry about an ike_updown event
for the old IKE_SA.
2012-09-06 11:27:28 +02:00
Martin Willi
a5c799602f Make task managers flush_queue() method public 2012-05-21 14:02:35 +02:00
Tobias Brunner
42500c274a Use name from initialization to access settings in libcharon.
Also fixes several whitespace errors.
2012-05-03 13:57:04 +02:00
Martin Willi
b24be29646 Merge branch 'ikev1'
Conflicts:
	configure.in
	man/ipsec.conf.5.in
	src/libcharon/encoding/generator.c
	src/libcharon/encoding/payloads/notify_payload.c
	src/libcharon/encoding/payloads/notify_payload.h
	src/libcharon/encoding/payloads/payload.c
	src/libcharon/network/receiver.c
	src/libcharon/sa/authenticator.c
	src/libcharon/sa/authenticator.h
	src/libcharon/sa/ikev2/tasks/ike_init.c
	src/libcharon/sa/task_manager.c
	src/libstrongswan/credentials/auth_cfg.c
2012-05-02 11:12:31 +02:00
Martin Willi
b1f2f05c92 Merge branch 'ikev1-clean' into ikev1-master
Conflicts:
	configure.in
	man/ipsec.conf.5.in
	src/libcharon/daemon.c
	src/libcharon/plugins/eap_ttls/eap_ttls_peer.c
	src/libcharon/plugins/eap_radius/eap_radius_accounting.c
	src/libcharon/plugins/eap_radius/eap_radius_forward.c
	src/libcharon/plugins/farp/farp_listener.c
	src/libcharon/sa/ike_sa.c
	src/libcharon/sa/keymat.c
	src/libcharon/sa/task_manager.c
	src/libcharon/sa/trap_manager.c
	src/libstrongswan/plugins/x509/x509_cert.c
	src/libstrongswan/utils.h

Applied lost changes of moved files keymat.c and task_manager.c.
Updated listener_t.message hook signature in new plugins.
2012-03-20 17:57:53 +01:00
Martin Willi
a7d3b0e098 Check if we actually have a packet before retransmitting it 2012-03-20 17:31:40 +01:00
Martin Willi
47b8f6ef4b Invoke bus_t.message hook twice, once plain and parsed, once encoded and encrypted 2012-03-20 17:31:37 +01:00
Martin Willi
3a925f74ab Do not query CHILD_SA during delete if they already expired 2012-03-20 17:31:31 +01:00
Martin Willi
8573b18d22 Fixed scheduling of IKEv2 init tasks in a second keyingtry 2012-03-20 17:31:29 +01:00