ICMPv6 Time Exceeded is not using `length` field
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 12.6k
- Forks
- 2.2k
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 56
Description
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.
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
- Prepare packet with ICMP Extension Header.
>>> pkt = Ether() / IPv6() / ICMPv6TimeExceeded(ext=ICMPExtension_Header()) / IPv6() / ICMPv6EchoRequest()
- Turn into
bytesand again intoEther.
>>> pkt = bytes(pkt)
>>> pkt = Ether(pkt)
- Verify
lengthfield.
>>> 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ICMPv6TimeExceeded entry point and reproduce the bytes-to-Ether round trip using an ICMPExtension_Header as shown. Confirm that the parsed length reflects the padded original datagram, reaching 16 for the provided example, and verify the packet tree no longer misrepresents the extension data.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100