Commit Graph
3321 Commits
Author SHA1 Message Date
Jon Shallow 3035cfd751 OSS-FUZZ: Add in i386 build for fuzzing 2026-06-13 20:12:26 +01:00
Jon Shallow 4c3f4af1c0 OSS-FUZZ: Support different architectures and engines 2026-06-12 21:08:45 +01:00
Jon Shallow 46e34175b8 RIOT: Fix build against latest version 2026-06-12 17:21:21 +01:00
Jon Shallow 888ba34ece Q-Block: Better timing / recovering when rate limiting
Make use of an outstanding list of blocks to transmit to remove duplicates
and only send one at a time if rate-limiting.
2026-06-10 12:01:10 +01:00
Jon Shallow 46e505c430 OSCORE: Support using MbedTLS for OSCORE only (not (D)TLS)
New ./configure option

 --with-mbedtls-oscore

If --disable-dtls is set, then MbedTLS is used as the OSCORE backend, otherwise
the MbedTLS library is used for both (D)TLS and OSCORE.

New cmake option

 -DOSCORE_BACKEND=mbedtls

If -DENABLE_DTLS=OFF is set, then MbedTLS is used as the OSCORE backend, otherwise
the MbedTLS library is used for both (D)TLS and OSCORE.

New Zephyr option

 config MBEDTLS_OSCORE

If set to y and CONFIG_LIBCOAP_OSCORE_SUPPORT is set to y, then the Zephyr MbedTLS
backend will get used for the OSCORE backend (no (D)TLS).
2026-06-10 11:56:44 +01:00
Jon Shallow 5ea8b7d5e9 OpenSSL: Support 4.0 and later buids
Remove all references to ENGINE_*() as support has been removed in 4.0.

There currently is no tested Provider support for PKCS11.
2026-06-05 15:51:01 +01:00
Jon Shallow 193ec26ead Proxy: Check for non-safe options
Generally re-organize option handling, making use of enums etc.

This also updates critical options checks, and well as repeatable options.
2026-06-05 15:22:38 +01:00
Michiel De Witte b4de71ee24 Fix data race in coap_resolve_address_info() 2026-06-02 09:57:30 +01:00
David Korczynski bd47692407 Add proxy fuzz harness to be consumed by OSS-Fuzz
The goal is to increase code coverage of coap_proxy.c logic,
which currently stands at less than 2%:
https://storage.googleapis.com/oss-fuzz-coverage/libcoap/reports/20260518/linux/src/libcoap/src/report.html

Signed-off-by: David Korczynski <david@adalogics.com>
2026-06-01 16:05:55 +01:00
Jon Shallow f669cf5e24 coap_openssl.c: Support clients alternating betweek PKI and PSK 2026-06-01 15:16:19 +01:00
Jon Shallow c4e651ae70 LwIP: Allocate semaphores per context for NO_SYS == 0
Each LwIP coap_context_t must now periodically call coap_io_process().
2026-06-01 09:55:31 +01:00
Jon Shallow d32d298333 coap_oscore.c: Fix replay protection 2026-06-01 09:18:10 +01:00
Jon Shallow eb73b10e64 oss-fuzz: Further support for running with threading support 2026-05-30 14:15:54 +01:00
Jon Shallow be107f0229 coap_proxy.c: Fix memory leak 2026-05-30 10:10:23 +01:00
David Korczynski c28f8f5e7a fix lint
Signed-off-by: David Korczynski <david@adalogics.com>
2026-05-30 09:47:56 +01:00
David Korczynski 0e03abc99c Adds extended coap_cache fuzzer to be consumed by OSS-Fuzz
The goal is to extend code coverage of libcoap. Can confirm from local
runs this provides a significant boost to coap_cache.c coverage.

Signed-off-by: David Korczynski <david@adalogics.com>
2026-05-30 09:47:56 +01:00
Jon Shallow 7370fcf6ad LwIP: Add in support for MEM_USE_POOLS for COAP_STRING malloc()s
If both MEMP_USE_CUSTOM_POOLS and MEM_USE_POOLS are defined in
lwipopts.h and there is a suitable
LWIP_MALLOC_MEMPOOL_START .. LWIP_MALLOC_MEMPOOL_END
definition in lwippools.h, then any coap_malloc_type(COAP_STRING, ..) will
make use of the defined pools.

A new src/coap_mem_lwip.c file has been added.
2026-05-27 06:32:11 +01:00
David Korczynski e909ff5dd5 Adds extended uri fuzzer to be consumed by OSS-Fuzz
Extends on the code coverage of the coap_uri.c module, which currently
has the code coverage:
https://storage.googleapis.com/oss-fuzz-coverage/libcoap/reports/20260512/linux/src/libcoap/src/coap_uri.c.html

Signed-off-by: David Korczynski <david@adalogics.com>
2026-05-25 11:39:43 +01:00
David Korczynski 574332f6e3 Add ws_frame fuzzer to be consumed by OSS-Fuzz
Signed-off-by: David Korczynski <david@adalogics.com>
2026-05-20 14:26:02 +01:00
Lucien Zuercher 855d53ef10 oscore: enable external credential storage and safe recipient cleanup
Add reference counting to recipient contexts so they can be safely removed
while still in use by active sessions. Expose callback hooks for credential
lookup, echo, and sequence storage to allow custom backends.
Expand example server to demonstrate the external storage via a simple
file based database. Expand coap_oscore_rcp_conf_t to enable settings
preconfigured echo value, sequence counter and window value as uint64
Enable temporary credentials returned by the find function and are destroyed
after use.
2026-05-20 13:09:24 +01:00
Jon Shallow 48559f0016 RIOT: Add help documentation
General documentation tidy up.
2026-05-20 10:20:22 +01:00
Fabian Hüßler db7b7e8207 coap_config.h.riot: add CONFIG_LIBCOAP_MAX_STRINGS 2026-05-19 14:53:42 +01:00
Jon Shallow 590570a465 oss-fuzz: Support testing with thread enabled builds 2026-05-18 12:06:58 +01:00
Jon Shallow 56ad791cc4 wolfssl.c: Update not needed assert() 2026-05-18 12:03:53 +01:00
David Korczynski 57370405c8 OSS-Fuzz: Add new dtls harness
The goal is to increase code coverage, which is currently around 25%:
https://storage.googleapis.com/oss-fuzz-coverage/libcoap/reports/20260318/linux/report.html

Signed-off-by: David Korczynski <david@adalogics.com>
2026-05-18 11:37:41 +01:00
Krisztian Szilvasi 12a4a494f5 fix(cmake): specify project to only use c
This makes installing cxx compiler unnecessary

Signed-off-by: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com>
2026-05-16 16:36:58 +01:00
Jon Shallow 3d6b603672 coap_pdu.c: Handle extended token checking with small PDUs
Handle errors reported by sanitize checks.
2026-05-16 16:32:23 +01:00
Jon Shallow 9f14450a7e coap_subscribe.c: Fix issue found by oss-fuzz 2026-05-14 15:51:32 +01:00
Jon Shallow c1147eb096 coap_pdu.c: Support checking for extended tokens when large pdu created
Picked up by oss-fuzz
2026-05-13 10:29:30 +01:00
Jon Shallow 13139e7be9 Options: Check Uri-Path and Location-Path options for . or ..
Check incoming Uri-Path and Location-Path options for just . or .. (or %2e
hex encoded variants) and treat as being invalid.

Stop insertion of Uri-Path and Location-Path options that contain just
. or .. (or %2e hex encoded variants).
2026-05-11 19:41:17 +01:00
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