🇰🇷 한글 설명
DHCPv4 클라이언트의 net_dhcpv4_msg_type_name() 함수에서 잘못된 경계 검사로 인해 발생하는 인덱스 범위 초과 취약점입니다. sizeof 연산자가 요소 개수가 아닌 바이트 크기를 반환하여, 공격자가 조작된 DHCP 메시지 타입을 전송할 경우 배열 범위를 벗어난 메모리 읽기가 발생합니다. 이로 인해 시스템 충돌(DoS)이나 인접 메모리 정보 유출이 발생할 수 있습니다.
💡 쉬운 설명
네트워크 설정 정보를 받는 과정에서 잘못된 숫자가 들어왔을 때 이를 제대로 걸러내지 못하는 오류입니다. 해커가 가짜 신호를 보내면 컴퓨터 프로그램이 갑자기 꺼지거나 내부 정보가 밖으로 새 나갈 수 있습니다.
🇺🇸 원문 (English)
The DHCPv4 client helper net_dhcpv4_msg_type_name() in subsys/net/lib/dhcpv4/dhcpv4.c indexes a static 8-element const char * name table after a faulty bounds check. The guard used msg_type <= sizeof(name) instead of msg_type <= ARRAY_SIZE(name); sizeof returns the byte size of the pointer array (32 on 32-bit, 64 on 64-bit targets) rather than the element count of 8, so message-type values from 9 up to that byte size pass the check and cause name[msg_type - 1] to read past the end of the array.
The msg_type value originates from the DHCP MESSAGE TYPE option, which is read as an unchecked raw byte from a received packet (net_pkt_read_u8) and passed unmodified into the lookup. A DHCP server, or any host able to inject a spoofed DHCP reply onto the client's link, can therefore drive the index out of bounds. The out-of-range slot yields a garbage const char * that is then dereferenced by a %s log conversion.
The lookup is reached only from a debug log statement (NET_DBG / LOG_DBG), so the out-of-bounds read is triggerable only when the DHCPv4 log module is built at DEBUG level (CONFIG_NET_DHCPV4_LOG_LEVEL_DBG), which is not the default configuration. When that condition holds, the result is an out-of-bounds read and a wild-pointer dereference: most likely a crash of the DHCP client (denial of service) and potentially disclosure of an adjacent pointer's contents through the log output. The fix replaces sizeof with ARRAY_SIZE, restoring the correct 1..8 acceptance window.
📍 영향받는 시스템
DHCPv4 로그 레벨이 DEBUG로 설정된(CONFIG_NET_DHCPV4_LOG_LEVEL_DBG) 시스템
⚔️ 공격 벡터
네트워크 상에서 조작된 DHCP 응답 패킷을 전송하여 공격
🛡️ 대응 방법
sizeof 대신 ARRAY_SIZE 매크로를 사용하여 경계 검사 로직을 수정
🔧 검증 코드
명령어 결과에서 sizeof(name)이 발견되면 취약한 코드가 포함된 것이며, ARRAY_SIZE(name)으로 되어 있어야 안전합니다.
grep -r "sizeof(name)" subsys/net/lib/dhcpv4/dhcpv4.c