Skip to content

Scapy v2.6.0 doesn't correctly read routes in containers #4674

@michaelvdnet

Description

@michaelvdnet

Brief description

The new rtnetlink implementation builds an incorrect route table on Azure Container Apps.
This breaks pretty much all inet functionality as Ether layer dst and IP layer src fields are no longer correctly set due to lookup logic involving the route table.

Scapy version

2.6.1

Python version

3.11.11

Operating system

python:11-alpine image -> alpine 3.21.3 -> linux 5.15.173.1-1.cm2

Additional environment information

No response

How to reproduce

>>> scapy.__version__
>>> conf.route  
>>> conf.route.route()
>>> p = Ether()/IP(dst="<snip>")/ICMP()
>>> p.show()
>>> srp1(p)

Actual result

>>> scapy.__version__
'2.6.1.dev49'
>>> conf.route
Network          Netmask          Gateway      Iface  Output IP     Metric
0.0.0.0          0.0.0.0          169.254.1.1  eth0   0.0.0.0       0     
100.100.0.14     255.255.255.255  0.0.0.0      eth0   100.100.0.14  0     
100.100.127.255  255.255.255.255  0.0.0.0      eth0   100.100.0.14  0     
127.0.0.0        255.0.0.0        0.0.0.0      lo     127.0.0.1     0     
127.0.0.1        255.255.255.255  0.0.0.0      lo     127.0.0.1     0     
127.255.255.255  255.255.255.255  0.0.0.0      lo     127.0.0.1     0     
169.254.1.1      255.255.255.255  0.0.0.0      eth0   0.0.0.0       0     
>>> conf.route.route()
('lo', '0.0.0.0', '0.0.0.0')
>>> p = Ether()/IP(dst="<snip>")/ICMP()
>>> p.show()
###[ Ethernet ]###
  dst       = None
  src       = 26:5d:4b:dd:17:a0
  type      = IPv4
###[ IP ]###
     version   = 4
     ihl       = None
     tos       = 0x0
     len       = None
     id        = 1
     flags     = 
     frag      = 0
     ttl       = 64
     proto     = icmp
     chksum    = None
     src       = 0.0.0.0
     dst       = <snip>
     \options   \
###[ ICMP ]###
        type      = echo-request
        code      = 0
        chksum    = None
        id        = 0x0
        seq       = 0x0
        unused    = b''

>>> srp1(p)
Begin emission
WARNING: No broadcast address found for iface eth0

..............^CWARNING: MAC address to reach destination not found. Using broadcast.

Finished sending 0 packets

Received 14 packets, got 0 answers, remaining 0 packets

Expected result

>>> scapy.__version__
'2.5.0'
>>> conf.route
Network      Netmask          Gateway      Iface  Output IP     Metric
0.0.0.0      0.0.0.0          169.254.1.1  eth0   100.100.0.33  0     
127.0.0.0    255.0.0.0        0.0.0.0      lo     127.0.0.1     1     
169.254.1.1  255.255.255.255  0.0.0.0      eth0   100.100.0.33  0     
>>> conf.route.route()
('eth0', '100.100.0.33', '169.254.1.1')
>>> p = Ether()/IP(dst="<snip>")/ICMP()
>>> p.show()
WARNING: No broadcast address found for iface eth0

###[ Ethernet ]### 
  dst       = aa:aa:aa:aa:aa:aa
  src       = ae:f4:4a:dd:f9:60
  type      = IPv4
###[ IP ]### 
     version   = 4
     ihl       = None
     tos       = 0x0
     len       = None
     id        = 1
     flags     = 
     frag      = 0
     ttl       = 64
     proto     = icmp
     chksum    = None
     src       = 100.100.0.33
     dst       = <snip>
     \options   \
###[ ICMP ]### 
        type      = echo-request
        code      = 0
        chksum    = None
        id        = 0x0
        seq       = 0x0
        unused    = ''

>>> srp1(p)
Begin emission:
WARNING: No broadcast address found for iface eth0

Finished sending 1 packets.
*
Received 1 packets, got 1 answers, remaining 0 packets
<Ether  dst=ae:f4:4a:dd:f9:60 src=aa:aa:aa:aa:aa:aa type=IPv4 |<IP  version=4 ihl=5 tos=0x0 len=28 id=51819 flags= frag=0 ttl=62 proto=icmp chksum=0x4116 src=<snip> dst=100.100.0.33 |<ICMP  type=echo-reply code=0 chksum=0x0 id=0x0 seq=0x0 |>>>

Related resources

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions