Commit Graph
3369 Commits
Author SHA1 Message Date
Jon Shallow d0fa34cf4f coap_resource.c: Update .well-known/core query matching
Support matching multiple, space separated, values, not limited to if=, rt= and rel=.

Fix OOB read if the last space separated value is shorter than the query.

Support matching against multiple queries.

Do not sent back empty 2.05 response if multicast.
2026-08-11 16:09:02 +01:00
Jon Shallow 230979ddba coap_mem.c: Support esp-idf SPIRAM memory allocations 2026-08-08 16:11:53 +01:00
ZT Winds 1c8c8bd3a7 oscore_cbor: fix infinite loop on large CBOR array/map counts
CBOR array and map counts can exceed UINT16_MAX. The uint16_t loop counters
then wrap and never reach the advertised count, causing a CWE-835 denial of
service.

Use size_t loop counters and reject counts that cannot fit in the remaining
buffer at the minimum encoding size of one byte per array element or two
bytes per map pair. Propagate malformed-value errors and cover large
malformed containers and valid values over 64 KiB with regression tests.
2026-08-08 16:11:20 +01:00
Jon Shallow a5803ff733 OSCORE: Boundary check OSCORE option creation 2026-08-08 13:27:40 +01:00
Jon Shallow 98805f70a5 Documentation tidy up
Add in codespell to pre-commit to help fix documentation errors.
2026-08-08 12:05:03 +01:00
Jon Shallow 1394e9833d CI: Cache Contiki/LwIP/Zephyr downloads 2026-08-06 09:55:09 +01:00
kkrentz eafc0230f5 coap_net.c: Avoid divsion by zero if COAP_TICKS_PER_SECOND < 1000 2026-08-01 10:45:44 +01:00
kkrentz bf7323d9a2 coap_net.c: Replace %d with PRIu32 2026-08-01 09:41:23 +01:00
Jon Shallow 7cdc58da69 RIOT: Update Makefile.ci for supported boards 2026-07-30 12:51:48 +01:00
Jon Shallow d4f78cd560 ICMP: Treat genuine ICMP diagnostic PDU for UDP as failure
Posix support only for unicast client requests.

ICMP disgnostic messages are ignored on server sessions.
2026-07-28 16:42:41 +01:00
Jon Shallow f52fadaa9a coap_net.c: For NON responses, use server generated message id 2026-07-25 17:23:48 +01:00
Jon Shallow 0121c25f63 LwIP: Properly seed random number generation 2026-07-25 15:48:45 +01:00
Jon Shallow 463fa7c533 CI: Update to action/cache@v5
Removes CI warnings. Also fix warning for Contiki MacOS build.
2026-07-25 14:31:17 +01:00
Jon Shallow 0014440160 OSS-FUZZ: Stop actual packet transmissions
Make sure all packets are dropped in persist_target.c.
2026-07-25 13:58:10 +01:00
Jon Shallow c056e91ddb tls_backend_testcases.sh: Fix 2.05 code matching time in error 2026-07-25 13:08:46 +01:00
Jon Shallow 54537a38c5 Typos: Fix documentation typos
Includes minor code tidy up.
2026-07-25 12:49:31 +01:00
Jon Shallow 0befa05f48 RIOT: Code tidy following review 2026-07-21 12:30:28 +01:00
94xhn 09e91a2e5c coap_resource.c: harden coap_print_wellknown_lkd() against short attribute values
In the "match attribute" branch of coap_print_wellknown_lkd(), an
attribute value shorter than 2 bytes (e.g. a lone " registered via
coap_add_attr()) causes attr->value->s[0] == '"' to read past the
value, and unquoted_val.length -= 2 to underflow the size_t length
to SIZE_MAX. The resulting bogus coap_str_const_t is then passed to
match(), which dereferences memory far outside the original buffer.

Guard the quote-check on length >= 2 before reading s[0], mirroring
the length && ... guard already used a few lines above for
query_pattern (added in #1977) and the trailing-'*' guard next to
it.

Reproduced with a standalone harness placing a 1-byte attribute
value at the end of a guard-paged region: pre-fix, unquoted_val.length
becomes SIZE_MAX and match() crashes on the guard page; post-fix,
length stays at the original value (no underflow) and match() safely
short-circuits. A normal quoted value ("foo", 5 bytes) still strips
to foo (3 bytes) unchanged, confirming no regression.
2026-07-17 15:24:27 +01:00
Jon Shallow 1122bf9fb9 Proxy: Report 5.04 on proxy gateway timeout
Timeout is set to MAX_TRANSMIT_WAIT for CON Non-Reliable requests.

If request is active, idle timeout is ignored.
2026-07-16 11:03:01 +01:00
Mario Kicherer 12b7e99225 add coap_endpoint_join_mcast_group_intf 2026-07-15 10:17:05 +01:00
Jon Shallow 94bacc8939 Duplicate MIDs: If repeat MID request, send back previous response
Clean up duplicate MID handling, and just send back last response if MID
matches.

Removed COAP_BLOCK_CACHE_RESPONSE as no longer required for duplicate MID
handling, and so no need to send an Empty ACK response for a subsequent
Separate response as a referenced copy of the last PDU respponse is now kept
for a session.

Note that if a request is sent by a proxy to an upstream server, this always
converts the upstream server's response into a Separate response back to the
client as the upstream server may take time to respond, do any error recovery
etc.
2026-07-14 09:56:34 +01:00
Jon Shallow 72978e9fc6 PKI: Add in PKI wildcard and multiple SANs support 2026-07-11 10:28:31 +01:00
Jon Shallow ec038499d8 TinyDTLS: Update to the latest version 2026-07-10 15:11:48 +01:00
Jon Shallow 05a946c878 configure.ac: Move forward with releases following semver.org format 2026-07-10 11:46:48 +01:00
Jon Shallow bc708771c8 coap_net.c: Redo mcast large token fix
Drop sending 4.00 or RST response if large token size support is not available
and request is a multicast request.

Fixes #2063.
2026-07-10 09:22:24 +01:00
Jon Shallow 8a7375700f coap_net.c: Revert out mcast large token fix as it breaks OSCORE
Revert out #2078 as it causes issues with OSCORE when determining
if large token support size is available.
2026-07-10 09:22:24 +01:00
Jon Shallow 34b1d8c167 coap-server.c: Remove default hint for PSK
This allows (D)TLS1.3 to be negotiated when using PSK.

If '-i match_identity_file' is being used, the hint is taken from the first
entry if not otherwise defined by '-h hint'.
2026-07-09 15:39:29 +01:00
Jon Shallow f9734a55fc configure.ac: Remove space after -I option
pkg-config --cflags gets confused by the space.
2026-07-06 17:44:34 +01:00
Jon Shallow eadd400b62 oscore_cbor.c: Fix coap_persist_observe_add() boundary checks 2026-07-06 10:44:45 +01:00
David Korczynski e2463f007f Add OSCORE CBOR fuzz harness to be consumed by OSS-Fuzz
The goal is to increase code coverage of the OSCORE CBOR reader in
src/oscore/oscore_cbor.c, which decodes attacker-reachable data (the
persisted observe/OSCORE association blob in coap_subscribe.c and the
OSCORE option kid_context in coap_oscore.c) but is currently largely
unexercised:
https://storage.googleapis.com/oss-fuzz-coverage/libcoap/reports/20260702/linux/src/libcoap/src/oscore/report.html

Signed-off-by: David Korczynski <david@adalogics.com>
2026-07-03 07:36:09 +01:00
Jon Shallow ce032db273 oscore_cbor.c: Fix handling large negative integers
Exclude OSS-FUZZ seed corpus files from pre-commit hooks.
2026-07-02 19:54:48 +01:00
Jon Shallow f2d301e9c5 TLS: Fix interoperability issues raised by examples/tls_backend_testcases.sh 2026-06-30 12:32:36 +01:00
tlhc 2bea51aaf5 coap_openhitls.c: prefer SAN before CN for certificate names 2026-06-29 11:32:03 +01:00
Jon Shallow 7c9cadb57c pkg-config: Include cmake and sanitize support for .pc files 2026-06-29 09:07:35 +01:00
Jon Shallow 6c5a0bcb4f TLS: Support client checking sent SNI to received server's PKI CN
For coap-client, if either -R or -C options are specified, then allowing
self-signed certificates is now disabled.
2026-06-27 12:20:00 +01:00
Jon Shallow 6c01c83272 coap_proxy.c: Decrement MAX_AGE when returning cached entry 2026-06-27 11:25:19 +01:00
tlhc aa68d5f7e3 feat: add openHiTLS backend support
- Add openHiTLS DTLS/TLS backend
- Integrate openHiTLS crypto into libcoap (D)TLS and OSCORE paths.
- Extend TLS tests and add interop validation script.
2026-06-27 11:18:22 +01:00
Jon Shallow 261dc9b58c WebSockets: Handle large reads 2026-06-25 15:42:04 +01:00
Jon Shallow d354a693a7 CMakeLists.txt: Better handle OSCORE only back-ends 2026-06-25 09:34:58 +01:00
Jon Shallow 92d58d1115 TLS: Compatability tidy up 2026-06-25 09:24:37 +01:00
Jon Shallow f4a8fe1d12 Extended Tokens: Fix multicast responses 2026-06-24 13:32:30 +01:00
Jon Shallow abde6a513a Proxy: Cleanup proxy associations
Handles situation where the event handler is not defined.
2026-06-24 13:29:26 +01:00
Jon Shallow 2e995218f3 SendQueue: Match Mid and Token (if given) to remove entry from queue
For Empty ACK and RST do not do a token match.
2026-06-22 13:48:44 +01:00
Jon Shallow c65dcb16df coap_wolfssl.c: Fix Identity Hint, PEM_BUF and timeouts 2026-06-22 13:47:38 +01:00
Jon Shallow 83a71af102 coap-gnutls.c: Fix CN, establised state and timeouts 2026-06-22 13:45:53 +01:00
Dmytro Bagrii 77b4714604 examples: server: Fix const qualifier discard
Compiling with gcc-16.1.1 and glibc-2.43 yields warnings: "initialization
discards ‘const’ qualifier from pointer target type".

Indeed, pointer passed to strchr() is `const char *` and memory pointed by
return value of strchr() is never modified, so variable to assign return
value should be `const char *`.
2026-06-22 09:57:21 +01:00
Mario Kicherer 3891726e17 coap_openssl.c: unify tls_client_hello_call_back for PSK and PKI to fix simultaneous operation 2026-06-20 12:53:01 +01:00
Jon Shallow 0869dea655 coap_mbedtls.c: Fix checking PKI Common Name and Connected Event 2026-06-18 13:16:24 +01:00
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