Impact
The USBX DFU UPLOAD functionality may be utilized to introduce a buffer overflow resulting in overwrite of memory contents. In particular cases this may allow an attacker to bypass security features or execute arbitrary code.
The implementation of ux_device_class_dfu_control_request
function does not assure that a buffer overflow will not occur during handling of the DFU UPLOAD command. When an attacker issues the UX_SLAVE_CLASS_DFU_COMMAND_UPLOAD
control transfer request with wLenght
larger than the buffer size (UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH
, 256 bytes), depending on the actual implementation of dfu -> ux_slave_class_dfu_read
, a buffer overflow may occur. In example ux_slave_class_dfu_read
may read 4096 bytes (or more up to 65k) to a 256 byte buffer ultimately resulting in an overflow. Furthermore in case an attacker has some control over the read flash memory - in example DFU is used with an external SPI flash chip or the DFU DOWNLOAD command may be used - this may result in execution of arbitrary code and platform compromise.
Patches
We analyzed this bug and determined that we needed to fix it. This fix has been included in USBX release 6.1.11.
Workarounds
Align request and buffer size to assure that buffer boundaries are respected.
References
https://github.com/azure-rtos/usbx/blob/master/common/usbx_device_classes/src/ux_device_class_dfu_control_request.c
For more information
If you have any questions or comments about this advisory:
Impact
The USBX DFU UPLOAD functionality may be utilized to introduce a buffer overflow resulting in overwrite of memory contents. In particular cases this may allow an attacker to bypass security features or execute arbitrary code.
The implementation of
ux_device_class_dfu_control_request
function does not assure that a buffer overflow will not occur during handling of the DFU UPLOAD command. When an attacker issues theUX_SLAVE_CLASS_DFU_COMMAND_UPLOAD
control transfer request withwLenght
larger than the buffer size (UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH
, 256 bytes), depending on the actual implementation ofdfu -> ux_slave_class_dfu_read
, a buffer overflow may occur. In exampleux_slave_class_dfu_read
may read 4096 bytes (or more up to 65k) to a 256 byte buffer ultimately resulting in an overflow. Furthermore in case an attacker has some control over the read flash memory - in example DFU is used with an external SPI flash chip or the DFU DOWNLOAD command may be used - this may result in execution of arbitrary code and platform compromise.Patches
We analyzed this bug and determined that we needed to fix it. This fix has been included in USBX release 6.1.11.
Workarounds
Align request and buffer size to assure that buffer boundaries are respected.
References
https://github.com/azure-rtos/usbx/blob/master/common/usbx_device_classes/src/ux_device_class_dfu_control_request.c
For more information
If you have any questions or comments about this advisory: