-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Open
Description
Brief description
There is a bug where the TCP layer within an ICMPv6 error message is incorrectly parsed as TCP instead of TCPerror. This occurs when the IPerror6 is followed by an IPv6 extension header.
Scapy version
2.7.0
Python version
3.11.0
Operating system
Ubuntu 22.04.5 LTS
Additional environment information
No response
How to reproduce
Here is a simple example to reproduce the bug:
# example.py
from scapy.layers.inet import TCPerror
from scapy.layers.inet6 import IPv6, IPerror6, ICMPv6DestUnreach, IPv6ExtHdrFragment
pkt = (
IPv6(src="2001:da8::1", dst="2001:da8::5")
/ ICMPv6DestUnreach()
/ IPerror6(src="2001:da8::5", dst="2001:da8::6")
/ IPv6ExtHdrFragment(m=0, offset=0)
/ TCPerror()
)
print("The parsed packet:")
parsed_pkt = IPv6(pkt.build())
parsed_pkt.show()Actual result
$ python3 example.py
The parsed packet:
###[ IPv6 ]###
version = 6
tc = 0
fl = 0
plen = 76
nh = ICMPv6
hlim = 64
src = 2001:da8::1
dst = 2001:da8::5
###[ ICMPv6 Destination Unreachable ]###
type = Destination unreachable
code = No route to destination
cksum = 0x10df
length = 0
unused = 0x0
extpad = b''
ext = None
###[ IPv6 in ICMPv6 ]###
version = 6
tc = 0
fl = 0
plen = 28
nh = Fragment Header
hlim = 64
src = 2001:da8::5
dst = 2001:da8::6
###[ IPv6 Extension Header - Fragmentation header ]###
nh = TCP
res1 = 0
offset = 0
res2 = 0
m = 0
id = 0
###[ TCP ]###
sport = ftp_data
dport = http
seq = 0
ack = 0
dataofs = 5
reserved = 0
flags = S
window = 8192
chksum = 0x3422
urgptr = 0
options = []
Expected result
The parsed packet:
###[ IPv6 ]###
version = 6
tc = 0
fl = 0
plen = 76
nh = ICMPv6
hlim = 64
src = 2001:da8::1
dst = 2001:da8::5
###[ ICMPv6 Destination Unreachable ]###
type = Destination unreachable
code = No route to destination
cksum = 0x10df
length = 0
unused = 0x0
extpad = b''
ext = None
###[ IPv6 in ICMPv6 ]###
version = 6
tc = 0
fl = 0
plen = 28
nh = Fragment Header
hlim = 64
src = 2001:da8::5
dst = 2001:da8::6
###[ IPv6 Extension Header - Fragmentation header ]###
nh = TCP
res1 = 0
offset = 0
res2 = 0
m = 0
id = 0
###[ TCP in ICMP ]###
sport = ftp_data
dport = http
seq = 0
ack = 0
dataofs = 5
reserved = 0
flags = S
window = 8192
chksum = 0x3422
urgptr = 0
options = []
Related resources
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels