Files
libcoap/include/coap2
Jon Shallow 15b42e9faa Possible to crash coap-server with uncompleted (D)TLS handshakes
For any TLS implementation, it is possible to crash the coap-server by
initiating (D)TLS handshakes but never completing them, thus continuing to use
more RAM.  Each partially completed handshake is left in the endpoint->sessions
chain in a state of COAP_SESSION_STATE_HANDSHAKE and unless
endpoint->max_idle_sessions is deliberately configured, these sessions will
never get deleted.

A cause of partially completed handshakes is when there is a PSK mismatch.

Furthermore, unnecessary CPU usage is used to search down long lists held in
endpoint->sessions.

This fix limits the  number of these sessions in a handshake state to the
number defined by endpoint->max_handshake_sessions if non zero or 100 to prevent
memory exhaustion.  By default, endpoint->max_handshake_sessions is 0.

Sessions in state COAP_SESSION_STATE_HANDSHAKE will get timed out after 30
seconds of inactivity.

This does not prevent a DOS attack by creating max_handshake_sessions as a
genuine new session will fail to get responded to until the number of current
COAP_SESSION_STATE_HANDSHAKE sessions drop.  However, the use of Cookie
exchanges by the underlying TLS library prior to a new session being created
and added into endpoint->sessions will filter out a lot of the DOS attacks.

include/coap2/coap_session.h

New default definition for COAP_DEFAULT_MAX_HANDSHAKE_SESSIONS
New default definition for COAP_PARTIAL_SESSION_TIMEOUT_TICKS

include/coap2/net.h

Include max_handshake_sessions in coap_context_t

src/coap_session.c

In coap_endpoint_get_session() check the number of sessions in
COAP_SESSION_STATE_HANDSHAKE and handle accordingly when limits are hit, or
they need to be timed out.
2018-12-18 16:14:03 +00:00
..
2018-10-17 15:10:38 +02:00
2018-11-24 13:59:47 +01:00