For example, take a look at esp8266, which is a $2 wifi device with 1-16MB of program space (FLASH) and 80 KB (that is 0.08 MB) of RAM. There are no "remote execution" vulnerabilities there [0] -- just "DOS" and "bypass wireless encryption" ones. In general, for IoT, you encrypt all traffic and you do not trust user's networks anyway, so it should not matter that the network packets can be intercepted.
For more protection, you can use Wifi co-processors [1] -- then even if your wifi co-processor is completely compromised, the worst it can do is to monitor/change network packets, something that we know how to handle already.
[0] https://nvd.nist.gov/vuln/search/results?form_type=Basic&res...