-
Notifications
You must be signed in to change notification settings - Fork 424
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
Unsigned Overflow in coap_update_token at coap_pdu.c at coap_update_token Function #1351
Comments
Given that the hexstream is being sent to the running server, this is not getting done by the examples client, so I am not able to reproduce the client issue. However, one of the hexstream values is invalid, which the examples server correctly reports there are issues with the data, but the Sanitizer does not complain. The bad hexstream entry is
|
Thank you for your reply. The hexstream was sent to the server using the following command: |
Doing that only exercises the server logic (the The issue in the |
Please see #1352 for a fix. Please confirm this fixes what you are trying to do as I cannot reproduce your client side actual issue with the information you have given us. Please note that this is a false positive that is reported. |
I tried to reproduce the crash again and no error was found. Thanks for the fix. |
Thanks for the feedback. Changes now merged into the develop branch. |
Hello, when I tried to reproduce this vulnerability, I sent the data packet to the server through the following script
I have observed that the server is constantly creating new sessions, which seems inconsistent with the behavior recorded in client.log.
Is there something wrong with my sending script? |
If you look at the server output, you will see that the source port (50912 40207) is changing per Try using the |
Environment
libcoap Configuration Summary
libcoap package version : "4.3.4"
libcoap package source : "v4.3.4-82-g0a39b6c0"
libcoap API version : "3"
libcoap ABI version : "3.1.2"
libcoap libtool SO version : "4.2.1"
libcoap DTLS lib extn : "-gnutls"
host system : "x86_64-pc-linux-gnu"
build with server support : "yes"
build with client support : "yes"
build with IPv4 support : "yes"
build with IPv6 support : "yes"
build with Unix socket support : "yes"
build with TCP support : "yes"
build DTLS support : "yes"
--> GnuTLS around : "yes" (found GnuTLS 3.6.13)
GNUTLS_CFLAGS : "-I/usr/include/p11-kit-1"
GNUTLS_LIBS : "-lgnutls"
add default names : "yes"
build Observe Persist : "yes"
build using epoll : "yes"
enable small stack size : "no"
enable separate responses : "yes"
enable OSCORE support : "yes"
enable Q-Block support : "yes"
enable max logging level : "none"
enable thread safe code : "yes"
enable recursive lock check : "yes"
build doxygen pages : "no"
build man pages : "no"
build unit test binary : "no"
build examples : "yes"
install examples source : "yes"
build with gcov support : "no"
build shared library : "no"
build static library : "yes"
Problem Description
After sending a sequence of messages to the CoAP server, a runtime error was reported by UndefinedBehaviorSanitizer (UBSan). The error indicated an unsigned integer overflow occurred in
coap_pdu.c
at the line where an address calculation was being performed. Specifically, an unsigned offset addition to a base address resulted in an overflow, indicating that the calculated address wrapped around to a lower value than the original address. This is a sign of undefined behavior due to integer overflow during pointer arithmetic. This suggests that the resulting address calculation wrapped around, which is indicative of undefined behavior in the program.Expected Behavior
The server is expected to handle a sequence of incoming messages reliably without encountering arithmetic overflows or other undefined behaviors during address calculations. Memory operations should remain within their allocated bounds, and all pointer arithmetic should result in valid memory addresses that are within the expected range.
Actual Behavior
The server exhibited undefined behavior after processing a sequence of messages, indicating a potential flaw in the address calculation within the coap_update_token function.
Steps to reproduce
libcoap
project:libcoap
directory and clear any previous configurations:cd libcoap bash ./autogen.sh --clear
hexstream.txt
Debug Logs
log of client :
client log.txt
Here is the UBSan report:
The text was updated successfully, but these errors were encountered: