Медвежья услуга от ядра OpenBSD
Каким образом роутеры на базе OpenBSD раздавали прописку наглым устройствам?
18 июня, тихий четверг, внезапно в tech@ прилетает патч с названием “ipv4: don’t forward packets from 0.0.0.0”, оказалось что все это время сетевой стек вел себя как заботливая мамочка.
Автор патча - David Gwynne, обратился в рассылку с письмом :
i don’t think we should forward packets with certain source addresses, and 0.0.0.0 in particular.
my initial motivation here is that ip_output special cases 0.0.0.0 and replaces it with an ip from the local system under the assumption that an unset ip originates from the local system.
in addition to this, my reading of rfc1122 makes me think it’s illegal from a standards point of view too.
however, i do think we should continue to treat packets from 0.0.0.0 on a connected network as valid because dhcp needs to do this. ie, we should accept packets from 0.0.0.0, but not forward them.
i discovered this because there’s a clever clogs dhcp implementation somewhere at work that knows it hasn’t got an address yet, but it tries talking to the dhcp server that last gave it an ip, which is on a different subnet in my topology. this means it sends a unicast ip packet from 0.0.0.0 to the ip of my dhcp server via the gateway on that subnet, which is pretty presumptuous of it.
at the moment my router tries to forward this, and it ends up changing the source ip on the packet to one of its addresses. this diff should make our ip stack drop the packet instead of forwarding it.
i havent run this on the firewall yet though. it’s pretty simple though, so should be easy to discuss.
В функции ip_forward() отсутствовала проверка исходного IPv4 адреса транзитных сетевых пакетов на INADDR_ANY ( 0.0.0.0 ), из-за чего маршрутизатор, вместо того чтобы отбросить мусорный пакет - пытался переслать unicast от узла у которого не было IP адреса, при этом подменяя 0.0.0.0 на собственный адрес интерфейса во время вызова ip_output(), по факту происходящего - срабатывала логика для локально сгенерированных пакетов.
Реакция Тео не заставила себя долго ждать :
Why has this not come up before?
Источники :