Closed devsaurus closed 7 years ago
https://github.com/espressif/esp-idf/blob/master/components/lwip/apps/dhcpserver.c#L897 https://github.com/espressif/esp-idf/blob/master/components/lwip/apps/dhcpserver.c#L918
No check for dhcps_msg overflow
This blocks certain clients that send such packets from interfacing with the ESP AP.
Are these packets in spec? How to resolve? Drop the extra bytes?
Are these packets in spec?
https://www.ietf.org/rfc/rfc2131.txt only states a minimum supported option length for the client - 312 octets. No spec for the server if I didn't miss anything there.
How to resolve? Drop the extra bytes?
I got the recommendation back then to increase the options
length from 312 to MTU - IPHEAD(20) - UDPHEAD(8) - DHCPHEAD(236). This accommodates the payload of a full UDP packet. Drawback of this simple solution is that the server starts to reply with these big packets itself since sizeof(struct dhcps_msg)
increases accordingly.
Thanks @devsaurus, your analysis is helpful for us, will update you once we have new progress...
Hi @devsaurus @negativekelvin the fix for this issue is submit, it will be targeted into idf release 2.1 dhcpserver.c.tar.gz
Thanks for the fix, @liuzfesp!
We've experienced and reported the same issue with NodeMCU based on non-OS SDK in the past. It appears to be still present in the IDF's dhcpserver.
Problem description
When the firmware is in soft-AP mode and DHCP server is enabled, the DHCP server will cause a crash when a packet is received that exceeds the expected size for struct dhcp_msg in dhcpserver.h. This blocks certain clients that send such packets from interfacing with the ESP AP.
Steps to reproduce
Download and extract dhcp_msgs.zip.
dhcp.bin
contains a valid DHCP request.dhcp_fault.bin
adds a lot of 0xdeadbeef in the padding section to extend the size of the DHCP request beyond the size of struct dhcp_msg.Connect to the ESP AP from a Linux machine. At the shell execute
This triggers an immediate reset of the firmware.