Skip to content

IPv6 routes parsing bug on 2.6.0 #4541

@alancanniff

Description

@alancanniff

Brief description

After upgrading to scapy 2.6 previously working scripts now fail at the import stage. I've been able to reproduce this on the command line in a venv with only scapy installed.

I've attached a full version of the stack trace
example.txt

I've noticed from the stack trace reference to inet6. inet6 is not enabled on this host

$ ip a | grep inet6
$

Scapy version

2.6.0

Python version

3.9

Operating system

Linux 4.18.0-372.26.1.el8_6.x86_64

Additional environment information

Using rockylinux8

How to reproduce

using python3.9 run the following
from scapy.all import *

Actual result

(venv) myhost:~/username/project$ python
Python 3.9.18 (main, Nov 18 2023, 01:00:14)
[GCC 8.5.0 20210514 (Red Hat 8.5.0-20)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from scapy.all import *
ERROR: Loading module scapy.layers.dcerpc
Traceback (most recent call last):
  File "/home/jenkins/username/project/venv/lib64/python3.9/site-packages/scapy/main.py", line 226, in _load
    mod = importlib.import_module(module)
  File "/usr/lib64/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/jenkins/username/project/venv/lib64/python3.9/site-packages/scapy/layers/dcerpc.py", line 35, in <module>
    from scapy.layers.dns import DNSStrField
  File "/home/jenkins/username/project/venv/lib64/python3.9/site-packages/scapy/layers/dns.py", line 68, in <module>
    from scapy.layers.inet import IP, DestIPField, IPField, UDP, TCP
  File "/home/jenkins/username/project/venv/lib64/python3.9/site-packages/scapy/layers/inet.py", line 2541, in <module>
    import scapy.layers.inet6
  File "/home/jenkins/username/project/venv/lib64/python3.9/site-packages/scapy/layers/inet6.py", line 110, in <module>
    import scapy.route6  # noqa: F401
  File "/home/jenkins/username/project/venv/lib64/python3.9/site-packages/scapy/route6.py", line 333, in <module>
    conf.route6 = Route6()
  File "/home/jenkins/username/project/venv/lib64/python3.9/site-packages/scapy/route6.py", line 47, in __init__
    self.resync()
  File "/home/jenkins/username/project/venv/lib64/python3.9/site-packages/scapy/route6.py", line 64, in resync
    self.routes = read_routes6()
  File "/home/jenkins/username/project/venv/lib64/python3.9/site-packages/scapy/arch/linux/rtnetlink.py", line 961, in read_routes6
    cset = scapy.utils6.construct_source_candidate_set(prefix, plen, devaddrs)
  File "/home/jenkins/username/project/venv/lib64/python3.9/site-packages/scapy/utils6.py", line 75, in construct_source_candidate_set
    if in6_isgladdr(addr) or in6_isuladdr(addr):
  File "/home/jenkins/username/project/venv/lib64/python3.9/site-packages/scapy/utils6.py", line 784, in in6_isgladdr
    return in6_isincluded(str, '2000::', 3)
  File "/home/jenkins/username/project/venv/lib64/python3.9/site-packages/scapy/utils6.py", line 714, in in6_isincluded
    temp = inet_pton(socket.AF_INET6, addr)
  File "/home/jenkins/username/project/venv/lib64/python3.9/site-packages/scapy/pton_ntop.py", line 92, in inet_pton
    return socket.inet_pton(af, addr)
OSError: illegal IP address string passed to inet_pton

Expected result

I expect the package to load without error

Related resources

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions