Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICMPv6 Time Exceeded is not using length field #4353

Open
ventaquil opened this issue Apr 18, 2024 · 0 comments
Open

ICMPv6 Time Exceeded is not using length field #4353

ventaquil opened this issue Apr 18, 2024 · 0 comments

Comments

@ventaquil
Copy link

ventaquil commented Apr 18, 2024

Brief description

Continuing work with ICMP Extension Headers started with #4281 issue, ICMPv6 is not using length field which causes malfunction in Wireshark packet tree.

ICMPv6

ICMPv6 without length

According to RFC 4884:

The length attribute represents length of the padded "original datagram" field, measured in 64-bit words.

Scapy version

2.5.0.dev317

Python version

3.10.12

Operating system

Linux 5.15.133.1

Additional environment information

No response

How to reproduce

  1. Prepare packet with ICMP Extension Header.
>>> pkt = Ether() / IPv6() / ICMPv6TimeExceeded(ext=ICMPExtension_Header()) / IPv6() / ICMPv6EchoRequest()
  1. Turn into bytes and again into Ether.
>>> pkt = bytes(pkt)
>>> pkt = Ether(pkt)
  1. Verify length field.
>>> pkt[ICMPv6TimeExceeded].length
0

Actual result

ICMPv6TimeExceeded.length field is not set when extension header is used.

>>> pkt = Ether() / IPv6() / ICMPv6TimeExceeded(ext=ICMPExtension_Header()) / IPv6() / ICMPv6EchoRequest()
>>> pkt = bytes(pkt)
>>> pkt = Ether(pkt)
>>> pkt[ICMPv6TimeExceeded].length
0
>>> pkt[ICMPv6TimeExceeded]
<ICMPv6TimeExceeded  type=Time exceeded code=hop limit exceeded in transit cksum=0x6231 length=0 unused=0x0 extpad=b'' ext=None |<IPerror6  version=6 tc=0 fl=0 plen=8 nh=ICMPv6 hlim=64 src=::1 dst=::1 |<ICMPv6EchoRequest  type=Echo Request code=0 cksum=0x7fbb id=0x0 seq=0x0 data=b'' |<Padding  load=b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x00\xdf\xff' |>>>>

Expected result

ICMPv6TimeExceeded.length is properly set (as 16 in this case).

Take a look to this packet catched in the wild.

>>> from scapy.contrib.mpls import ICMPExtension_MPLS
>>> pkt = b"\xa6\xc2\xa0\x1a\x03\t\x1a\x1b\r\x9d\x0e\x13\x86\xdd`\x00\x00\x00\x00\x98:5 \x01 4\x00\x00\x01M\x00\x00\x00\x00\x00\x00\x00\x01*\x01\x04\xf9\x00J'\xc1\x00\x00\x00\x00\x00\x00\x03\x10\x03\x008?\x10\x00\x00\x00`\x00~\x88\x00\x18:\x07*\x01\x04\xf9\x00J'\xc1\x00\x00\x00\x00\x00\x00\x03\x10 \x01\x05\xa06\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x80\x00F}\x02\x83\x80\xf3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x00\x19\xee\x00\x0c\x01\x01c\xfc@\x01\x00\x00!\x07"
>>> ether = Ether(pkt)
>>> ether
<Ether  dst=a6:c2:a0:1a:03:09 src=1a:1b:0d:9d:0e:13 type=IPv6 |<IPv6  version=6 tc=0 fl=0 plen=152 nh=ICMPv6 hlim=53 src=2001:2034:0:14d::1 dst=2a01:4f9:4a:27c1::310 |<ICMPv6TimeExceeded  type=Time exceeded code=hop limit exceeded in transit cksum=0x383f length=16 unused=0x0 extpad=b'' (64 octets) ext=<ICMPExtension_Header  version=2 reserved=0 chksum=0x19ee |<ICMPExtension_MPLS  len=12 classnum=MPLS classtype=1 stack=[<MPLS  label=409540 cos=0 s=0 ttl=1 |<MPLS  label=2 cos=0 s=1 ttl=7 |>>] |>> |<IPerror6  version=6 tc=0 fl=32392 plen=24 nh=ICMPv6 hlim=7 src=2a01:4f9:4a:27c1::310 dst=2001:5a0:3602::1 |<ICMPv6EchoRequest  type=Echo Request code=0 cksum=0x467d id=0x283 seq=0x80f3 data=b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' |>>>>>
>>> ether[ICMPv6TimeExceeded].length
16

Related resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant