DHCP server unbounded option parsing - OOB read from packet buffer
維護者通常 1 天內回覆
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 68/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 冷清
- 技術堆疊
- c
研究方向
從 components/net/lwip-dhcpd/dhcp_server.c 的第 346 行開始,追蹤接收封包的長度和選項位置是如何表示的。使用 AddressSanitizer 建置 DHCP 伺服器,並傳送所描述的格式錯誤 DHCP 封包,其中包括缺少的結束標記和過大的選項長度。當格式錯誤的選項不再導致讀取超出封包緩衝區時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
RT-Thread Version
tested HEAD, commit 38c007af
Hardware Type/Architectures
independent (Bug is in lwip-dhcpd C implementation)
Develop Toolchain
Other
Describe the bug
Summary
A buffer over-read vulnerability exists in RT-Thread's DHCP server implementation (components/net/lwip-dhcpd/dhcp_server.c) where the DHCP option parsing loop has no bounds check on the input buffer position, allowing a crafted DHCP packet to read past the allocated buffer.
Details
File: components/net/lwip-dhcpd/dhcp_server.c, line 346
The DHCP options parsing loop uses while(finished == 0) to iterate through options in the received packet. The loop reads option type and length fields from the packet data but does NOT check whether the current read position exceeds the packet buffer boundary.
/* dhcp_server.c:346 */
while(finished == 0) {
/* reads option type and length from packet data */
/* NO check that position < packet_length */
}
Since DHCP packets are received over the network with no authentication, this is reachable pre-authentication on the local network segment.
PoC
Send a crafted DHCP packet on the local network segment with:
- Valid DHCP header (op=1, htype=1, hlen=6)
- Options section containing a chain of options where each option's length field points past the end of the packet
- No DHCP_OPTION_END (0xFF) marker
The server's option parsing loop will read past the packet buffer boundary until it hits unmapped memory (crash) or reads adjacent heap data (info leak).
Build and run the RT-Thread DHCP server component with AddressSanitizer enabled to observe the over-read:
# Cross-compile RT-Thread with ASAN, enable lwip-dhcpd,
# send crafted DHCP DISCOVER on the local interface
Other additional context
Impact
- Out-of-bounds read from the packet buffer
- Potential information disclosure from adjacent heap memory
- Potential crash (DoS) if reading into unmapped memory
- Affects any RT-Thread device running the built-in DHCP server
- Attack vector: adjacent network (DHCP is link-local), no authentication required
Suggested fix:
- while(finished == 0) {
+ while(finished == 0 && position < packet_length) {
Also validate that position + option_length does not exceed packet_length before reading option data.
- 主要語言
- C
- 星號
- 12.3k
- 分支
- 5.5k
- 平均合併
- 6 天 32 分鐘
- 30 天內合併 PR
- 24
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
RT-Thread/rt-thread 的其他 Issue
-
[Bug] [libc] timer_gettime 拆秒前将总纳秒截断为 uint32_t,剩余时间查询错误可能已有人在做 @Yunlk 於 2 天前認領。 未關閉in progress
難度 2/5 1-3 小時 新手友好度 68/100
RT-Thread/rt-thread#11924 · 6 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
bug Component component: net
難度 2/5 1-3 小時 新手友好度 78/100
RT-Thread/rt-thread#11913 · 1 則留言 ·
維護者通常 1 天內回覆
-
[Bug] dfs_v2 tmpfs: ftruncate(fd, 0) frees the file buffer but reports success — use-after-free read/write and double free from a legal POSIX call可能已有人在做 @remukisama 於 6 天前認領。 未關閉in progress
難度 2/5 1-3 小時 新手友好度 78/100
RT-Thread/rt-thread#11902 · 4 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
[bsp][stm32][bluepill] README「快速上手」缺少重新生成 MDK 工程这一步,按文档操作无法编译通过可能已有人在做 @moment-NEW 於 23 天前認領。 未關閉in progress
難度 2/5 1-3 小時 新手友好度 75/100
RT-Thread/rt-thread#11818 · 4 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
BSP BSP: Loongson bug RT-Smart
難度 2/5 1-3 小時 新手友好度 72/100
RT-Thread/rt-thread#11717 · 2 則留言 ·
維護者通常 1 天內回覆
查看 RT-Thread/rt-thread 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 72/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
yunusemreyl/omen-space#337 ·
維護者通常 1 天內回覆
-
dependency component: oneMKL module: dpclang
難度 2/5 1-3 小時 新手友好度 82/100
intel/torch-xpu-ops#5880 ·
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 65/100
netty/netty-tcnative#1024 ·