🇰🇷 한글 설명
Zephyr RTOS의 UpdateHub OTA 클라이언트(subsys/mgmt/updatehub/updatehub.c)에서 z_impl_updatehub_probe() 함수가 초기화되지 않은 힙 메모리를 읽는 취약점입니다. 서버 응답을 복사할 때 NUL 종료 문자가 누락되어 strlen()이 할당 범위를 넘어 읽을 수 있으며, 이로 인해 업데이트 스레드나 장치가 충돌할 수 있습니다. 공격자는 첫 번째 JSON 파싱을 실패시키는 대용량 페이로드로 이 경로를 유도할 수 있습니다.
💡 쉬운 설명
기기가 업데이트 서버에서 받은 데이터를 처리하는 과정에서 메모리 경계를 잘못 확인해 엉뚱한 메모리를 읽게 됩니다. 이로 인해 악의적인 서버나 중간자 공격으로 기기가 멈추거나 재부팅될 수 있습니다.
🇺🇸 원문 (English)
The UpdateHub OTA client in subsys/mgmt/updatehub/updatehub.c contains an out-of-bounds / uninitialized-memory read in z_impl_updatehub_probe(). The probe response from the UpdateHub server is copied into a heap buffer (metadata) that is correctly NUL-terminated, but a second buffer (metadata_copy) is allocated with k_malloc (unzeroed) and filled with memcpy(metadata_copy, metadata, strlen(metadata)), which omits the terminating NUL. Everything after the copied content remains uninitialized heap.
When the first json_obj_parse() over the array descriptor fails, the code falls back to json_obj_parse(metadata_copy, strlen(metadata_copy), ...). The strlen() call scans past the copied bytes through uninitialized heap and, if no zero byte is found before the end of the allocation, reads beyond the buffer; the resulting over-long length is then parsed as JSON. The probe payload is fully controlled by the (malicious, compromised, or — without the optional CONFIG_UPDATEHUB_DTLS — on-path) UpdateHub server, which can craft a large payload that fails the first parse to drive this path.
The consequence is a read of uninitialized heap, with a worst case of an out-of-bounds read past the metadata_copy allocation that can fault and crash the update thread/device, producing a network-triggerable denial of service. The over-read data is consumed only internally to evaluate the update and is not returned to the attacker, so there is no direct information disclosure and no out-of-bounds write.
The fix zeroes metadata_copy with memset before the copy, guaranteeing NUL termination and bounding strlen() within the allocation.
📍 영향받는 시스템
UpdateHub OTA 클라이언트를 사용하는 Zephyr RTOS 기반 임베디드 장치 (수정 이전 Zephyr 버전)
⚔️ 공격 벡터
악의적이거나 손상된 UpdateHub 서버, 또는 DTLS를 사용하지 않는 경우 네트워크 중간자가 조작된 대용량 probe 응답을 전송하여 과도한 메모리 읽기를 유발
🛡️ 대응 방법
Zephyr를 수정된 버전으로 업데이트하고, metadata_copy를 memcpy 전에 memset으로 초기화하는 패치를 적용하며, CONFIG_UPDATEHUB_DTLS를 활성화
🔧 검증 코드
첫 번째 명령은 Zephyr 버전을 확인하고 두 번째 명령은 metadata_copy에 대한 memset이 있는지 검색합니다. 검색 결과가 없으면 패치가 적용되지 않은 것입니다.
west list zephyr 2>/dev/null || (cd zephyr 2>/dev/null && git describe --tags 2>/dev/null); grep -n 'memset(metadata_copy' subsys/mgmt/updatehub/updatehub.c 2>/dev/null