🇰🇷 한글 설명
Zephyr RTOS의 DHCPv4 클라이언트가 트랜잭션 식별자(xid)를 트랜잭션마다 새로 생성하지 않고 카운터처럼 관리하여, RENEWING/REBINDING 시 동일한 식별자를 재사용하고 예측 가능하게 증가합니다. 이로 인해 공격자가 식별자를 알아내면 위조된 DHCP 응답으로 기본 게이트웨이와 DNS 설정을 공격자가 원하는 주소로 변경할 수 있습니다.
💡 쉬운 설명
기기가 네트워크 설정을 받을 때 쓰는 확인용 번호가 예측 가능해서 누군가 가짜 설정 응답을 보낼 수 있습니다. 그러면 기기의 인터넷 경로와 DNS가 공격자 쪽으로 바뀔 수 있습니다.
🇺🇸 원문 (English)
The DHCPv4 client in subsys/net/lib/dhcpv4/dhcpv4.c maintained its transaction identifier (iface->config.dhcpv4.xid) as a counter rather than as a per-transaction random value. It was seeded once with sys_rand32_get() in dhcpv4_start_internal(), incremented by one in dhcpv4_send_discover() and dhcpv4_send_decline(), and never changed by dhcpv4_send_request() — so every RENEWING and REBINDING exchange reused, unchanged, the identifier that had already appeared on the wire in the broadcast DHCPDISCOVER at boot, and where the identifier did move it moved predictably by one. RFC 2131 4.1 requires a single identifier per transaction, chosen so that clients are unlikely to collide.
This identifier is the client's only unpredictable reply-validation token. net_dhcpv4_input() accepts a BOOTP reply on op, a matching xid, and a matching chaddr (the interface MAC, which is public); the UDP callback is registered with a wildcard remote address and port, and no server-identifier or source-address check is applied. An attacker who learns one identifier — for example any host on the same segment that sees the broadcast DHCPDISCOVER, or a DHCP server or relay on a network the device previously joined — therefore retains a valid token for the device's whole uptime, and can predict the identifiers of later exchanges, without having to observe the unicast renew traffic or race the legitimate server.
A forged reply that passes those checks has effect regardless of client state, because dhcpv4_parse_options() applies its side effects before the state machine gate in dhcpv4_handle_reply(): the router option calls net_if_ipv4_set_gw() and the DNS option calls dns_resolve_reconfigure(). A single accepted datagram can thus repoint the device's default gateway and resolvers at attacker-controlled addresses, redirecting its traffic; during RENEWING or REBINDING a forged DHCPACK re-binds the lease with attacker-chosen parameters and a forged DHCPNAK removes the address and restarts configuration.
The fix draws a fresh sys_rand32_get() value at each point where a transaction begins — entering SELECTING, RENEWING and REBINDING, and at the INIT/INIT-REBOOT entry taken when an interface with a lease goes down — while REQUESTING and DECLINE keep the identifier of the exchange they belong to, as RFC 2131 requires. As a side effect the client also no longer discards a slow server's offer after retransmitting a discover, and the initial-discover backoff now draws its own randomness instead of deriving it from the identifier.
📍 영향받는 시스템
Zephyr RTOS의 DHCPv4 클라이언트(subsys/net/lib/dhcpv4)를 사용하는 임베디드 기기 (수정 이전 버전)
⚔️ 공격 벡터
같은 네트워크의 공격자가 브로드캐스트 DHCPDISCOVER 등으로 xid를 알아낸 뒤, 위조된 DHCPACK/DHCPNAK 응답을 보내 게이트웨이와 DNS를 변경
🛡️ 대응 방법
Zephyr의 수정된 버전으로 업데이트하여 트랜잭션 시작 시마다 sys_rand32_get()으로 새 xid를 생성하도록 패치 적용
🔧 검증 코드
결과에 RENEWING/REBINDING/SELECTING 진입 지점에서 sys_rand32_get() 호출이 포함되어 있으면 패치가 적용된 것이고, 호출이 시작 시 한 번뿐이면 취약한 상태입니다.
grep -rn "sys_rand32_get" $ZEPHYR_BASE/subsys/net/lib/dhcpv4/dhcpv4.c 2>/dev/null | head -20
📊 CVSS Vector String
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L
💻 영향받는 소프트웨어
Microsoft Exchange Server