What changed, and why it matters
This firmware update changes how USB response data is handed off to the USB hardware. Previously, the code trusted the caller not to change the data buffer while the USB controller was still sending it, and it required the caller's buffer to be aligned in a specific way. Now the code copies the data into its own fixed, properly aligned buffer before handing it to the USB hardware. This is a defensive hardening change: it removes a class of potential bugs where a caller might pass a temporary (stack) buffer that changes or is misaligned while the USB transfer is in progress. The commit does not describe a specific exploitable vulnerability, so this is best viewed as preventive maintenance rather than a confirmed security fix.
Treat as a hardening commit. Review callers of hid_hww_write_poll() and hid_u2f_write_poll() to confirm they no longer need to guarantee buffer alignment or persistence. Consider whether the static buffer introduces any new concurrency or re-entrancy concerns, since the same buffer is now reused for every write. No immediate incident response is indicated in the absence of a disclosed vulnerability.
Security signals we found
Defensive copy introduced before DMA/USB write
Buffer alignment requirement explicitly addressed with __attribute__((aligned(4)))
Eliminates reliance on caller-provided buffer lifetime and alignment
No explicit bug, CVE, or exploit described in commit or supplied references
Evidence from the diff
The patch modifies hid_hww_write_poll() and hid_u2f_write_poll() to copy the outgoing report into a new static, 4-byte-aligned 64-byte buffer before calling hid_write(). The previous implementation passed the caller-supplied pointer directly to the USB stack, which relies on DMA. DMA requires stable, aligned memory for the duration of the asynchronous transfer. The change eliminates two failure modes: (1) caller modifying or freeing the buffer before the DMA completes, and (2) caller-provided stack buffers that may not be 32-bit aligned. The commit message frames this as an enabler for stack-allocated buffers and a removal of reliance on caller behavior.
Changed components
src/usb/class/hid/hww/hid_hww.csrc/usb/class/hid/u2f/hid_u2f.cUSB HID HWW (hardware wallet) interfaceUSB HID U2F interfaceInspect captured patch +6 / −2
diff --git a/src/usb/class/hid/hww/hid_hww.c b/src/usb/class/hid/hww/hid_hww.c
index f7e07b4..0499138 100644
--- a/src/usb/class/hid/hww/hid_hww.c
+++ b/src/usb/class/hid/hww/hid_hww.c
@@ -45,6 +45,7 @@ static struct usbdc_handler _request_handler = {NULL, (FUNC_PTR)_request};
static volatile bool _send_busy = false;
static volatile bool _has_data = false;
static volatile bool _request_in_flight = false;
+static uint8_t _write_buf[64] __attribute__((aligned(4)));
// First time this function is called it initiates a transfer. Call it multiple times to poll for
// completion. Once it returns true, there is data in the buffer.
@@ -73,7 +74,8 @@ bool hid_hww_write_poll(const uint8_t* data)
if (_send_busy) {
return false;
}
- if (hid_write(&_func_data, data, USB_HID_REPORT_OUT_SIZE) == ERR_NONE) {
+ memcpy(_write_buf, data, USB_HID_REPORT_OUT_SIZE);
+ if (hid_write(&_func_data, _write_buf, USB_HID_REPORT_OUT_SIZE) == ERR_NONE) {
_send_busy = true;
return true;
}
diff --git a/src/usb/class/hid/u2f/hid_u2f.c b/src/usb/class/hid/u2f/hid_u2f.c
index 00bcb3c..6780bbd 100644
--- a/src/usb/class/hid/u2f/hid_u2f.c
+++ b/src/usb/class/hid/u2f/hid_u2f.c
@@ -33,6 +33,7 @@ static uint8_t _report_descriptor[] = {USB_DESC_U2F_REPORT};
static volatile bool _send_busy = false;
static volatile bool _has_data = false;
static volatile bool _request_in_flight = false;
+static uint8_t _write_buf[64] __attribute__((aligned(4)));
/**
* The USB device core request handler callback for the U2F interface.
@@ -75,7 +76,8 @@ bool hid_u2f_write_poll(const uint8_t* data)
if (_send_busy) {
return false;
}
- if (hid_write(&_func_data, data, USB_HID_REPORT_OUT_SIZE) == ERR_NONE) {
+ memcpy(_write_buf, data, USB_HID_REPORT_OUT_SIZE);
+ if (hid_write(&_func_data, _write_buf, USB_HID_REPORT_OUT_SIZE) == ERR_NONE) {
_send_busy = true;
return true;
}
Why this scored 42/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.