🇰🇷 한글 설명
Espressif ESP-hosted Wi-Fi 드라이버에서 SPI를 통해 수신된 프레임의 TLV 데이터 길이를 검증 없이 처리하여 발생하는 취약점입니다. 공격자가 주변 AP 스캔 목록 등을 조작하여 잘못된 길이를 유도할 경우, 메모리 경계를 벗어난 읽기 작업이 발생하여 시스템이 중단되거나 힙 할당 오류로 인해 서비스 거부(DoS) 상태에 빠질 수 있습니다.
💡 쉬운 설명
Wi-Fi 통신 과정에서 데이터의 길이를 확인하지 않는 허점이 있어, 공격자가 특수한 신호를 보내 기기를 멈추게 만들 수 있습니다. 이로 인해 기기의 Wi-Fi 기능이 작동을 멈추고 재부팅 전까지 사용할 수 없게 됩니다.
🇺🇸 원문 (English)
The Espressif ESP-hosted Wi-Fi driver (drivers/wifi/esp_hosted/) parses frames received over SPI from the ESP co-processor in esp_hosted_event_task(). For control frames it took the 16-bit TLV field data_length straight off the wire and passed it to pb_istream_from_buffer(frame.data_value, frame.data_length) without checking it against the frame length or the receive buffer. frame.data_value sits 26 bytes into a 3188-byte stack object, so a data_length of up to 0xFFFF makes pb_decode() read up to roughly 62 KB past the end of that object.
Only the first fragment of a fragmented control response carries a TLV header; the pre-fix driver performed half-duplex SPI transactions and silently discarded any frame the co-processor queued while the host was transmitting (esp_hosted_hal_spi_transfer() aliased the RX buffer onto the TX buffer). When the discarded frame is the first fragment of a fragmented response, the driver treats the next fragment as a new frame — its per-fragment header and checksum are genuine, so both validation steps pass — and reads the TLV header out of raw protobuf continuation bytes. Those bytes come from control responses whose size and content an adjacent, unauthenticated attacker can influence, notably the AP scan list, which grows with the number and SSID length of access points in radio range.
The impact is denial of service rather than disclosure. Reading past the end of the RAM region faults the device, and CONFIG_NANOPB_ENABLE_MALLOC is selected by the driver, so garbage length prefixes read out of bounds also drive heap allocations. The out-of-bounds bytes themselves do not reach the application: pb_decode() is started mid-stream on raw protobuf continuation bytes and so almost always fails outright, and anything that did decode would still have to pass esp_hosted_response(), which requires an exact msg_id match against the pending request, and then esp_hosted_ctrl_response(), which requires a success resp — an attacker influences the size and content of legitimate control responses, not the structure decoded out of misaligned bytes. Two related defects in the same receive path make the denial of service permanent: the fragment reassembly guard was sized with ESP_FRAME_SIZE instead of ESP_FRAME_MAX_PAYLOAD and, when tripped, returned from the sole RX thread instead of dropping the frame, and unhandled control events were queued with k_msgq_put(..., K_FOREVER) on an eight-entry queue that nothing drains, blocking that same thread. The driver has no watchdog or restart path, so either condition ends all Wi-Fi reception until the device is rebooted.
📍 영향받는 시스템
Espressif ESP-hosted Wi-Fi driver (drivers/wifi/esp_hosted/)
⚔️ 공격 벡터
인증되지 않은 공격자가 주변 Wi-Fi 환경(AP 스캔 목록 등)을 조작하여 조작된 제어 프레임을 전송
🛡️ 대응 방법
드라이버의 TLV 데이터 길이 검증 로직을 수정하고, 프레임 재조립 가드 및 메시지 큐 처리 방식을 업데이트하여 패치 적용
🔧 검증 코드
명령어 결과에서 데이터 길이 검증 없이 pb_istream_from_buffer가 호출되는 코드가 발견되면 취약한 버전입니다.
git grep -r "esp_hosted_event_task" drivers/wifi/esp_hosted/ | grep "pb_istream_from_buffer"