Commit Graph
3291 Commits
Author SHA1 Message Date
Jon Shallow df90dfd7b1 coap_subscribe.c: Sanity check persist startup logic 2026-05-11 18:08:55 +01:00
Arthur Chan 64e2a65ad0 OSS-Fuzz: Further fix block fuzzer on wellknown handling path
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-05-09 16:13:34 +01:00
Arthur Chan 2614649ecc OSS-Fuzz: Add fuzzer for persist storing
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-05-09 16:11:08 +01:00
Arthur Chan c99bf12801 OSS-Fuzz: Fix block fuzzer
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-05-08 09:33:36 +01:00
Arthur Chan be60f46ff0 OSS-Fuzz: Fix async fuzzer
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-05-08 09:32:36 +01:00
Arthur Chan 60dad69e95 OSS-Fuzz: Fix observe fuzzer
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-05-08 09:31:43 +01:00
Arthur Chan 76a793be5c OSS-Fuzz: Add a helper for fuzzing
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-05-07 19:36:44 +01:00
Jon Shallow 382e16cc7f coap_ws.c: Fix potential OOB on read headers 2026-05-07 17:09:22 +01:00
Jon Shallow 54faa02565 coap_resource.c: Fix inverted error introduced in #1927 2026-05-07 16:22:21 +01:00
Arthur Chan feab110c7f OSS-Fuzz: Fix block_check_fuzzer
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-05-07 14:22:46 +01:00
Magdalena Szumny a77c2c64fe Use Zephyr allocators for Zephyr targets 2026-05-06 13:52:06 +01:00
OwenSanzas 34cee6ef76 coap_resource.c: harden coap_print_wellknown_lkd against zero-length query-pattern
When a Uri-Query filter ends in '=' with no value bytes (e.g. "rt="),
the filter parser computes resource_param.length == query_filter->length - 1
and query_pattern.length == 0, but then unconditionally dereferences
query_pattern.s[0] to test for a leading '/'. With the current allocator
strategy in coap_new_string() (which over-allocates by 1 byte for a NUL
terminator) this read lands on the NUL slot and is harmless; ASan does
not flag it on the dispatch path.

However, coap_print_wellknown is a public, exported COAP_API. A caller
passing a tightly-allocated coap_string_t (length == alloc_size, no
trailing slack) hits a 1-byte heap-buffer-overflow read at
src/coap_resource.c:178. The man page does not document any required
allocation slack, so this is an API-contract footgun rather than only an
internal invariant violation.

Mirror the existing guard already in place for the trailing '*' check
(line 183) by guarding the leading '/' check on query_pattern.length > 0.

Reproducer (clang + ASan, against HEAD e3f8cd0):

  uint8_t *filter = malloc(3);
  memcpy(filter, "rt=", 3);
  coap_string_t qf = { .length = 3, .s = filter };
  coap_print_wellknown(ctx, out, &out_buflen, 0, &qf);
  /* AddressSanitizer: heap-buffer-overflow READ of size 1
   *   #0 coap_print_wellknown_lkd src/coap_resource.c:178
   *   #1 coap_print_wellknown    src/coap_resource.c:110             */

After the fix the PoC exits cleanly; the sanity case "rt=x" (length>0)
continues to work unchanged.

Signed-off-by: OwenSanzas <zesheng@tamu.edu>
2026-05-05 09:24:36 +01:00
Jon Shallow 169eccbff8 CI: Update to use microsoft/setup-msbuild@v3 2026-05-04 20:43:07 +01:00
Jon Shallow de54053789 Q-Block: Reference track coap_lg_srcv_t and coap_lg_crcv_t 2026-05-04 17:46:59 +01:00
Jon Shallow e3f8cd05d0 coap_resource.txt.in: Update resource flags definitions 2026-04-24 09:15:51 +01:00
Magdalena Szumny 6a18d42dc7 Update version for security scanning 2026-04-24 07:41:07 +01:00
Krisztian Szilvasi d62f137bcd feat(zephyr): support v4.4
- fix(cmake): only create alias if it doesn't exist:
Zephyr v4.4 has moved to MbedTLS 4.x in following PR:
https://github.com/zephyrproject-rtos/zephyr/pull/104031
Zephyr now uses MbedTLS' CMakeLists, which exports targets
with NAMESPACE MbedTLS::, therefore MbedTLS::mbedtls,
MbedTLS::mbedx509, MbedTLS::tfpsacrypto aliases already exist

- fix(zephyr): v4.4: include correct mbedtls config based on zephyr version
CONFIG_MBEDTLS_CFG_FILE was deprecated. Instead, CONFIG_MBEDTLS_CONFIG_FILE
shall be used. This change supports both based on Kconfig symbols.

Signed-off-by: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com>
2026-04-23 16:48:56 +01:00
Jon Shallow 8402c3bb8c OSS-FUZZ: Fix issues found 2026-04-22 21:03:50 +01:00
Jon Shallow 244b0c2be4 OSS-FUZZ: Fix issues found 2026-04-22 10:07:44 +01:00
Jon Shallow b1b60fe159 RIOT: Handle ints being 16 bits 2026-04-22 09:04:00 +01:00
Jon Shallow 86b778167a RIOT: Implement RIOT's coding standards 2026-04-20 21:28:45 +01:00
Jon Shallow 783b5317ca Uri-Path-Abbrev: Initial IETF Draft support
https://datatracker.ietf.org/doc/html/draft-ietf-core-uri-path-abbrev-04
2026-04-18 12:05:48 +01:00
Jon Shallow e4297c9c89 OSS-FUZZ: Fix issues found 2026-04-18 11:56:32 +01:00
Jon Shallow b197807b54 ASN1: Add in limit check for recursive tags 2026-04-18 11:36:49 +01:00
Jon Shallow edc146d9f1 KeepAlive: Make sure sessions timeout after ping failures
Currently set to 3 concurrent ping failures.
2026-04-18 10:44:44 +01:00
Ernestas Kulik 766b852849 Implement support for LLC sockets
Useful in embedded contexts, where devices might only have a link-layer
connection, but still need to exchange information.
2026-04-18 09:11:19 +01:00
Jon Shallow 3f4d08f964 RateLimit: Support rate limiting NON packets
New coap_context_rate_limit_ppm() function added.

Useful for 6TiSCH type environments.
2026-04-16 13:11:27 +01:00
Jon Shallow 5d76f75c24 ThreadSafe: Fix CVE 1670700 thread number logging 2026-04-16 13:10:43 +01:00
Jon Shallow c50ea5bb37 RIOT: Update to latest 2026-04-16 12:27:38 +01:00
Jon Shallow 24d146d553 Update SO and ABI to match v4.3.5b bug fix release 2026-04-14 11:43:07 +01:00
Jon Shallow 77929465d3 OSCORE: Support complex sender and recipient configurations
Also supports silent_server configuration for recipient definitions.
2026-04-14 10:42:41 +01:00
Jon Shallow e766f053c2 Debugging: Add examples support for causing network failures
Add -Z option to coap-client and coap-server.
2026-04-13 17:02:39 +01:00
Jon Shallow 2c8cceb997 coap_net.c: Move prepend_508_ip out of coap_send_internal 2026-04-11 20:21:08 +01:00
Jon Shallow 707d08ed44 DTLS: Do not call coap_session_disconnected_lkd() for writes
Let the upper calling layer do the coap_session_disconnected_lkd()
on detection of write error.
2026-04-11 14:33:05 +01:00
Jon Shallow 414900ecc3 coap_threadsafe.c: Support multiple use of coap_io_process_configure_threads()
Support for multiple libcoap contexts.
2026-04-08 16:00:01 +01:00
Jon Shallow 17a0c692fe OSS-FUZZ: Reduce unnecessary logging during runs
No need to log socket or OSCORE issues at critical level.
2026-04-08 12:48:44 +01:00
Jon Shallow bdd05e726f coap_threadsafe.c: Provide internal SIGINT handler for closing down threads 2026-04-04 16:56:00 +01:00
Jon Shallow 912cae62d7 CBOR: Be more rigorous in boundary checking 2026-04-04 09:23:58 +01:00
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