3439 Commits
Author SHA1 Message Date
Jon Shallow 05e9a9caf4 Epoll: Handle server side read errors
Models that done for clients.
2026-09-02 12:59:47 +01:00
Jon Shallow 741729de08 Q-Block: Faster recovery times
Initiate a request for missing blocks if there are missing blocks and the
last 2 blocks of a PAYLOAD_SET are in.
2026-09-02 08:50:49 +01:00
Jon Shallow fcbd803828 Q-Block: Better recovery for lossy networks
Following the principles laid out in RFC9177.
2026-09-02 08:50:49 +01:00
Jon Shallow 2029e51727 coap_pdu.c: Check option lengths when adding options
Support adding options to CSM PDUs.
2026-09-01 20:47:57 +01:00
Jon Shallow 24ae8f2ee8 Block: Make sure SizeX option is added for small sizes with blocks 2026-09-01 20:46:45 +01:00
Jon Shallow dbeedd59b4 OSCORE: Fix observe cancellation when doing Appendix B.2 2026-09-01 15:57:49 +01:00
Jon Shallow 9cb8f45f4f PSK: Support keys in hex notation in matching files
coap-server options
-i match_identiity_file
-s match_psk_sni_file

coap-client option
-h match_hint_file
2026-09-01 11:29:49 +01:00
Jon Shallow beb924545f OSCORE: Fix observe cancellation
Also remove unnecessary COAP_EVENT_XMIT_BLOCK_FAIL events being triggered.
2026-08-31 11:28:30 +01:00
Jon Shallow 44e02b8693 LwIP: Allow smaller initial PDU buffer allocations 2026-08-31 10:46:47 +01:00
Jon Shallow d0605cc5e7 Block: Check for ETag/RTag option size overflow
This is not network exploitable as any incoming packet will fail the
coap_pdu_parse() / coap_pdu_parse_opt_base() check when building the CoAP PDU.
2026-08-29 09:22:01 +01:00
Jon Shallow ee764d94b4 Q-Block: Check for required options
RFC9177 section-4.3.
Q-Block1: Size1 and RTag required.

RFC9177 section-4.4.
Q-Block2: Size2 and ETag required.
2026-08-25 07:49:16 +01:00
Michiel De WitteandClaude Fable 5 091f189e7a Restore the request's local address when a triggered async fires
Server sessions are keyed on (remote address, local port) only, and
session->addr_info.local is overwritten by the destination of every
received packet. When a unicast CON request is parked in a coap_async_t
for a separate response and a multicast packet from the same peer
arrives before the async fires, the re-invoked handle_request() sees a
multicast local address, drops the CON per RFC7252 8.1 ("Invalid
multicast packet received"), and coap_check_async() frees the async:
the response is silently never sent.

Snapshot the local address in coap_register_async() and restore it on
the session before the async fires, so the deferred request is handled
(and its response source selected) against the address it actually
arrived on.

Seen in the field with a CoAP remote control whose GET /endpoint was
answered via the async path while it also multicast periodic
announcements from the same source port: the device received the empty
ACK and then never got the response.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-24 16:35:51 +01:00
Jon Shallow 9d407dd083 Documentation: Updates 2026-08-22 17:42:40 +01:00
Jon Shallow f325f6a4b0 coap_net.c: Enforce response Content-Format matches request Accept option
Only if the request includes the Accept Option and it is not an empty ACK.
2026-08-22 15:09:26 +01:00
Jon Shallow dfe1cd2b93 coap_net.c: Check block options for invalid SZX = 7 2026-08-22 15:06:39 +01:00
Jon Shallow ea841dd0c7 coap_mutex_internal.h: Fix LwIP coap_mutex_destroy 2026-08-20 10:31:27 +01:00
Jon Shallow 850748ca14 Recovery: Support dropping incoming packets for testing 2026-08-20 09:56:09 +01:00
Jon Shallow dfd55459d7 NoTLS: Use SHA1 for digest computations
Removed:
include/coap3/coap_hashkey_internal.h
src/coap_hashkey.c
2026-08-15 15:20:12 +01:00
Jon Shallow 7c456246c9 coap_resource.c: Make Observe deregistration more rigorous 2026-08-15 15:18:46 +01:00
Jon Shallow 3c7742a2ee coap_block.c: Send 2.31 response if duplicate block received
Only happens if the MID is different and this is not the final block.
2026-08-15 15:09:24 +01:00
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