I found a lot of resources about how to secure WiFi networks. This question is not about that. How can I make sure the software running on the modem/router is not exploitable to known security flaws? I found reports on many discovered vulnerabilities, but to my surprise no-one has put up exhaustive lists on vulnerable devices? Even the manufacturers don't report which of their devices are vulnerable, even though they know.
Listing some vulnerabilities which allow remote code execution on routers:
UPnP: researchers found exploitable flaws in some widely used UPnP implementations. UPnP is a feature which is on by default in many routers, printers and other devices.
Over 80 million unique IPs were identified that responded to UPnP discovery requests from the internet. Somewhere between 40 and 50 million IPs are vulnerable to at least one of three attacks outlined in this paper. Source.
I've disabled UPnP on my modem.
WPS: This only applies to attackers within WiFi distance, so it's not that bad, but I've disabled WPS on my router anyway.
Then there's Misfortune Cookie, which in 2014 affected at least 12 million devices on the internet. The vulnerability is in a RomPager webserver running inside many routers to provide an admin interface. "Attackers can send specially crafted HTTP cookies that exploit the vulnerability to corrupt memory and alter the application state." I don't understand why the web server for the admin interface of a router has to be visible to the internet in the first place... I was unable to find out whether my modem or router are affected by this.