Skip to content

Fix CID server-role handling and send-buffer bounds - #1

Open
svdwalt007 wants to merge 1 commit into
mrdeep1:connection_idfrom
svdwalt007:fix-cid-server-and-bounds
Open

svdwalt007 wants to merge 1 commit into
mrdeep1:connection_idfrom
svdwalt007:fix-cid-server-and-bounds

Conversation

@svdwalt007

Copy link
Copy Markdown

Two fixes on top of eclipse-tinydtls#302.

  1. Server role. dtls_check_tls_extension() is also used for received ClientHellos. A connection_id extension there was parsed and its CID stored as write_cid, but dtls_send_server_hello() never echoes the extension, so a server would send tls12_cid records that were never negotiated (RFC 9146, section 3). Only the client side is implemented, so the extension is now ignored in a ClientHello.

  2. Send-buffer bounds. dtls_prepare_record() did not include cid_length in its size checks. The CID, the inner content type byte and the AEAD tag could overrun a nearly full buffer by up to DTLS_MAX_CID_LENGTH bytes. Each write is now checked first.

Tested: library builds; dtls-client -z against dtls-server over loopback (PSK) completes the handshake. The server-role fix is not exercised by that test, because the client offers an empty CID; it needs a peer that offers a non-empty CID. I have not tested against a CID-capable third-party server.

A ClientHello carrying a connection_id extension was parsed on the
server side and its CID stored as write_cid, but the ServerHello never
echoes the extension. A server would then send tls12_cid records that
were not negotiated (RFC 9146, section 3). Only the client side is
implemented, so ignore the extension in a ClientHello.

dtls_prepare_record() did not account for the CID in its send-buffer
checks: the CID, the inner content type and the AEAD tag were written
or counted without cid_length, so a nearly full buffer could be
overrun by up to DTLS_MAX_CID_LENGTH bytes. Check before each write.
@svdwalt007

Copy link
Copy Markdown
Author

@mrdeep1 - is it possible to accept this PR and merge and push the upstream to do same... ? would be good to get this CID functionality into tinyDTLS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants