🇰🇷 한글 설명
hawkBit 장치 관리 클라이언트의 response_json_cb() 함수에서 HTTP 응답 본문을 힙 버퍼에 저장할 때, 문자열 종료를 위한 NUL 문자를 위한 공간을 확보하지 않아 힙 기반 경계 외 쓰기(Out-of-bounds Write)가 발생합니다. 공격자가 제어하는 업데이트 서버가 특정 크기의 응답을 보낼 경우, 할당된 메모리 범위를 벗어나 1바이트를 쓰게 되어 힙 메모리 오염을 유발할 수 있습니다.
💡 쉬운 설명
데이터를 담는 그릇을 만들 때 마지막 마침표를 찍을 공간을 미리 만들지 않아, 그릇 밖으로 마침표를 찍어버리는 문제입니다. 이로 인해 시스템의 메모리가 엉망이 되어 장치가 갑자기 멈추거나 재시작될 수 있습니다.
🇺🇸 원문 (English)
The hawkBit device management client in subsys/mgmt/hawkbit accumulates the body of an HTTP response from the update server into a heap buffer in response_json_cb() (subsys/mgmt/hawkbit/hawkbit.c). The buffer is sized to hold the received body bytes but reserves no space for a terminating NUL. When the full response has arrived, the code writes response_data[downloaded_size] = '\0' — and whenever the accumulated body length equals the allocation, that terminator lands one byte past the end of the heap object (a heap-based out-of-bounds write, CWE-122 / CWE-787).
The body length and fragmentation are taken directly from the parsed HTTP response (rsp->body_frag_start / rsp->body_frag_len) and are fully controlled by the remote hawkBit server, which chooses its own response length. The precise trigger depends on how the buffer grows, and both forms are remotely reachable. Since v4.0.0 the reallocation is sized to exactly downloaded_size + body_len, so any response body larger than the 1100-byte initial buffer makes the out-of-bounds write deterministic; such response sizes are normal for hawkBit deployment metadata. Before v4.0.0 the buffer grew by doubling and the growth check ((downloaded_size + body_len) > response_buffer_size) is false at equality, so a response body whose length is exactly the current allocation — 1100 bytes with the default initial buffer — skips the reallocation entirely and writes the terminator at response_data[1100] of an 1100-byte object. The HTTP length-mismatch check does not catch this, because the declared and received lengths genuinely agree. Either form is reachable by a malicious, compromised, or man-in-the-middle update server (TLS is optional and, when enabled, does not protect against a hostile server), with no authentication of response content and no client-side length cap protecting the write.
The out-of-bounds write is a fixed single NUL byte immediately following the allocation, corrupting adjacent allocator metadata or the next allocation. The practical impact is heap corruption leading to denial of service (fault on a subsequent allocation or free), with the bounded, allocator-dependent possibility of further corruption. The fix sizes the buffer to the body length plus one and copies with memcpy, ensuring the terminator always lands within the allocation.
📍 영향받는 시스템
hawkBit device management client (v4.0.0 미만 및 특정 조건의 v4.0.0 이상 버전)
⚔️ 공격 벡터
악의적인 또는 탈취된 hawkBit 업데이트 서버를 통한 원격 HTTP 응답 전송
🛡️ 대응 방법
버퍼 크기를 응답 본문 길이에 1바이트를 더한 크기로 할당하도록 소프트웨어를 업데이트하십시오.
🔧 검증 코드
출력된 버전이 v4.0.0 미만인지 확인하거나, 패치된 최신 버전인지 보안 공지사항과 대조하십시오.
hawkbit-client --version 2>/dev/null || echo 'Version check not supported via CLI'