GHSA-cq46-m9x9-j8w2: Scapy Scapy Session Loading Vulnerable To Vulnerability
MODERATEGHSA-cq46-m9x9-j8w2 is a MODERATE scapy session loading vulnerable to vulnerability (CWE-502: Deserialization of Untrusted Data) affecting Scapy libraries in the PyPI ecosystem. The issue involves scapy session loading vulnerable to arbitrary code execution via untrusted pickle deserialization. Remediation is available in the latest vendor maintenance releases.
GHSA-cq46-m9x9-j8w2 at a Glance
How to Fix GHSA-cq46-m9x9-j8w2
To remediate this vulnerability, upgrade all affected Scapy dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install scapy>=Latest secure release
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show scapy
How to Check if You Are Affected
To determine whether your Python environment is affected by GHSA-cq46-m9x9-j8w2, inspect your installed packages using pip:
pip show scapy
Analyze the terminal output to locate any version of Scapy in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than the patched release), your application is affected.
Note: The pip show scapy command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-502: Deserialization of Untrusted Data, where the product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid. In Scapy, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
GHSA-cq46-m9x9-j8w2 Affected Scapy Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
scapy
|
PyPI |
≤ 2.6.1
|
|
References
Frequently Asked Questions
What is GHSA-cq46-m9x9-j8w2?
Which Scapy versions are affected?
What version fixes GHSA-cq46-m9x9-j8w2?
Is scapy affected?
What CWE is associated with GHSA-cq46-m9x9-j8w2?
How can I check PyPI dependencies for GHSA-cq46-m9x9-j8w2?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-cq46-m9x9-j8w2",
"modified" : "2025-10-23T20:10:45Z",
"published" : "2025-10-22T16:45:49Z",
"aliases" : [ ],
"summary" : "Scapy Session Loading Vulnerable to Arbitrary Code Execution via Untrusted Pickle Deserialization",
"details" : "### Summary\n\nAn 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.\n\n---\n\n### Details\n\nScapy’s interactive shell supports session loading using gzip-compressed pickle files:\n\n```bash\n./run_scapy -s <session_file.pkl.gz>\n```\n\nInternally, this triggers:\n\n```python\n# main.py\nSESSION = pickle.load(gzip.open(session_name, \"rb\"))\n```\n\nSince 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.\n\nThe 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`.\n\n**Affected lines in source code**:\nhttps://github.com/secdev/scapy/blob/master/scapy/main.py#L569-L572\n\n```python\ntry:\n s = pickle.load(gzip.open(fname, \"rb\"))\nexcept IOError:\n try:\n s = pickle.load(open(fname, \"rb\"))\n```\n\n### Impact\n\nThis is a classic deserialization vulnerability which leads to Code Execution (CE) when untrusted data is deserialized.\n\nAny user who can trick another user into loading a crafted `.pkl.gz` session file (e.g. via `-s` option) can execute arbitrary Python code.\n\n- **Vulnerability type:** Insecure deserialization (Python `pickle`)\n- **CWE**: [CWE-502: Deserialization of Untrusted Data](https://cwe.mitre.org/data/definitions/502.html)\n- **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`\n- **CVSS Score**: 5.4 (Medium)\n- **Impact:** Arbitrary Code Execution\n- **Attack vector:** Local or supply chain (malicious `.pkl.gz`)\n- **Affected users:** Any user who loads session files (even interactively)\n- **Affected version:** **Scapy v2.6.1**\n\n---\n\n### Mitigations\n\n- Do not use 'sessions' (the -s option when launching Scapy).\n- Use the Scapy 2.7.0+ where the session mechanism has been removed.",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "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"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "scapy"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"last_affected" : "2.6.1"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/secdev/scapy/security/advisories/GHSA-cq46-m9x9-j8w2"
}, {
"type" : "WEB",
"url" : "https://github.com/secdev/scapy/commit/13621d1145b3435e9d03caf20997107a84435c0b"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/secdev/scapy"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-502" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2025-10-22T16:45:49Z",
"nvd_published_at" : null
}
}