Commit Graph
3253 Commits
Author SHA1 Message Date
Jon Shallow c46c64bca3 tinydtls: Update to latest version 2026-04-02 12:30:03 +01:00
Jon Shallow 9366f8333e OSCORE: Be more rigorous in boundary checking 2026-04-02 10:37:52 +01:00
Ernestas Kulik 4c6a8f10a4 examples: server: Fix builds without proxy support
d33b7fa571 adds a call to setup_cpsk(),
which is only defined with COAP_PROXY_SUPPORT defined. This commit
enables said function if COAP_CLIENT_SUPPORT is enabled as well.
2026-04-02 09:42:51 +01:00
Jon Shallow 5010974814 coap_io_posix.c: Make coap_io_process_remove_threads() thread protected.
Don't report

WARN coap_socket_accept_tcp: accept: Resource temporarily unavailable

when multiple threads are trying to process the same incoming TCP connection.
2026-04-01 15:58:42 +01:00
Jon Shallow f0533d32b1 LwIP: Handle PDUs with max size of 0 (unlimited) 2026-03-28 10:45:50 +00:00
Arthur Chan caa7120cae OSS-Fuzz: Add fuzzer for block low level checking
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-03-28 10:44:50 +00:00
Arthur Chan f283c7b69b OSS-Fuzz: Fix block fuzzer
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-03-28 10:44:31 +00:00
shruti gunwant 12cf731531 oscore: fix OSCORE replay window validation for out-of-order sequence numbers 2026-03-27 14:05:48 +00:00
Jon Shallow 80c37b7bc6 Coverity: Fix CID 1483550, 1670422-1670425
CID 1594475 is a false positive as multiple threads cannot execute in the same
code as global_lock is set.
2026-03-26 09:24:44 +00:00
rohit.patil 0a48ceec41 coap_net: skip Content-Format check for OSCORE FETCH
When a FETCH request is OSCORE-protected the Content-Format option is
an inner (encrypted) option per RFC 8613 §4.1.3.1 and is legitimately
absent from the outer CoAP message.  The existing RFC 8132 §2.3.1
check unconditionally rejects such requests with 4.15 (Unsupported
Content-Format) even when COAP_OSCORE_SUPPORT is disabled and the
application uses its own OSCORE stack.

Only enforce the Content-Format presence rule when no OSCORE option
is present in the outer request.

Fixes: https://github.com/obgm/libcoap/issues/1936
2026-03-25 10:54:27 +00:00
Jon Shallow a307ef9467 sanitizer: Fix reported issues
coap_new_cache_entry() does not correctly check for no PDU data when called
with COAP_CACHE_RECORD_PDU. No current libcoap code (examples and library)
call coap_new_cache_entry() with COAP_CACHE_RECORD_PDU set.

Internal function coap_pdu_resize() can be used to reduce a PDU size,
creating current options confusion.  Fix is not to reduce PDU if new
size is smaller than the current used size. No current libcoap code calls
coap_pdu_resize() to reduce the size.

If there is an issue with the PDU options where the maximum used option
value is larger than the last defined option value, an assert() is triggered.

All of the coap_*_option() functions correctly manage pdu->max_opt, but
this issue could occur if coap_pdu_resize() was called to reduce the PDU size
below that of pdu->used_size.
2026-03-24 18:35:31 +00:00
Jon Shallow 84560ef825 Sanitizer: Fix issues raised by ASan and UBSan when testing 2026-03-24 14:22:45 +00:00
Jon Shallow 39b79e23b4 multi-threading: Lock resource structure when calling request handlers
If an app request call-back modifies any data associated with a resource,
then multiple threads can attempt to unsafely modify the data at the same time.

Lock the resource when calling the app request handler (as global_lock is
unlocked) to prevent concurrent changes to the resource information.

If the app request handler is definately known to not modify the resource
information, then COAP_RESOURCE_SAFE_REQUEST_HANDLER can be set in the flags
for coap_resource_init().  Usually if there is a PUT, POST, PATCH or IPATCH
handler it is unsafe to set this. Setting this will reduce lock contention.
2026-03-23 19:01:53 +00:00
Arthur Chan efec6cf653 OSS-Fuzz: Fix packet transmission checking for network related fuzzers
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-03-20 21:26:34 +00:00
Arthur Chan 407e6b06cf OSS-Fuzz: Add fuzzer targeting coap_async
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-03-20 16:09:12 +00:00
Jon Shallow daa390eed9 coap_openssl.c: Fix coap_dgram_destroy() 2026-03-20 14:00:58 +00:00
Jon Shallow e817ec85dd coap_resource.c: Fix 2 threads doing a DELETE on the same resource 2026-03-20 13:47:55 +00:00
Jon Shallow d2e4e5e7f6 coap_tinydtls.c: Deprecate use of u_int 2026-03-20 09:45:02 +00:00
Jon Shallow 21b7a9a0eb Debugging: Add coap_debug_set_packet_fail() for testing network failures
This is similar to coap_debug_set_packet_loss() which drops packets that are
to be sent, but emulates network reported errors by reporting ECONNREFUSED.
2026-03-20 09:13:41 +00:00
Jon Shallow c0ee83bcfb Sanitizer: Add in build environment support
configure --enable-sanitizer
cmake -DENABLE_SANITIZER=ON
2026-03-20 08:24:43 +00:00
Florek, Bartlomiej 44e5c68c51 fix: OSCORE ACK retransmission handling 2026-03-19 15:13:32 +00:00
Lucien Zuercher 5b5b6972ec fix: do not override sequence counter after window processing 2026-03-19 14:48:16 +00:00
Jon Shallow 66f465a022 coap_tinydtls.c: Correctly initialize address in get_session_addr() 2026-03-19 11:05:22 +00:00
Jon Shallow 7c6912a68b coap_block.c: Fix mcast slave token generation 2026-03-19 09:30:58 +00:00
Arthur Chan 766711f62c OSS-Fuzz: Revamp block_fuzzer and add corpus seed
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-03-18 10:05:42 +00:00
Jon Shallow c1b1ffa27d oss-fuzz: Fix complaint about memcpy() 2026-03-16 14:49:56 +00:00
Jon Shallow ef97823845 main.yml: Use actions/checkout@v6
Fixes future Node.js 20 deprecation for github workflows.

There are still some other actions that continue to use Node.js 20 which will
need to be updated when they have also been ugraded to stop CI Action run warnings.
2026-03-16 14:49:02 +00:00
Arthur Chan f39d2152b3 OSS-Fuzz: Add observe fuzzer
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-03-16 12:40:27 +00:00
Jon Shallow 513685b580 SECURITY.md: Update the Security Policy 2026-03-13 16:05:25 +00:00
Florek, Bartlomiej d15d25f1ab impr(security): tracking CVE using CPE 2026-03-13 14:36:24 +00:00
Arthur Chan cc8de29bd4 OSS-Fuzz: Add more targets to network fuzzer
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-03-13 13:53:45 +00:00
Jon Shallow 9fc4d35cb2 coap_resource.c: Fix reference to deleted Observe after transmit failure 2026-03-13 13:52:22 +00:00
Jon Shallow 27f8e127ed coap_debug.c: Fix coap_debug_set_packet_loss("100%") 2026-03-13 13:49:21 +00:00
Lucien Zuercher e774e2e7ee fix: memory leak if client receives ACK response via OSCORE 2026-03-10 14:29:36 +00:00
Jon Shallow 40502ffebb oss-fuzz: Fix undefined-behavior
Analyzer run time does not like A -= B or A +=B even if A and B are uint32_t as there is potential
for overflow.

Analyzer run time does not like overflow when doing coap_tick_t - coap_tick_t.

Analyzer run time does not like (uint8_t << 24) as uint8_t is promoted as int, not u_int.

Analyzer run time does not like while(A--) {} even if A is uint32_t, as A is always decremented on
the test, even if the value of A is 0.

Fix potential overflow when analyzing an asn.1 tag.

Fix potential overflow when doing decode_segment() on a % hex value.
2026-03-10 11:09:10 +00:00
Jon Shallow fe41b51aab OSS-FUZZ: Fix build issue 2026-03-04 17:31:05 +00:00
Arthur Chan 099d9842da OSS-Fuzz: Simplify block_fuzzer
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-03-04 16:38:54 +00:00
Jon Shallow af72924dcc coap_openssl.c: Tidy up old versions builds (< 1.1.1)
Fix formatting
2026-03-04 16:33:39 +00:00
Jon Shallow 30875ab127 OSS-FUZZ: Fix discovered issues 2026-03-04 16:18:15 +00:00
Arthur Chan bb639096ab OSS-Fuzz: Fix Makefile for fuzzer to include CFLAGS from OSS-Fuzz
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-03-04 11:05:56 +00:00
Arthur Chan ea9d1cb803 OSS-Fuzz: Fix bias condition
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-03-04 11:05:33 +00:00
Jon Shallow 210cbf378a ASN1: Check for buffer overflows when determining tags and length
Include oss-fuzzer checks.
2026-03-03 10:36:46 +00:00
Arthur Chan e57294c7e6 OSS-Fuzz: Add fuzzer for coap-net targets
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-03-03 10:36:16 +00:00
Florek, Bartlomiej a4d7c29313 fix(config): enhance Zephyr configuration for libcoap 2026-03-03 10:35:36 +00:00
Carl Elgstrom e24ce7a6b3 coap_mem: fix -Werror=return-type in coap_malloc() lwIP stub 2026-02-27 16:32:56 +00:00
Arthur Chan 6fd1fbf702 OSS-Fuzz: Add new fuzzer for coap block processing
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-02-23 09:28:27 +00:00
Jon Shallow 55eba9193a oscore.c: Boundary check oscore_generate_nonce() parameters
Follows https://datatracker.ietf.org/doc/html/rfc8613#section-5.2 and Figure 8.
2026-02-23 09:15:41 +00:00
Jon Shallow 9d5d063331 RIOT: Fix building against the latest RIOT code 2026-02-21 10:56:44 +00:00
Jon Shallow 83ceb9687c coap_openssl.c: Support setting of PSK security level at compile time
Include
 -DCOAP_OPENSSL_PSK_SECURITY_LEVEL=0
as a compile time option to give a security level of 0 for PSK clients,
allowing them to connect to old servers that have not been TLS updated..

Vslues ore 0-5.  The default (usually) is 1.

The function SSL_set_security_level() is called
with the defined level of COAP_OPENSSL_PSK_SECURITY_LEVEL.

Note: Setting this to 0 adds weak ciphers to the list of supported ciphers,
opening up potential security vulnerabilities.
2026-02-18 20:54:04 +00:00
Magdalena Szumny e80fe9edd2 API for checking session encryption 2026-02-17 09:57:28 +00:00