secdev / secdev/scapy

Missmatch between recalculated and received UDP checksum

Open
#4,906 3 comments 0 reactions 1 assignee View on GitHub

@guedou is already working on this.

Since Feb 11, 2026.

bug
Dominant language
Python
Stars
12.6k
Forks
2.2k
Avg merge
1d 4h
Merged PRs (30d)
56

Description

Brief description

Problems with Scapy providing a different value for the UDP checksum (when recalculated) than what is received

I'm using a VXLAN packet (see attached code snippet) that uses IPv6. To calculate the UDP checksum, scapy calculates an IPv6 pseudo header, but seems it is using the wrong UDP packet length (rfc2460 section-8.1). Scapy gives:

ph6.src = ::
ph6.dst = ::
ph6.uplen = 43
ph6.zero = 0
ph6.nh = 17

The correct length should be 270 but scapy is only using the udp_hdr_len (8B), vxlan_hdr_len (8B), inner_ether_src (6B), inner_ether_dst (6B), inner_ether_len (2B), LLC_hdr_len (4B), the following 9B after LLC HDR and ignoring all the rest of the payload.

Wireshark does compute the expected (0x1a8) UDP checksum when parsing this packet. This packet is generated using a test equipment and captured inside the same test equipment, so there is no offload going on.

Using scapy 2.7.0 and python 3.11.2

Scapy version

2.7.0

Python version

3.11.2

Operating system

Lubuntu 20.04

Additional environment information

No response

How to reproduce
import binascii

from scapy.all import *
from scapy.layers.l2 import Ether
from scapy.layers.inet import UDP

pkt_data = "ffffffffffffffffffffffff8100000086dd60000000010e1100000000000000000000000000000000000000000000000000000000000000000018bd2118010e01a8738a32362d5473c879f89f16a8f9cd673fec8d6b000d9a2976054be71268024a7817f64d63fad1d4eb2db918f004c198dc03e7ec4e836ca554e1b4f0c157c61728ae722bd55eac05d698f04a0df32b8d21f031ae70a7ad530d027915763af0e736fa6d61a334289b3aef64855b44ed09f02de48485a3337575d409561fe192bca02214a8a5b10cc66c756992eadaeaf56f8eeeb58c18cce9f36fd8983ff7890dedc28ed254080c180231440188d5afc32bff2193a8f94a1b683b1e850a613eaf42ccd37e5af706d93b11e31649a1b9f39c613ce5a4263fcfe7873da6fdd9d09c90f15b687efc3342189cbac70ab686d1dc5f000015128c4d3400080000034584f14d8e217811d6cee444"

data_bytes = binascii.unhexlify(pkt_data)
p0 = Ether(data_bytes)

print('--'*20)
print("checksum (received): ", hex(p0[UDP].chksum))

del p0[UDP].chksum
p0 = p0.__class__(bytes(p0))

print("checksum (scapy)   : ", hex(p0[UDP].chksum))

Actual result
---------------------------------------- 
checksum (received):  0x1a8 
checksum (scapy)   :  0x424d
Expected result
---------------------------------------- 
checksum (received):  0x1a8 
checksum (scapy)   :  0x424d

expected checksum calculated by scapy: 0x1a8 
Related resources

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.