Commit Graph

16680 Commits

Author SHA1 Message Date
Tobias Brunner 3f003e5e21 Merge branch 'cert-chain-fixes'
This fixes several issues that came up via BSI's Certification Path
Validation Test Tool (CPT):

 1) In compliance with RFC 4945, section 5.1.3.2, we now enforce that a
    certificate used for IKE authentication either does not contain a keyUsage
    extension (like the ones produced by pki --issue) or that they include
    digitalSignature or nonRepudiation.

 2) CRLs that are not yet valid are now rejected as that could be a
    problem in scenarios where expired certificates are removed from CRLs and
    the clock on the host doing the revocation check is trailing behind that
    of the host issuing CRLs.

 3) Results other than revocation (e.g. a skipped check because the CRL
    couldn't be fetched) are now stored also for intermediate CA certificates
    and not only for end-entity certificates, so a strict CRL policy can be
    enforced in such cases.
2018-05-22 09:52:08 +02:00
Tobias Brunner 9746c308ff testing: Add ikev2/multi-level-ca-skipped scenario 2018-05-22 09:50:47 +02:00
Tobias Brunner 0cf3549675 revocation: Fix memory leak if fetching CRL/OCSP fails
We might get a 404 error page back.
2018-05-22 09:50:47 +02:00
Tobias Brunner cae43b890a revocation: Set defaults if CRL/OCSP checking is disabled in config 2018-05-22 09:50:47 +02:00
Tobias Brunner b00d3adbd1 revocation: Also store validation results for intermediate CA certificates
If the certificate is revoked, we immediately returned and the chain was
invalid, however, if we couldn't fetch the CRL that result was not stored
for intermediate CAs and we weren't able to enforce a strict CRL policy
later.
2018-05-22 09:50:47 +02:00
Tobias Brunner 13f76a241c revocation: Ignore CRLs that are not yet valid
Using such CRLs can be a problem if the clock on the host doing the
revocation check is trailing behind that of the host issuing CRLs in
scenarios where expired certificates are removed from CRLs.  As revoked
certificates that expired will then not be part of new CRLs a host with
trailing clock might still accept such a certificate if it is still
valid according to its system clock but is not contained anymore in the
not yet valid CRL.
2018-05-22 09:50:47 +02:00
Tobias Brunner 9c6b102ee0 openssl: Fail CRL validity check if thisUpdate is in the future 2018-05-22 09:50:47 +02:00
Tobias Brunner a0902d1ae0 x509: Fail CRL validity check if thisUpdate is in the future 2018-05-22 09:50:47 +02:00
Tobias Brunner 6143f926ef ike: Reject certificates that are not compliant with RFC 4945 2018-05-22 09:50:47 +02:00
Tobias Brunner 504e12326d openssl: Set IKE compliance flag depending on keyUsage 2018-05-22 09:50:47 +02:00
Tobias Brunner 920366e688 x509: Set IKE compliance flag depending on keyUsage 2018-05-22 09:50:47 +02:00
Tobias Brunner 9fcf4fdda1 x509: Add flag that marks compliance with RFC 4945
According to RFC 4945, section 5.1.3.2, a certificate for IKE must
either not contain the keyUsage extension, or, if it does, have at least
one of the digitalSignature or nonReputiation bits set.
2018-05-22 09:50:47 +02:00
Tobias Brunner 598096e7a2 Merge branch 'dhcp-fixes'
Fixes some issues in the dhcp plugin like avoiding ICMP port unreachables
when setting a specific server address, or increasing the maximum size for
options e.g. for DNs in the client identifier option. The latter is also
only sent now if identity_lease is enabled (for most DHCP servers it
serves the same function as a unique MAC address does).
2018-05-22 09:44:51 +02:00
Tobias Brunner 7b660944b6 dhcp: Only send client identifier if identity_lease is enabled
The client identifier serves as unique identifier just like a unique MAC
address would, so even with identity_leases disabled some DHCP servers
might assign unique leases per identity.
2018-05-18 18:04:01 +02:00
Tobias Brunner 0e5b94d038 dhcp: Increase maximum size of client identification option
This increases the chances that subject DNs that might have been cut
off with the arbitrary previous limit of 64 bytes might now be sent
successfully.

The REQUEST message has the most static overhead in terms of other
options (17 bytes) as compared to DISCOVER (5) and RELEASE (7).
Added to that are 3 bytes for the DHCP message type, which means we have
288 bytes left for the two options based on the client identity (host
name and client identification).  Since both contain the same value, a
FQDN identity, which causes a host name option to get added, may be
142 bytes long, other identities like subject DNs may be 255 bytes
long (the maximum for a DHCP option).
2018-05-18 18:04:01 +02:00
Tobias Brunner 30e886fe3b dhcp: Increase buffer size for options in DHCP messages
According to RFC 2131, the minimum size of the 'options' field is 312
bytes, including the 4 byte magic cookie.  There also does not seem to
be any restriction regarding the message length, previously the length
was rounded to a multiple of 64 bytes.  The latter might have been
because in BOOTP the options field (or rather vendor-specific area as it
was called back then) had a fixed length of 64 bytes (so max(optlen+4, 64)
might actually have been what was intended), but for DHCP the field is
explicitly variable length, so I don't think it's necessary to pad it.
2018-05-18 18:04:01 +02:00
Tobias Brunner 13edecdc20 dhcp: Reduce receive buffer size on send socket
Since we won't read from the socket reducing the receive buffer saves
some memory and it should also minimize the impact on other processes that
bind the same port (Linux distributes packets to the sockets round-robin).
2018-05-18 18:04:01 +02:00
Tobias Brunner becf027cd9 dhcp: Bind server port when a specific server address is specified
DHCP servers will respond to port 67 if giaddr is non-zero, which we set
if we are not broadcasting.  While such messages are received fine via
RAW socket the kernel will respond with an ICMP port unreachable if no
socket is bound to that port.  Instead of opening a dummy socket on port
67 just to avoid the ICMPs we can also just operate with a single
socket, bind it to port 67 and send our requests from that port.

Since SO_REUSEADDR behaves on Linux like SO_REUSEPORT does on other
systems we can bind that port even if a DHCP server is running on the
same host as the daemon (this might have to be adapted to make this work
on other systems, but due to the raw socket the plugin is not that portable
anyway).
2018-05-18 18:04:01 +02:00
Tobias Brunner e8b5c7b94e dhcp: Fix destination port check in packet filter
The previous code compared the port in the packet to the client port and, if
successful, checked it also against the server port, which, therefore, never
matched, but due to incorrect offsets did skip the BPF_JA.  If the client port
didn't match the code also skipped to the instruction after the BPF_JA.
However, the latter was incorrect also and processing would have continued at
the next instruction anyway.  Basically, DHCP packets to any port were accepted.

What's not fixed with this is that the kernel returns an ICMP Port
unreachable for packets sent to the server port (67) because we don't
have a socket bound to it.

Fixes: f0212e8837 ("Accept DHCP replies on bootps port, as we act as a relay agent if server address configured")
2018-05-18 18:04:01 +02:00
Matt Selsky 646a492538 dhcp: Fix typos in comments 2018-05-18 18:04:01 +02:00
Tobias Brunner 3594663166 eap-aka-3gpp: Add test vectors from 3GPP TS 35.207 14.0.0 2018-05-18 17:37:39 +02:00
Tobias Brunner 8dfc40fa20 appveyor: Also build on Windows Server 2016 2018-05-18 17:31:48 +02:00
Tobias Brunner 943f3929f4 pki: --verify command optionally takes directories for CAs and CRLs 2018-05-18 17:29:00 +02:00
Tobias Brunner 667e74d60a bliss: Fix compilation with non-GNU C libraries
Not even the glibc man page mentions that type.

Fixes #2638.
2018-05-14 15:51:42 +02:00
Micah Morton b9fcc61991 Allow strongSwan to be spawned as non-root user
This patch allows for giving strongSwan only the runtime capabilities it
needs, rather than full root privileges.

Adds preprocessor directives which allow strongSwan to be configured to
 1) start up as a non-root user
 2) avoid modprobe()'ing IPsec kernel modules into the kernel, which
    would normally require root or CAP_SYS_MODULE

Additionally, some small mods to charon/libstrongswan ensure that charon
fully supports starting as a non-root user.

Tested with strongSwan 5.5.3.
2018-05-14 15:50:01 +02:00
Tobias Brunner 0d2e18a189 nm: Update NEWS 2018-05-07 12:13:23 +02:00
Tobias Brunner 6e5c00b7c7 nm: Don't hardcode install path for .name file 2018-05-07 12:09:32 +02:00
Tobias Brunner 9c4e4b5e8e nm: Don't rely on NetworkManager.pc for paths when building without libnm-glib
Also make the paths configurable, in case the defaults don't work out on
a certain platform.
2018-05-07 12:09:32 +02:00
Andreas Steffen 43a1839cbc libimcv: Added inactive field to device database table 2018-04-27 12:42:29 +02:00
Andreas Steffen 234ec9225d sw-collector: Added --check option 2018-04-27 11:42:34 +02:00
Tobias Brunner 8929c700ef ikev1: Ignore roam events for IKEv1
We don't have MOBIKE and the fallback to reauthentication does also not
make much sense as that doesn't affect the CHILD_SAs for IKEv1.  So
instead of complicating the code we just ignore roam events for IKEv1
for now.

Closes strongswan/strongswan#100.
2018-04-27 11:13:17 +02:00
Tobias Brunner 4af1fd59dd thread: Properly clean up meta data of thread if pthread_create() fails 2018-04-19 18:22:15 +02:00
Andreas Steffen 69ee158e2a Version bump to 5.6.3dr1 2018-04-19 16:34:06 +02:00
Andreas Steffen 51d5b35f51 testing: Fixed ikev2/alg-chacha20poly1305 scenario 2018-04-19 16:33:04 +02:00
Tobias Brunner a747ad738c ike: Ignore rekeyed and deleted CHILD_SAs when reestablishing IKE_SAs 2018-04-12 16:32:47 +02:00
Tobias Brunner a1620c16ec ike: Remove special handling for routed CHILD_SAs during reauth/reestablish
These are managed in the trap manager, no trap policies will ever be
attached to an IKE_SA (might have been the case in very early releases).
2018-04-12 16:30:28 +02:00
Tobias Brunner 485952ff83 controller: Remove special handling for routed CHILD_SAs when terminating
In very early versions routed CHILD_SAs were attached to IKE_SAs, since
that's not the case anymore (they are handled via trap manager), we can
remove this special handling.
2018-04-12 16:30:28 +02:00
Tobias Brunner 5a7b0be294 proposal: Don't specify key length for ChaCha20/Poly1305
This algorithm uses a fixed-length key and we MUST NOT send a key length
attribute when proposing such algorithms.

While we could accept transforms with key length this would only work as
responder, as original initiator it wouldn't because we won't know if a
peer requires the key length.  And as exchange initiator (e.g. for
rekeyings), while being original responder, we'd have to go to great
lengths to store the condition and modify the sent proposal to patch in
the key length.  This doesn't seem worth it for only a partial fix.
This means, however, that ChaCha20/Poly1305 can't be used with previous
releases (5.3.3 an newer) that don't contain this fix.

Fixes #2614.

Fixes: 3232c0e64e ("Merge branch 'chapoly'")
2018-04-12 16:07:13 +02:00
Tobias Brunner b2163409cc ikev2: Reuse marks and reqid of CHILD_SAs during MBB reauthentication
Since these are installed overlapping (like during a rekeying) we have to use
the same (unique) marks (and possibly reqid) that were used previously,
otherwise, the policy installation will fail.

Fixes #2610.
2018-04-12 15:50:04 +02:00
Tobias Brunner 21553276a3 revocation: Make sure issuer of fetched CRL matches that of the certificate
Unless there is a cRLIssuer listed in the CDP, the CRL should be issued
by the same issuer as the checked certificate.

Fixes #2608.
2018-04-12 15:45:24 +02:00
Tobias Brunner 85bfab621d ike: Float to port 4500 if either port is 500
If the responder is behind a NAT that remaps the response from the
statically forwarded port 500 to a new external port (as Azure seems to be
doing) we should still switch to port 4500 if we used port 500 so far as
it would not have been possible to send any messages to it if it wasn't
really port 500 (we only add a non-ESP marker if neither port is 500).
2018-04-12 15:25:21 +02:00
Tobias Brunner ce0a770c74 Merge branch 'ikev1-down-reauth'
This triggers child_updown() if IKEv1 reauthentication fails due to
retransmits. The SA is also tried to be reestablished.

Fixes #2573.
2018-04-12 15:19:49 +02:00
Tobias Brunner 40ec7f998a _updown: Remove printf calls for identities
This was apparently for compatibility with pluto, which escaped some
characters as octal values.
2018-04-12 15:17:24 +02:00
Tobias Brunner eb82210620 ikev1: Trigger down events for CHILD_SAs if reauthentication failed due to retransmits 2018-04-12 15:17:24 +02:00
Tobias Brunner ebc6defa05 ikev1: Reestablish SAs if reauthentication failed due to retransmits 2018-04-12 15:17:24 +02:00
Tobias Brunner a36d8097ed traffic-selector: Always print protocol if either protocol or port is set
This helps to distinguish between port and protocol if only one of them
is set.  If no protocol is set it's printed as 0, if the traffic
selector covers any port (0-65535) the slash that separates the two values
and the port is omitted.
2018-04-11 12:31:31 +02:00
Tobias Brunner 73382f516e Merge branch 'child-deleted'
This adds a new state for CHILD_SAs that we deleted but still keep
around to process delayed packets (IKEv2 only).  This allows us to treat
them specially in some cases (e.g. to avoid triggering child_updown()
events as we already did that when we deleted such SAs).

Closes strongswan/strongswan#93.
2018-04-09 17:15:24 +02:00
Tobias Brunner 3a3136ef33 bus: Don't trigger child_updown for deleted CHILD_SAs
These were rekeyed but have not been destroyed yet.
2018-04-09 17:13:41 +02:00
Tobias Brunner 16898026a5 child-sa: Add new state to track deleted but not yet destroyed CHILD_SAs
This allows us to easily identify SAs we keep around after a rekeying to
process delayed packets.
2018-04-09 17:13:41 +02:00
Afschin Hormozdiary e873544080 ikev1: Unify child_updown calls when having duplicate QMs
If a Quick mode is initiated for a CHILD_SA that is already installed
we can identify this situation and rekey the already installed CHILD_SA.

Otherwise we end up with several CHILD_SAs in state INSTALLED which
means multiple calls of child_updown are done. Unfortunately,
the deduplication code later does not call child_updown() (so up and down
were not even).

Closes strongswan/strongswan#95.
2018-04-09 15:06:48 +02:00