-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Buffer Over-read Affecting Fragmentation Feature #54
Comments
Thanks! Opening the issue here in Github is exactly the correct way to proceed. |
@bathooman There is a fix to the feature/handshake_fragmentation branch at #62 for testing out. |
Hello, Unfortunately, the pull request does not address the mentioned bug in any way. I reviewed the new check and it appears that it checks for fragmented Regards, |
I was not able to reproduce the original reported issue. Complicated by multiple issues raised with the same named zip file containing different files to reproduce an issue across the multiple issues raised. Furthermore, the contents of the example patch files (to de-randomize some items) did not match the content of the source files (even after ignoring the helpful additions of assert(). In this case, With the #62 code are you still able to reproduce a similar issue for any other handshake message? |
With your code (untouched other than to add in the
Hence my fix. |
@bathooman #62 has been updated which should fix your initially reported issue. |
Dear @mrdeep1 The |
Yes, #62 fixes this issue from my perspective when testing with the latest provided zip file. |
Thank you for the PR. However, unfortunately, The PR partially solves the issue. Suppose you have a fragmented Everything is fine with the In Best, |
Dear @mrdeep1 PR #62 resolves the memory error when we are reassembling the fragments. It is also very nice in the sense that it solves the non-conformance bugs regarding Note that the I suggest that TinyDTLS always uses the real data length instead of the values different fields contain. Best, |
@bathooman It is good that you are doing all this code checking - thanks. There are two distinct branches of code here It is my belief that the over-read by one is fixed in develop's #61. |
Yes. If Best, |
Hello,
I have tried to submit this through Eclipse Bugzilla. However, apparently, the dedicated page for TinyDTLS has been removed or I did not have access to it. The following over-read has been found by using symbolic execution technique. Suppose you have a
Client Key Exchange
message with the following values for the mentioned fields:length
in the record layer = 25length
in the handshake layer = 51fragment length
= 16fragment offset
= 0When we are handling the message (in
dtls_handle_message()
),data_length = decrypt_verify(peer, msg, rlen, &data)
is called. It returns a pointer to the first offset of the handshake layer (uint8 *data
) and the real size of the handshake layer (data_length = 25
). Later, as we havepacket_length=51 > fragment_length=16
, we start the reassembling process. the message also passfragment_offset=0 + fragment_length=16 <= packet_length=51
check. Finally, after allocating memory on the heap (peer->handshake_params->reassemble_buf->data
), when we are going to copy the message (memcpy) into the newly allocated buffer, we use the combination offragment offset
andfragment length
to derive the size of the handshake message and the pointer (data
) as it points to the first offset of the handshake layer. Let me remind you that the valid range fordata
is 25 (=data_length
). However, in this scenario, the size (fragment_length=16 + handshake_header_size=12) is 28. Therefore, there is a 3-byte overread happening.I have attached the means to reproduce the mentioned bug. To do so, after downloading the suite, in
tinydtls-witness/tests
, execute the scriptsetupserver.sh
to compileTinyDTLS
. Note that, I have de-randomized TinyDTLS for this demonstration and the patch is available intinydtls-witness/tests/patches
. Successful execution ofsetupserver.sh
will rundtls-server
on port 20220. Now, executing./reproduce.sh
intinydtls-witness/tests
should causedtls-server
to crash.The malformed
Client Key Exchange
can be found intinydtls-witness/tests/testcases
.I hope I could explain it understandably.
tinydtls-witness.zip
Best wishes,
Hooman Asadian
The text was updated successfully, but these errors were encountered: