net: ICMPv4 echo reply packets do not use default values in the IP header #13147
Labels
area: Conformance
Conformance tests
area: Networking
bug
The issue is a bug, or the PR is fixing a bug
Describe the bug
The ICMPv4 echo reply packets are build by reusing the echo request packet, only changing a few fields of the IP header. This means some fields of the outbound packet are taken from the inboud packet instead of using the default values from the interface, and most notably the TTL, flags and fragment offset. It might be safer to create a new packet using
net_ipv4_create()
andicmpv4_create()
and copying only the payload.To Reproduce
Send an ICMP echo request packet with a given TTL different than 64 (the default value in Zephyr). See how the echo reply packet comes back with the same TTL (if on the same subnet or lower if it goes through a router). Use a different TTL and observe how the echo reply packet use that different TTL.
Expected behavior
The echo reply packet should use the default IP header values and not the one from the inbound packet.
Impact
Conformance issue. It also means that the IP header sent by the board for ICMPv4 packets can partially be controlled by the inbound packet. It might have security impacts.
The text was updated successfully, but these errors were encountered: