[Bug] raw-API DHCP server reads client option values without bounds checks (OOB read)
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 78/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- c
- Domaine
- networking, security
Piste de recherche
Lisez components/net/lwip-dhcpd/dhcp_server_raw.c, en commençant par dhcp_server_option_find et ses appelants aux lignes citées ; comparez leurs vérifications à celles de dhcp_server.c, qui utilise des sockets. Vérifiez les limites de l’en-tête de l’option et les longueurs de valeur déclarées avant toute lecture, puis confirmez que les options tronquées sont rejetées et que les options DHCP valides continuent d’être traitées correctement.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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
- Langage dominant
- C
- Étoiles
- 12.3k
- Forks
- 5.5k
- Merge moyen
- 7 j 22 h
- PR mergées (30 j)
- 30
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de RT-Thread/rt-thread
-
[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 callPeut-être pris @remukisama l’a pris il y a 1 jour. Ouvertein progress
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
RT-Thread/rt-thread#11902 · 4 commentaires · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
[bsp][stm32][bluepill] README「快速上手」缺少重新生成 MDK 工程这一步,按文档操作无法编译通过Peut-être pris @moment-NEW l’a pris il y a 18 jours. Ouvertein progress
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
RT-Thread/rt-thread#11818 · 4 commentaires · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
BSP BSP: Loongson bug RT-Smart
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
RT-Thread/rt-thread#11717 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Arch: RISC-V BSP BSP: HPMicro bug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
RT-Thread/rt-thread#11687 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
RT-Thread/rt-thread#11472 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de RT-Thread/rt-thread
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
Les mainteneurs répondent en général sous 1 jour
-
Bug Status: Needs Triage
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
Remove unused FVS_* macrosOuverteinterpreter-core type-feature
Difficulté 1/5 Moins d'une heure Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
[onnx] update to 1.22.0Ouvertecategory:port-update
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 2 jours
-
Update OpenBSD CI to OpenBSD 8.0 and vmactions/openbsd-vm v1.4.9Peut-être pris @hyoklee l’a pris aujourd’hui. Ouverte
Difficulté 1/5 1-3 heures Accessibilité débutants 85/100
Les mainteneurs répondent en général sous 2 jours