[Bug] raw-API DHCP server reads client option values without bounds checks (OOB read)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- c
- 領域
- networking, security
調査の方向性
components/net/lwip-dhcpd/dhcp_server_raw.cを読み、まずdhcp_server_option_findと引用された行にある呼び出し元を確認します。それらのチェックを、ソケットベースのdhcp_server.cのチェックと比較してください。読み取り前にオプションヘッダーの境界と宣言された値の長さを検証し、切り詰められたオプションが拒否され、有効なDHCPオプションが引き続き正しく処理されることを確認してください。
索引モデルが issue の本文から書いたものです。
説明
RT-Thread Version
master @ 1c801efabc.
Affected area
Networking
Hardware/BSP vendor
Not applicable / Other
Architecture
Not applicable / Other
Board and hardware details
Not applicable.
Develop Toolchain
GCC
Describe the bug
The raw-API DHCP server parses client packets without bounding the option walk or the option-value reads.
components/net/lwip-dhcpd/dhcp_server_raw.c:296:
static u8_t *dhcp_server_option_find(u8_t *buf, u16_t len, u8_t option) {
u8_t *end = buf + len;
while ((buf < end) && (*buf != DHCP_OPTION_END)) {
if (*buf == option) return buf;
buf += (buf[1] + 2); /* buf[1] read even when buf == end-1 */
}
return NULL;
}
buf[1] is read without verifying buf + 1 < end, so a final option header at end-1 reads one byte past the buffer. The function also only guarantees the returned pointer is < end, and the callers read the value with no length check:
node = dhcp_client_find_by_ip(dhcpserver, (ip4_addr_t *)(&opt[2])); /* :209, reads 4 bytes */
msg_type = *(opt + 2); /* :372 */
A REQUESTED_IP (50) or MESSAGE_TYPE (53) option placed at the tail lets opt[2]..opt[5] read up to 4 bytes past the buffer. The packet buffer is a fixed pbuf_alloc(PBUF_TRANSPORT, 1500, PBUF_RAM) (:331), so the over-reads land just past that heap allocation.
The sibling socket-based server dhcp_server.c performs exactly the checks this file omits (dhcp_opt + 2 > dhcp_opt_end, declared-length validation, length < 4 / length < 1), which confirms the raw variant is missing them.
Steps / trigger. Any host on the same L2 segment sends a DHCP packet to UDP/67 whose option area ends with a REQUESTED_IP / MESSAGE_TYPE option header positioned so its value bytes fall at or past the buffer end. No authentication. Reproduced at logic level under ASan (reports/repro/dhcpd-raw/).
Expected. Short or truncated options are rejected before their length/value bytes are read, as dhcp_server.c already does.
Actual. Out-of-bounds read of a few bytes past the 1500-byte heap allocation. The values are used only for dispatch / IP comparison and are not returned to the attacker, so the practical impact is a crash / DoS if the allocation abuts an unmapped page.
Suggested fix. Port the socket variant's checks: require buf + 1 < end before reading buf[1] and buf + 2 + buf[1] <= end before advancing; in each caller verify the matched option's declared length and that opt + 2 + opt[1] <= end before reading the value.
Other additional context
No response
- 主要言語
- C
- スター
- 12.3k
- フォーク
- 5.5k
- 平均マージ
- 7日 22時間
- マージ済み PR(30日)
- 30
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
RT-Thread/rt-thread のほかの issue
-
[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 が 1 日前に担当しました。 オープンin progress
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
RT-Thread/rt-thread#11902 · コメント 4 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
[bsp][stm32][bluepill] README「快速上手」缺少重新生成 MDK 工程这一步,按文档操作无法编译通过対応中かも @moment-NEW が 18 日前に担当しました。 オープン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 日以内に返信
-
Arch: RISC-V BSP BSP: HPMicro bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
RT-Thread/rt-thread#11687 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
RT-Thread/rt-thread#11472 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
RT-Thread/rt-thread の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
colbymchenry/codegraph#2770 ·
メンテナーはふだん 1 日以内に返信
-
area/ysql kind/enhancement priority/medium status/awaiting-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
yugabyte/yugabyte-db#35578 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
Bug Status: Needs Triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
interpreter-core type-feature
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信