python3-scapy: fix CVE-2026-128237 and CVE-2026-128238
PATCH 1/2 python3-scapy: fix CVE-2026-128237 and CVE-2026-128238
From: Ashishkumar Parmar <[email protected]>
This patch backports the shared upstream BER fix to the current version of Scapy. The fix bounds numeric decoding and recursive ASN.1/BER decoding. Both CVEs are addressed by the same upstream commit, referenced in [1]. Their public advisories are referenced in [2] and [3].
The CBOR files do not exist in the current version and are omitted. Applicable ASN.1/BER source and regression test changes are retained together.
[1] https://github.com/secdev/scapy/commit/36239645cf0b9408eb0821d9ed94f02e7b3c6dc6
[2] https://github.com/secdev/scapy/security/advisories/GHSA-xx44-g48m-mjp6
[3] https://github.com/secdev/scapy/security/advisories/GHSA-456h-w4v7-hvpr
--- .../CVE-2026-128237_CVE-2026-128238.patch | 269 ++++++++++++++++++ .../python/python3-scapy_2.6.1.bb | 1 + 2 files changed, 270 insertions(+) create mode 100644 meta-networking/recipes-devtools/python/python3-scapy/CVE-2026-128237_CVE-2026-128238.patch
meta-networking/recipes-devtools/python/python3-scapy/CVE-2026-128237_CVE-2026-128238.patch new file +269 -0
@@ -0,0 +1,269 @@ +From 46557d0e8fa42e93b82c09c78134ceb03ff52d9f Mon Sep 17 00:00:00 2001 +From: Gabriel <[email protected]> +Date: Fri, 31 Jul 2026 18:24:22 +0200 +Subject: [PATCH] Improve BER handling of integer boundaries (#5063) + +CVE: CVE-2026-128237 CVE-2026-128238 +Upstream-Status: Backport [https://github.com/secdev/scapy/commit/36239645cf0b9408eb0821d9ed94f02e7b3c6dc6] + +Backport Changes: +- Omit scapy/cbor/cbor.py and scapy/cbor/cborcodec.py because these + files do not exist in the current version. + +Signed-off-by: Ashishkumar Parmar <[email protected]> +--- + scapy/asn1/asn1.py | 12 +++++----- + scapy/asn1/ber.py | 57 ++++++++++++++++++++++++++++++++++----------- + test/regression.uts | 28 +++++++++++++++++----- + 3 files changed, 71 insertions(+), 26 deletions(-) + +diff --git a/scapy/asn1/asn1.py b/scapy/asn1/asn1.py +index 0783a3b3..44588b6f 100644 +--- a/scapy/asn1/asn1.py ++++ b/scapy/asn1/asn1.py +@@ -126,13 +126,13 @@ class ASN1Codec(EnumElement): + # type: (Type[BERcodec_Object[Any]]) -> None + cls._stem = stem + +- def dec(cls, s, context=None): +- # type: (bytes, Optional[Type[ASN1_Class]]) -> ASN1_Object[Any] +- return cls._stem.dec(s, context=context) # type: ignore ++ def dec(cls, s, context=None, _depth=0): ++ # type: (bytes, Optional[Type[ASN1_Class]], int) -> ASN1_Object[Any] ++ return cls._stem.dec(s, context=context, _depth=_depth) # type: ignore + +- def safedec(cls, s, context=None): +- # type: (bytes, Optional[Type[ASN1_Class]]) -> ASN1_Object[Any] +- return cls._stem.safedec(s, context=context) # type: ignore ++ def safedec(cls, s, context=None, _depth=0): ++ # type: (bytes, Optional[Type[ASN1_Class]], int) -> ASN1_Object[Any] ++ return cls._stem.safedec(s, context=context, _depth=_depth) # type: ignore + + def get_stem(cls): + # type: () -> type +diff --git a/scapy/asn1/ber.py b/scapy/asn1/ber.py +index 23899274..b5ffc425 100644 +--- a/scapy/asn1/ber.py ++++ b/scapy/asn1/ber.py +@@ -50,6 +50,8 @@ from typing import ( + + # [ BER tools ] # + ++MAX_BER_DEPTH = 32 ++ + + class BER_Exception(Exception): + pass +@@ -155,8 +157,8 @@ def BER_num_enc(ll, size=1): + return b"".join(chb(k) for k in x) + + +-def BER_num_dec(s, cls_id=0): +- # type: (bytes, int) -> Tuple[int, bytes] ++def BER_num_dec(s, cls_id=0, max_pow=32): ++ # type: (bytes, int, int) -> Tuple[int, bytes] + if len(s) == 0: + raise BER_Decoding_Error("BER_num_dec: got empty string", remaining=s) + x = cls_id +@@ -166,6 +168,9 @@ def BER_num_dec(s, cls_id=0): + x |= c & 0x7f + if not c & 0x80: + break ++ if i > max_pow: ++ raise BER_Decoding_Error("BER_num_dec: maximum value reached (2^32-1)", ++ remaining=s) + if c & 0x80: + raise BER_Decoding_Error("BER_num_dec: unfinished number description", + remaining=s) +@@ -338,7 +343,8 @@ class BERcodec_Object(Generic[_K], metaclass=BERcodec_metaclass): + def do_dec(cls, + s, # type: bytes + context=None, # type: Optional[Type[ASN1_Class]] +- safe=False # type: bool ++ safe=False, # type: bool ++ _depth=0, # type: int + ): + # type: (...) -> Tuple[ASN1_Object[Any], bytes] + if context is not None: +@@ -360,22 +366,28 @@ class BERcodec_Object(Generic[_K], metaclass=BERcodec_metaclass): + # Value type defined as Unknown + l, s = BER_num_dec(remainder) + return ASN1_BADTAG(s[:l]), s[l:] +- return codec.dec(s, _context, safe) ++ return codec.dec(s, _context, safe, _depth=_depth) + + @classmethod + def dec(cls, + s, # type: bytes + context=None, # type: Optional[Type[ASN1_Class]] + safe=False, # type: bool ++ _depth=0, # type: int + ): + # type: (...) -> Tuple[Union[_ASN1_ERROR, ASN1_Object[_K]], bytes] ++ if _depth > MAX_BER_DEPTH: ++ raise BER_Exception("Reached maximum BER recursion limit") + if not safe: +- return cls.do_dec(s, context, safe) ++ return cls.do_dec(s, context, safe, _depth=_depth) + try: +- return cls.do_dec(s, context, safe) ++ return cls.do_dec(s, context, safe, _depth=_depth) + except BER_BadTag_Decoding_Error as e: + o, remain = BERcodec_Object.dec( +- e.remaining, context, safe ++ e.remaining, ++ context=context, ++ safe=safe, ++ _depth=_depth + 1, + ) # type: Tuple[ASN1_Object[Any], bytes] + return ASN1_BADTAG(o), remain + except BER_Decoding_Error as e: +@@ -387,9 +399,10 @@ class BERcodec_Object(Generic[_K], metaclass=BERcodec_metaclass): + def safedec(cls, + s, # type: bytes + context=None, # type: Optional[Type[ASN1_Class]] ++ _depth=0, # type: int + ): + # type: (...) -> Tuple[Union[_ASN1_ERROR, ASN1_Object[_K]], bytes] +- return cls.dec(s, context, safe=True) ++ return cls.dec(s, context, safe=True, _depth=_depth) + + @classmethod + def enc(cls, s, size_len=0): +@@ -437,6 +450,7 @@ class BERcodec_INTEGER(BERcodec_Object[int]): + s, # type: bytes + context=None, # type: Optional[Type[ASN1_Class]] + safe=False, # type: bool ++ _depth=0, # type: int + ): + # type: (...) -> Tuple[ASN1_Object[int], bytes] + l, s, t = cls.check_type_check_len(s) +@@ -461,7 +475,8 @@ class BERcodec_BIT_STRING(BERcodec_Object[str]): + def do_dec(cls, + s, # type: bytes + context=None, # type: Optional[Type[ASN1_Class]] +- safe=False # type: bool ++ safe=False, # type: bool ++ _depth=0, # type: int + ): + # type: (...) -> Tuple[ASN1_Object[str], bytes] + # /!\ the unused_bits information is lost after this decoding +@@ -515,6 +530,7 @@ class BERcodec_STRING(BERcodec_Object[str]): + s, # type: bytes + context=None, # type: Optional[Type[ASN1_Class]] + safe=False, # type: bool ++ _depth=0, # type: int + ): + # type: (...) -> Tuple[ASN1_Object[Any], bytes] + l, s, t = cls.check_type_check_len(s) +@@ -555,6 +571,7 @@ class BERcodec_OID(BERcodec_Object[bytes]): + s, # type: bytes + context=None, # type: Optional[Type[ASN1_Class]] + safe=False, # type: bool ++ _depth=0, # type: int + ): + # type: (...) -> Tuple[ASN1_Object[bytes], bytes] + l, s, t = cls.check_type_check_len(s) +@@ -562,7 +579,8 @@ class BERcodec_OID(BERcodec_Object[bytes]): + while s: + l, s = BER_num_dec(s) + lst.append(l) +- if (len(lst) > 0): ++ if lst: ++ # X.690 sect 8.19.4 + lst.insert(0, lst[0] // 40) + lst[1] %= 40 + return ( +@@ -639,18 +657,24 @@ class BERcodec_SEQUENCE(BERcodec_Object[Union[bytes, List[BERcodec_Object[Any]]] + def do_dec(cls, + s, # type: bytes + context=None, # type: Optional[Type[ASN1_Class]] +- safe=False # type: bool ++ safe=False, # type: bool ++ _depth=0, # type: int + ): + # type: (...) -> Tuple[ASN1_Object[Union[bytes, List[Any]]], bytes] + if context is None: + context = cls.tag.context ++ if _depth > MAX_BER_DEPTH: ++ raise BER_Exception("Reached maximum BER recursion limit") + ll, st = cls.check_type_get_len(s) # we may have len(s) < ll + s, t = st[:ll], st[ll:] + obj = [] + while s: + try: + o, remain = BERcodec_Object.dec( +- s, context, safe ++ s, ++ context=context, ++ safe=safe, ++ _depth=_depth + 1, + ) # type: Tuple[ASN1_Object[Any], bytes] + s = remain + except BER_Decoding_Error as err: +@@ -683,8 +707,13 @@ class BERcodec_IPADDRESS(BERcodec_STRING): + return chb(int(cls.tag)) + BER_len_enc(len(s), size=size_len) + s + + @classmethod +- def do_dec(cls, s, context=None, safe=False): +- # type: (bytes, Optional[Any], bool) -> Tuple[ASN1_Object[str], bytes] ++ def do_dec(cls, ++ s, # type: bytes ++ context=None, # type: Optional[Any] ++ safe=False, # type: bool ++ _depth=0, # type: int ++ ): ++ # type: (...) -> Tuple[ASN1_Object[str], bytes] + l, s, t = cls.check_type_check_len(s) + try: + ipaddr_ascii = inet_ntoa(s) +diff --git a/test/regression.uts b/test/regression.uts +index 9b53fa36..67cd2870 100644 +--- a/test/regression.uts ++++ b/test/regression.uts +@@ -4150,16 +4150,21 @@ r1 == b'@\x04\x08\x08\x08\x08' + r2 = b.dec(r1)[0] + r2.val == '8.8.8.8' + +-a = b'\x1f\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\x01\x01\x00C\x02\x01U0\x0f0\r\x06\x08+\x06\x01\x02\x01\x02\x01\x00\x02\x01!' +-ret = False ++a = b'\x1f\xfe\xfe\xfe\xfe\xfe\x01\x01\x00C\x02\x01U0\x0f0\r\x06\x08+\x06\x01\x02\x01\x02\x01\x00\x02\x01!' + try: + BERcodec_Object.check_type(a) +-except BER_BadTag_Decoding_Error: +- ret = True ++except BER_BadTag_Decoding_Error as ex: ++ assert "Got tag" in str(ex) + else: +- ret = False ++ assert False + +-assert ret ++a = b'\x1f\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\xfe\x01\x01\x00C\x02\x01U0\x0f0\r\x06\x08+\x06\x01\x02\x01\x02\x01\x00\x02\x01!' ++try: ++ BERcodec_Object.check_type(a) ++except BER_Decoding_Error as ex: ++ assert "maximum value" in str(ex) ++else: ++ assert False + + = BER trigger failures + +@@ -4170,6 +4175,17 @@ except BER_Decoding_Error: + pass + + ++= BER tests - 2 ++ ++a = b'0c\x02\x01\x01\x04\x06public\xa2V\x02\x01\x01\x02\x01\x00\x02\x01\x000K0I\x06\x03+\x06\x010B0@0>0<0:08060402000.0,0*0(0&0$0"0 0\x1e0\x1c0\x1a0\x180\x160\x140\x120\x100\x0e0\x0c0\n0\x080\x060\x040\x020\x00' ++try: ++ SNMP(a) ++except BER_Exception as ex: ++ assert "recursion limit" in str(ex) ++else: ++ assert False ++ ++ + ############ + ############ + + Fields
meta-networking/recipes-devtools/python/python3-scapy_2.6.1.bb +1 -0
@@ -19,6 +19,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=b234ee4d69f5fce4486a80fdaf4a4263" SRCREV = "8e08cbf759de6709a5b4af6bea3655d293129bb4" SRC_URI = "git://github.com/secdev/scapy.git;branch=master;protocol=https;tag=v${PV} \ file://0001-python3-scapy-skip-ICMP-regression-tests-in-ptest.patch \ + file://CVE-2026-128237_CVE-2026-128238.patch \ file://run-ptest" UPSTREAM_CHECK_COMMITS = "1"
Signature · 1 line
2.35.6
PATCH 2/2 python3-scapy: fix CVE-2025-71463
From: Ashishkumar Parmar <[email protected]>
This patch applies the upstream backport for CVE-2025-71463 to the current version. The upstream fix merge or commit is referenced in [1], and the public CVE advisory is referenced in [2]. The individual backported commit links are recorded in the embedded patch headers when the fix expands to multiple commits.
This patch also removes stale session persistence examples and obsolete man-page limitations. The introduction cleanup is taken from [3].
[1] https://github.com/secdev/scapy/commit/13621d1145b3435e9d03caf20997107a84435c0b
[2] https://github.com/secdev/scapy/security/advisories/GHSA-cq46-m9x9-j8w2
[3] https://github.com/secdev/scapy/commit/5376fcc86aaba7c516fb4aa19576b03b387d217a
--- .../python/python3-scapy/CVE-2025-71463.patch | 468 ++++++++++++++++++ .../python/python3-scapy_2.6.1.bb | 1 + 2 files changed, 469 insertions(+) create mode 100644 meta-networking/recipes-devtools/python/python3-scapy/CVE-2025-71463.patch
meta-networking/recipes-devtools/python/python3-scapy/CVE-2025-71463.patch new file +468 -0
@@ -0,0 +1,468 @@ +From 8df000ba71082f90902ef8f971b0ca1f881edf17 Mon Sep 17 00:00:00 2001 +From: Guillaume Valadon <[email protected]> +Date: Wed, 1 Oct 2025 21:58:56 +0200 +Subject: [PATCH] Sessions removed + +CVE: CVE-2025-71463 +Upstream-Status: Backport [https://github.com/secdev/scapy/commit/13621d1145b3435e9d03caf20997107a84435c0b] + +Backport Changes: +- The removed temporary-file test uses the current version's + AppVeyor-specific Windows path assertion instead of the newer upstream + assertion. +- Include only the introduction documentation cleanup from upstream + https://github.com/secdev/scapy/commit/5376fcc86aaba7c516fb4aa19576b03b387d217a + to remove obsolete session save/reload examples. Its unrelated autorun + and session bookkeeping changes are omitted. +- Remove the obsolete session-saving limitation from doc/scapy.1 because + session persistence is removed by this fix. + +Signed-off-by: Ashishkumar Parmar <[email protected]> +--- + doc/scapy.1 | 12 +-- + doc/scapy/introduction.rst | 14 +--- + doc/scapy/usage.rst | 18 ---- + scapy/main.py | 166 ++----------------------------------- + test/regression.uts | 67 +-------------- + 5 files changed, 11 insertions(+), 266 deletions(-) + +diff --git a/doc/scapy.1 b/doc/scapy.1 +index 395871a8..1e8d6d4f 100644 +--- a/doc/scapy.1 ++++ b/doc/scapy.1 +@@ -17,10 +17,7 @@ arping, tcpdump, tshark, p0f, ... + .PP + \fBScapy\fP uses the Python interpreter as a command board. That means that + you can use directly Python language (assign variables, use loops, +-define functions, etc.) If you give a file a parameter when you run +-\fBScapy\fP, your session (variables, functions, instances, ...) will be saved +-when you leave the interpreter and restored the next time you launch +-\fBScapy\fP. ++define functions, etc.) + .PP + The idea is simple. Those kinds of tools do two things : sending packets + and receiving answers. That's what \fBScapy\fP does : you define a set of +@@ -48,9 +45,6 @@ header-less mode, also reduces verbosity. + \fB\-d\fR + increase log verbosity. Can be used many times. + .TP +-\fB\-s\fR FILE +-use FILE to save/load session values (variables, functions, instances, ...) +-.TP + \fB\-p\fR PRESTART_FILE + use PRESTART_FILE instead of $HOME/.config/scapy/prestart.py as pre-startup file + .TP +@@ -194,10 +188,6 @@ Does not give the right source IP for routes that use interface aliases. + + May miss packets under heavy load. This is a restriction from python itself + +-Session saving is limited by Python ability to marshal objects. As a +-consequence, lambda functions and generators can't be saved, which seriously +-reduce the usefulness of this feature. +- + BPF filters don't work on Point-to-point interfaces. + + +diff --git a/doc/scapy/introduction.rst b/doc/scapy/introduction.rst +index ab8b97cf..b308755c 100644 +--- a/doc/scapy/introduction.rst ++++ b/doc/scapy/introduction.rst +@@ -62,10 +62,9 @@ Interpreting results can help users that don't know what a port scan is, but it + Quick demo + ========== + +-First, we play a bit and create four IP packets at once. Let's see how it works. We first instantiate the IP class. Then, we instantiate it again and we provide a destination that is worth four IP addresses (/30 gives the netmask). Using a Python idiom, we develop this implicit packet in a set of explicit packets. Then, we quit the interpreter. As we provided a session file, the variables we were working on are saved, then reloaded:: ++First, we play a bit and create four IP packets at once. Let's see how it works. We first instantiate the IP class. Then, we instantiate it again and we provide a destination that is worth four IP addresses (/30 gives the netmask). Using a Python idiom, we develop this implicit packet in a set of explicit packets:: + +- # ./run_scapy -s mysession +- New session [mysession] ++ # ./run_scapy + Welcome to Scapy (2.4.0) + >>> IP() + <IP |> +@@ -76,15 +75,6 @@ First, we play a bit and create four IP packets at once. Let's see how it works. + >>> [p for p in ip] + [<IP dst=207.171.175.28 |>, <IP dst=207.171.175.29 |>, + <IP dst=207.171.175.30 |>, <IP dst=207.171.175.31 |>] +- >>> ^D +- +-:: +- +- # ./run_scapy -s mysession +- Using session [mysession] +- Welcome to Scapy (2.4.0) +- >>> ip +- <IP dst=<Net www.target.com/30> |> + + Now, let's manipulate some packets:: + +diff --git a/doc/scapy/usage.rst b/doc/scapy/usage.rst +index a32792db..990aa5f4 100644 +--- a/doc/scapy/usage.rst ++++ b/doc/scapy/usage.rst +@@ -1019,24 +1019,6 @@ The output above can be reimported back into Scapy using ``import_object()``:: + \x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f + !"#$%&\'()*+,-./01234567' |>>>> + +-Sessions +-^^^^^^^^ +- +-At last Scapy is capable of saving all session variables using the ``save_session()`` function: +- +->>> dir() +-['__builtins__', 'conf', 'new_pkt', 'pkt', 'pkt_export', 'pkt_hex', 'pkt_raw', 'pkts'] +->>> save_session("session.scapy") +- +-Next time you start Scapy you can load the previous saved session using the ``load_session()`` command:: +- +- >>> dir() +- ['__builtins__', 'conf'] +- >>> load_session("session.scapy") +- >>> dir() +- ['__builtins__', 'conf', 'new_pkt', 'pkt', 'pkt_export', 'pkt_hex', 'pkt_raw', 'pkts'] +- +- + Making tables + ------------- + +diff --git a/scapy/main.py b/scapy/main.py +index c5ad0c74..c7ef726b 100644 +--- a/scapy/main.py ++++ b/scapy/main.py +@@ -14,14 +14,11 @@ import sys + import os + import getopt + import code +-import gzip + import glob + import importlib + import io + from itertools import zip_longest + import logging +-import pickle +-import types + import warnings + from random import choice + +@@ -230,7 +227,7 @@ conf.color_theme = DefaultTheme() + def _usage(): + # type: () -> None + print( +- "Usage: scapy.py [-s sessionfile] [-c new_startup_file] " ++ "Usage: scapy.py [-c new_startup_file] " + "[-p new_prestart_file] [-C] [-P] [-H]\n" + "Args:\n" + "\t-H: header-less start\n" +@@ -439,116 +436,8 @@ def _scapy_exts(): + return res + + +-def save_session(fname="", session=None, pickleProto=-1): +- # type: (str, Optional[Dict[str, Any]], int) -> None +- """Save current Scapy session to the file specified in the fname arg. +- +- params: +- - fname: file to save the scapy session in +- - session: scapy session to use. If None, the console one will be used +- - pickleProto: pickle proto version (default: -1 = latest)""" +- from scapy import utils +- from scapy.config import conf, ConfClass +- if not fname: +- fname = conf.session +- if not fname: +- conf.session = fname = utils.get_temp_file(keep=True) +- log_interactive.info("Saving session into [%s]", fname) +- +- if not session: +- if conf.interactive_shell in ["ipython", "ptipython"]: +- from IPython import get_ipython +- session = get_ipython().user_ns +- else: +- session = builtins.__dict__["scapy_session"] +- +- if not session: +- log_interactive.error("No session found ?!") +- return +- +- ignore = session.get("_scpybuiltins", []) +- hard_ignore = ["scapy_session", "In", "Out", "open"] +- to_be_saved = session.copy() +- +- for k in list(to_be_saved): +- i = to_be_saved[k] +- if k[0] == "_": +- del to_be_saved[k] +- elif hasattr(i, "__module__") and i.__module__.startswith("IPython"): +- del to_be_saved[k] +- elif isinstance(i, ConfClass): +- del to_be_saved[k] +- elif k in ignore or k in hard_ignore: +- del to_be_saved[k] +- elif isinstance(i, (type, types.ModuleType, types.FunctionType)): +- if k[0] != "_": +- log_interactive.warning("[%s] (%s) can't be saved.", k, type(i)) +- del to_be_saved[k] +- else: +- try: +- pickle.dumps(i) +- except Exception: +- log_interactive.warning("[%s] (%s) can't be saved.", k, type(i)) +- +- try: +- os.rename(fname, fname + ".bak") +- except OSError: +- pass +- +- f = gzip.open(fname, "wb") +- pickle.dump(to_be_saved, f, pickleProto) +- f.close() +- +- +-def load_session(fname=None): +- # type: (Optional[Union[str, None]]) -> None +- """Load current Scapy session from the file specified in the fname arg. +- This will erase any existing session. +- +- params: +- - fname: file to load the scapy session from""" +- from scapy.config import conf +- if fname is None: +- fname = conf.session +- try: +- s = pickle.load(gzip.open(fname, "rb")) +- except IOError: +- try: +- s = pickle.load(open(fname, "rb")) +- except IOError: +- # Raise "No such file exception" +- raise +- +- scapy_session = builtins.__dict__["scapy_session"] +- s.update({k: scapy_session[k] for k in scapy_session["_scpybuiltins"]}) +- scapy_session.clear() +- scapy_session.update(s) +- update_ipython_session(scapy_session) +- +- log_loading.info("Loaded session [%s]", fname) +- +- +-def update_session(fname=None): +- # type: (Optional[Union[str, None]]) -> None +- """Update current Scapy session from the file specified in the fname arg. +- +- params: +- - fname: file to load the scapy session from""" +- from scapy.config import conf +- if fname is None: +- fname = conf.session +- try: +- s = pickle.load(gzip.open(fname, "rb")) +- except IOError: +- s = pickle.load(open(fname, "rb")) +- scapy_session = builtins.__dict__["scapy_session"] +- scapy_session.update(s) +- update_ipython_session(scapy_session) +- +- + @overload +-def init_session(session_name, # type: Optional[Union[str, None]] +- mydict, # type: Optional[Union[Dict[str, Any], None]] ++def init_session(mydict, # type: Optional[Union[Dict[str, Any], None]] + ret, # type: Literal[True] + ): + # type: (...) -> Dict[str, Any] +@@ -556,21 +445,18 @@ def init_session(session_name, # type: Optional[Union[str, None]] + + + @overload +-def init_session(session_name, # type: Optional[Union[str, None]] +- mydict=None, # type: Optional[Union[Dict[str, Any], None]] ++def init_session(mydict=None, # type: Optional[Union[Dict[str, Any], None]] + ret=False, # type: Literal[False] + ): + # type: (...) -> None + pass + + +-def init_session(session_name, # type: Optional[Union[str, None]] +- mydict=None, # type: Optional[Union[Dict[str, Any], None]] ++def init_session(mydict=None, # type: Optional[Union[Dict[str, Any], None]] + ret=False, # type: bool + ): + # type: (...) -> Union[Dict[str, Any], None] + from scapy.config import conf +- SESSION = {} # type: Optional[Dict[str, Any]] + + # Load Scapy + scapy_builtins = _scapy_builtins() +@@ -578,39 +464,7 @@ def init_session(session_name, # type: Optional[Union[str, None]] + # Load exts + scapy_builtins.update(_scapy_exts()) + +- if session_name: +- try: +- os.stat(session_name) +- except OSError: +- log_loading.info("New session [%s]", session_name) +- else: +- try: +- try: +- SESSION = pickle.load(gzip.open(session_name, "rb")) +- except IOError: +- SESSION = pickle.load(open(session_name, "rb")) +- log_loading.info("Using existing session [%s]", session_name) +- except ValueError: +- msg = "Error opening Python3 pickled session on Python2 [%s]" +- log_loading.error(msg, session_name) +- except EOFError: +- log_loading.error("Error opening session [%s]", session_name) +- except AttributeError: +- log_loading.error("Error opening session [%s]. " +- "Attribute missing", session_name) +- +- if SESSION: +- if "conf" in SESSION: +- conf.configure(SESSION["conf"]) +- conf.session = session_name +- SESSION["conf"] = conf +- else: +- conf.session = session_name +- else: +- conf.session = session_name +- SESSION = {"conf": conf} +- else: +- SESSION = {"conf": conf} ++ SESSION = {"conf": conf} # type: Dict[str, Any] + + SESSION.update(scapy_builtins) + SESSION["_scpybuiltins"] = scapy_builtins.keys() +@@ -623,6 +477,7 @@ def init_session(session_name, # type: Optional[Union[str, None]] + return SESSION + return None + ++ + ################ + # Main # + ################ +@@ -751,8 +606,6 @@ def interact(mydict=None, argv=None, mybanner=None, loglevel=logging.INFO): + STARTUP_FILE = DEFAULT_STARTUP_FILE + PRESTART_FILE = DEFAULT_PRESTART_FILE + +- session_name = None +- + if argv is None: + argv = sys.argv + +@@ -765,8 +618,6 @@ def interact(mydict=None, argv=None, mybanner=None, loglevel=logging.INFO): + conf.fancy_banner = False + conf.verb = 1 + conf.logLevel = logging.WARNING +- elif opt == "-s": +- session_name = param + elif opt == "-c": + STARTUP_FILE = param + elif opt == "-C": +@@ -798,7 +649,7 @@ def interact(mydict=None, argv=None, mybanner=None, loglevel=logging.INFO): + default=DEFAULT_PRESTART, + ) + +- SESSION = init_session(session_name, mydict=mydict, ret=True) ++ SESSION = init_session(mydict=mydict, ret=True) + + if STARTUP_FILE: + _read_config_file( +@@ -1018,9 +869,6 @@ def interact(mydict=None, argv=None, mybanner=None, loglevel=logging.INFO): + else: + raise ValueError("Invalid conf.interactive_shell") + +- if conf.session: +- save_session(conf.session, SESSION) +- + + if __name__ == "__main__": + interact() +diff --git a/test/regression.uts b/test/regression.uts +index 67cd2870..ea01eb2d 100644 +--- a/test/regression.uts ++++ b/test/regression.uts +@@ -622,72 +622,6 @@ try: + except SystemExit: + assert True + +-= Session test +- +-import builtins +- +-# This is automatic when using the console +-def get_var(var): +- return builtins.__dict__["scapy_session"][var] +- +-def set_var(var, value): +- builtins.__dict__["scapy_session"][var] = value +- +-def del_var(var): +- del builtins.__dict__["scapy_session"][var] +- +-init_session(None, {"init_value": 123}) +-set_var("test_value", "8.8.8.8") # test_value = "8.8.8.8" +-save_session() +-del_var("test_value") +-load_session() +-update_session() +-assert get_var("test_value") == "8.8.8.8" #test_value == "8.8.8.8" +-assert get_var("init_value") == 123 +- +-= Session test with fname +- +-session_name = tempfile.mktemp() +-init_session(session_name) +-set_var("test_value", IP(dst="192.168.0.1")) # test_value = IP(dst="192.168.0.1") +-save_session(fname="%s.dat" % session_name) +-del_var("test_value") +- +-set_var("z", True) #z = True +-load_session(fname="%s.dat" % session_name) +-try: +- get_var("z") +- assert False +-except: +- pass +- +-set_var("z", False) #z = False +-update_session(fname="%s.dat" % session_name) +-assert get_var("test_value").dst == "192.168.0.1" #test_value.dst == "192.168.0.1" +-assert not get_var("z") +- +-= Clear session files +- +-os.remove("%s.dat" % session_name) +- +-= Test temporary file creation +-~ ci_only +- +-scapy_delete_temp_files() +- +-tmpfile = get_temp_file(autoext=".ut") +-tmpfile +-if WINDOWS: +- assert "scapy" in tmpfile and tmpfile.lower().startswith('c:\\users\\appveyor\\appdata\\local\\temp') +-else: +- import platform +- BYPASS_TMP = platform.python_implementation().lower() == "pypy" or DARWIN +- assert "scapy" in tmpfile and (BYPASS_TMP == True or "/tmp/" in tmpfile) +- +-assert conf.temp_files[0].endswith(".ut") +-scapy_delete_temp_files() +-assert len(conf.temp_files) == 0 +- + = Emulate interact() + ~ interact + +@@ -2186,6 +2120,7 @@ p.show() + + = Variable creations + from io import BytesIO ++import base64 + pcapfile = BytesIO(b'\xd4\xc3\xb2\xa1\x02\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00e\x00\x00\x00\xcf\xc5\xacVo*\n\x00(\x00\x00\x00(\x00\x00\x00E\x00\x00(\x00\x01\x00\x00@\x06|\xcd\x7f\x00\x00\x01\x7f\x00\x00\x01\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00\x91|\x00\x00\xcf\xc5\xacV_-\n\x00\x1c\x00\x00\x00\x1c\x00\x00\x00E\x00\x00\x1c\x00\x01\x00\x00@\x11|\xce\x7f\x00\x00\x01\x7f\x00\x00\x01\x005\x005\x00\x08\x01r\xcf\xc5\xacV\xf90\n\x00\x1c\x00\x00\x00\x1c\x00\x00\x00E\x00\x00\x1c\x00\x01\x00\x00@\x01|\xde\x7f\x00\x00\x01\x7f\x00\x00\x01\x08\x00\xf7\xff\x00\x00\x00\x00') + pcapngfile = BytesIO(b'\n\r\r\n\\\x00\x00\x00M<+\x1a\x01\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x01\x00,\x00File created by merging: \nFile1: test.pcap \n\x04\x00\x08\x00mergecap\x00\x00\x00\x00\\\x00\x00\x00\x01\x00\x00\x00\\\x00\x00\x00e\x00\x00\x00\xff\xff\x00\x00\x02\x006\x00Unknown/not available in original file format(libpcap)\x00\x00\t\x00\x01\x00\x06\x00\x00\x00\x00\x00\x00\x00\\\x00\x00\x00\x06\x00\x00\x00H\x00\x00\x00\x00\x00\x00\x00\x8d*\x05\x00/\xfc[\xcd(\x00\x00\x00(\x00\x00\x00E\x00\x00(\x00\x01\x00\x00@\x06|\xcd\x7f\x00\x00\x01\x7f\x00\x00\x01\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00\x91|\x00\x00H\x00\x00\x00\x06\x00\x00\x00<\x00\x00\x00\x00\x00\x00\x00\x8d*\x05\x00\x1f\xff[\xcd\x1c\x00\x00\x00\x1c\x00\x00\x00E\x00\x00\x1c\x00\x01\x00\x00@\x11|\xce\x7f\x00\x00\x01\x7f\x00\x00\x01\x005\x005\x00\x08\x01r<\x00\x00\x00\x06\x00\x00\x00<\x00\x00\x00\x00\x00\x00\x00\x8d*\x05\x00\xb9\x02\\\xcd\x1c\x00\x00\x00\x1c\x00\x00\x00E\x00\x00\x1c\x00\x01\x00\x00@\x01|\xde\x7f\x00\x00\x01\x7f\x00\x00\x01\x08\x00\xf7\xff\x00\x00\x00\x00<\x00\x00\x00') + pcapnanofile = BytesIO(b"M<\xb2\xa1\x02\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00e\x00\x00\x00\xcf\xc5\xacV\xc9\xc1\xb5'(\x00\x00\x00(\x00\x00\x00E\x00\x00(\x00\x01\x00\x00@\x06|\xcd\x7f\x00\x00\x01\x7f\x00\x00\x01\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x02 \x00\x91|\x00\x00\xcf\xc5\xacV-;\xc1'\x1c\x00\x00\x00\x1c\x00\x00\x00E\x00\x00\x1c\x00\x01\x00\x00@\x11|\xce\x7f\x00\x00\x01\x7f\x00\x00\x01\x005\x005\x00\x08\x01r\xcf\xc5\xacV\x9aL\xcf'\x1c\x00\x00\x00\x1c\x00\x00\x00E\x00\x00\x1c\x00\x01\x00\x00@\x01|\xde\x7f\x00\x00\x01\x7f\x00\x00\x01\x08\x00\xf7\xff\x00\x00\x00\x00")
meta-networking/recipes-devtools/python/python3-scapy_2.6.1.bb +1 -0
@@ -20,6 +20,7 @@ SRCREV = "8e08cbf759de6709a5b4af6bea3655d293129bb4" SRC_URI = "git://github.com/secdev/scapy.git;branch=master;protocol=https;tag=v${PV} \ file://0001-python3-scapy-skip-ICMP-regression-tests-in-ptest.patch \ file://CVE-2026-128237_CVE-2026-128238.patch \ + file://CVE-2025-71463.patch \ file://run-ptest" UPSTREAM_CHECK_COMMITS = "1"
Signature · 1 line
2.35.6