CVE-2026-76788: Stack out-of-bounds write in the OSDP Control Panel reply parser
The OSDP Control Panel reply parser cpdecoderesponse() in subsys/mgmt/osdp/src/osdpcp.c decodes replies from a Peripheral Device into a stack-allocated struct osdpevent. For the REPLYKEYPPAD and REPLYRAW reply types, the payload length is taken from the received frame and the only validation performed is that the declared length is self-consistent with the number of payload bytes present in the frame. Because the attacker controls both the length field and the frame length, that check imposes no bound, and the subsequent memcpy() writes into the fixed 64-byte data arrays of struct osdpeventkeypress / struct osdpeventcardread (OSDPEVENTMAXDATALEN). The sibling REPLYFMT handler in the same switch already carried the missing > OSDPEVENTMAXDATALEN bound.
The defect is reached from cpprocessreply(), which reads bytes from the OSDP RS-485 channel and passes them through osdpphycheckpacket() and osdpphydecodepacket() before dispatching on the reply ID. Triggering it requires CONFIGOSDP with CONFIGOSDPMODECP and an application event callback registered (the normal Control Panel integration), plus a frame carrying a correct SOM, a valid CRC-16, and a matching 2-bit sequence number — all of which are computable or observable by anyone on the bus. No check ties the reply ID to the outstanding command, so an oversized REPLYKEYPPAD or REPLYRAW is accepted as the answer to a routine CMDPOLL. A malicious or compromised card reader, or anyone with access to the RS-485 wiring, can supply such a frame; CONFIGOSDPSCENABLED only helps while a secure channel is active, and a single unauthenticated frame carrying a bad MAC causes scdeactivate(), after which plaintext replies are again accepted.
With the default CONFIGOSDPUARTBUFFERLENGTH of 256, roughly 180 bytes of fully attacker-chosen data can be written past the end of the stack-allocated event object, over saved registers and the return address on typical Cortex-M and RISC-V frame layouts (Zephyr does not enable stack canaries by default). The impact ranges from a hard crash of the access-control panel to potential control-flow hijack in the context of the OSDP receive thread. The fix adds an OSDPEVENTMAXDATALEN bound to both handlers, capping each memcpy() at the size of its destination.
Affected Software
Event History
Frequently Asked Questions
Which deployments are exposed?
The affected path requires CONFIG_OSDP with CONFIG_OSDP_MODE_CP enabled and an application event callback registered, as in a normal Control Panel integration. It processes replies received over the OSDP RS-485 channel from a Peripheral Device.
What must an attacker be able to do to trigger the overwrite?
An attacker must be able to send a crafted OSDP reply on the RS-485 channel. The frame must have a correct SOM and valid CRC-16, and the vulnerable reply types are REPLY_KEYPPAD and REPLY_RAW with an oversized but self-consistent payload length.
What can be done if patching is not immediately possible?
Disable the affected OSDP Control Panel functionality where operationally possible, such as by not enabling CONFIG_OSDP_MODE_CP or CONFIG_OSDP. Deployments without a registered application event callback do not meet the stated triggering conditions.