1

Today when I test running a tracert command (windows + Wireshark) I see a outbound ICMP_ECHO_REQUEST packet that has sourceIP as "192.168.1.55" - my local IPAddress.

It is followed by a ICMP_TTL_EXCEEDED packet sent from an internet wild host as reply to me that my EchoRequest packet died halfway. The reply-packet "quotes" first 28 byte of my "original packet" in the payload section where I can see the sourceIP staying "192.168.1.55" - my local ipAddress.

A question immediately pops out of my head: "The NAT did not rewrite the "local" sourceIP in IP-Header or did him rewrite it in payload "?

AFAIK in case of TCP or UDP packets, the NAT will replace the local "ip:port" with external "IP:PORT" in the IP-Header of the packet. So I am wondering:

1 - Whether NATs are replacing them in the payload section of packets? (Or just do that with ICMP packet of type TTL_Exceeded only?)

2 - If 1 is not true, is this a kind of security threat?

3

The answer is that it depends.

I have received ICMP messages from systems with a NAT device that let internal IP addresses leak through ICMP messages.

However in order for the receiver of an ICMP message to reliably associate it with a previously sent packet, the ICMP message need to contain the triggering packet essentially as it looked originally. This means if a packet triggers an ICMP message after being modified by a NAT, the NAT has to reverse the modifications inside the ICMP payload. And some NATs get this right.

There are more subtle aspects to notice. When a NAT modify IP addresses it also has to modify checksums inside the packet. However the ICMP payload is usually a truncated IP packet, thus transport layer checksums cannot be verified. For that reason they are rarely used, and leaving checksums inside ICMP payloads unmodified won't cause breakage. However this does cause checksums to be modified in one direction and not the other. That way a little bit of information about internal IP addresses can leak.

These leaks can be considered security vulnerabilities. This is just one kind of leaks a NAT can cause. More serious leaks are also possible including the possibility of sending packet fragments to another host than the intended recipient. Those are some of the reasons NATs are not a great idea. Replacing the NAT with a firewall without NAT will provide overall better security. But that of course requires more IP addresses.

  • So rewriting the icmp's payload is optional ? I know it's still arguable now that NATs should or should not rewrite ip:port in payload of icmp or even UDP/TCP. Some NATs are even mapping icmp's id to another id. But in your experience, can you tell the bahavior of majority of NATs regading ip rewriting in payload? – vantrung -cuncon Mar 29 '16 at 10:52
  • @vantrung-cuncon I don't know if any standards say whether a NAT has to rewrite the ICMP payload. But many NATs don't follow standards anyway. I haven't tested enough different NATs to make meaningful statements about the majority. I wonder if this study I heard about a few years back may cover that aspect. ICMP does not have any ID field, so I don't know which IDs it is you are thinking about. – kasperd Mar 29 '16 at 11:18
  • About the ID of icmp packet, it's called "identifier" if you look close enough to a icmp packet dump in wireshark. Cause icmp doesn't use Port concept as udp/tcp - icmp field "identifier" differentiates the mappings of different out-bound icmp instead. But some NAT producers thought that icmp's id can someday coincidentally conflicts cause it's randomly generated by different hosts behind same NAT, they try mapping even the icmp's id to another id & then translate it back to original id for icmp-replies. – vantrung -cuncon Mar 29 '16 at 11:33
  • @vantrung-cuncon ICMP does not have an ID field. ICMP has a 4 byte auxiliary field which is used for different purposes depending on the type of ICMP message. None of the ICMP types carrying an IP packet as their payload uses the auxiliary field for an ID. Some ICMP types are used to request that the other endpoint send an ICMP packet in response, those need to use part of the auxiliary field for an ID to match requests and responses, but that only applies to a few specific ICMP types. – kasperd Mar 29 '16 at 12:08
  • 1
    Yes you're right. It's for echo request only. I've just checked it again. Thanks ! – vantrung -cuncon Mar 29 '16 at 12:25
0

NAT does not touch the payload of packets. It touches only IP and TCP/UDP headers. IP addresses are included in IP header (source and destination). TCP header include source and destination ports, similarly for UDP header.

For ICMP case, you can look at this page. It states that in case of error message (such as TTL Exceeded), the packet includes IP header (20 bytes) + 8 bytes from payload = 28 bytes you have seen.

  • So you are saying that the inbound ICMP_TTL_EXCEEDED packet's payload is left as original as it was generated from the "wild internet host"? That leads to another fact that the internet host really knows my localIP cause it quoted my original packet that contains my localIP. This fact itself leads to another fact that my localIP was not translated at NAT when my original packet go out – vantrung -cuncon Mar 29 '16 at 9:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.