🇰🇷 한글 설명
Zephyr의 DNS resolver에서 mDNS(.local) 쿼리를 처리할 때, 호스트 이름의 마지막 라벨이 7바이트보다 짧으면 NUL 종료 문자 이후의 메모리를 읽는 오버리드(Over-read) 취약점이 발생합니다. 이로 인해 메모리 경계를 넘어서는 읽기 작업이 수행될 경우 시스템이 충돌하여 서비스 거부(DoS) 상태에 빠질 수 있습니다.
💡 쉬운 설명
특정 주소를 검색할 때 컴퓨터가 주소의 끝을 확인하는 과정에서 정해진 길이보다 더 많은 데이터를 읽으려 시도합니다. 이 과정에서 잘못된 메모리 영역을 건드리면 시스템이 멈추거나 꺼질 수 있습니다.
🇺🇸 원문 (English)
Zephyr's DNS resolver detects mDNS (.local) queries in dns_resolve_name_internal() (subsys/net/lib/dns/resolve.c) with memcmp(strrchr(query, '.'), ".local", 7), which always reads a fixed 7 bytes from the suffix pointer. When the resolved hostname's final label is shorter than 7 bytes (e.g. names ending in .org, .com, .net, .io, or a trailing dot), the comparison reads 1-2 bytes past the string's NUL terminator.
The hostname (query) is the caller-supplied name passed through the standard getaddrinfo()/dns_get_addr_info()/dns_resolve_name() path and is influenceable by operators or remote inputs (server names from configuration, parsed URLs, or app-facing interfaces).
On a tightly-sized buffer with no slack (for example a userspace getaddrinfo call where the hostname is copied with k_usermode_string_alloc_copy to exactly strlen+1 bytes), the over-read crosses the allocation boundary; if that boundary is unmapped (guard page, memory-domain boundary under MPU, or an address sanitizer) the over-read faults, causing a denial of service. The over-read bytes are never returned, so there is no information disclosure.
The flaw is compiled only when CONFIG_MDNS_RESOLVER is enabled, exists since v1.10.0, and is fixed by replacing the fixed-length memcmp with a NUL-safe strcmp(ptr, ".local").
📍 영향받는 시스템
Zephyr RTOS v1.10.0 이상 버전 중 CONFIG_MDNS_RESOLVER가 활성화된 시스템
⚔️ 공격 벡터
사용자 또는 원격 입력(설정 파일, URL 등)을 통해 짧은 도메인 이름을 DNS 쿼리로 전달
🛡️ 대응 방법
고정 길이 memcmp 대신 NUL 안전한 strcmp(ptr, ".local")를 사용하도록 업데이트
🔧 검증 코드
명령어 결과로 해당 소스 코드 라인이 출력되면 취약한 버전이며, 아무것도 출력되지 않으면 수정된 버전입니다.
grep -r "memcmp(strrchr(query, '\\.'), \".local\", 7)" subsys/net/lib/dns/resolve.c