Medium

Scapy Session Loading Vulnerable to Arbitrary Code Execution via Untrusted Pickle Deserialization

  • Disclosed: 22.10.2025
  • Updated: 11.10.2026 12:19

Summary

An unsafe deserialization vulnerability in Scapy <v2.7.0 allows attackers to execute arbitrary code when a malicious session file is locally loaded via the -s option. This requires convincing a user to manually load a malicious session file.


Details

Scapy’s interactive shell supports session loading using gzip-compressed pickle files:

bash
./run_scapy -s <session_file.pkl.gz>

Internally, this triggers:

python
# main.py
SESSION = pickle.load(gzip.open(session_name, "rb"))

Since no validation or restriction is performed on the deserialized object, any code embedded via __reduce__() will be executed immediately. This makes it trivial for an attacker to drop a malicious .pkl.gz in a shared folder and have it executed by unsuspecting users.

The vulnerability exists in the load_session function, which deserializes data using pickle.load() on .pkl.gz files provided via the -s CLI flag or programmatically through conf.session.

Affected lines in source code: https://github.com/secdev/scapy/blob/master/scapy/main.py#L569-L572

python
try:
    s = pickle.load(gzip.open(fname, "rb"))
except IOError:
    try:
        s = pickle.load(open(fname, "rb"))

Impact

This is a classic deserialization vulnerability which leads to Code Execution (CE) when untrusted data is deserialized.

Any user who can trick another user into loading a crafted .pkl.gz session file (e.g. via -s option) can execute arbitrary Python code.

  • Vulnerability type: Insecure deserialization (Python pickle)
  • CWE: CWE-502: Deserialization of Untrusted Data
  • CVSS v4.0 Vector: CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:A/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
  • CVSS Score: 5.4 (Medium)
  • Impact: Arbitrary Code Execution
  • Attack vector: Local or supply chain (malicious .pkl.gz)
  • Affected users: Any user who loads session files (even interactively)
  • Affected version: Scapy v2.6.1

Mitigations

  • Do not use 'sessions' (the -s option when launching Scapy).
  • Use the Scapy 2.7.0+ where the session mechanism has been removed.

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
Python (PyPI) scapy <= 2.6.1 no fix

References

CVSS score -
CVSS vector
CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:A/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
Weakness (CWE)
CWE-502
Platform
Python (PyPI)
Package
scapy
Disclosed
22.10.2025
Updated
11.10.2026 12:19

Sources and licenses

OSV / GitHub Advisory Database - GHSA-cq46-m9x9-j8w2 - CC BY 4.0

Vulnerability history: scapy

All published vulnerabilities of this package (Python (PyPI)), newest first. Shows whether this is a one-off slip or a package that needs watching.

Total entries
2
First → latest
07.2019 10.2025
Without a fix
1
Exploited in attacks
0

Severity breakdown

  • High 1
  • Medium 1

Disclosures per year

  1. 2019: 1
  2. 2020: 0
  3. 2021: 0
  4. 2022: 0
  5. 2023: 0
  6. 2024: 0
  7. 2025: 1
  8. 2026: 0
  1. Scapy Session Loading Vulnerable to Arbitrary Code Execution via Untrusted Pickle Deserialization this entry
    Medium ghsa-cq46-m9x9-j8w2 <= 2.6.1 no fix
  2. High · 7.5 CVE-2019-1010142 >= 2.4-rc1, < 2.4.1 2.4.1

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.