# GHSA-cq46-m9x9-j8w2: Scapy Session Loading Vulnerable to Arbitrary Code Execution via Untrusted Pickle Deserialization

> Attackers can execute arbitrary code by tricking users into loading malicious Scapy session files via unsafe pickle deserialization.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** No
- **Published:** 22 Oct 2025

## What is GHSA-cq46-m9x9-j8w2?

GHSA-cq46-m9x9-j8w2 is an unsafe deserialization vulnerability in scapy, published on 22 Oct 2025. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

### Official description

### 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](https://cwe.mitre.org/data/definitions/502.html)
- **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.

## Which versions are affected by GHSA-cq46-m9x9-j8w2?

2 open source packages ship an affected version, including scapy.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `scapy` | PyPI | All versions to 2.6.1 | None |
| `scapy` | PyPI | All versions to 2.6.1 | None |

## How do I fix GHSA-cq46-m9x9-j8w2?

No fix has been published for GHSA-cq46-m9x9-j8w2 yet. Limit exposure of the affected software until one is available.

## Is GHSA-cq46-m9x9-j8w2 being exploited?

There is no known exploitation of GHSA-cq46-m9x9-j8w2 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-cq46-m9x9-j8w2 and fix it if it is affected.

What it is: GHSA-cq46-m9x9-j8w2 is an unsafe deserialization vulnerability in scapy, published on 22 Oct 2025. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of GHSA-cq46-m9x9-j8w2 in the wild and no public exploit code.

Affected packages and fixed versions:
- scapy (PyPI): affected all versions up to 2.6.1; no fix listed
- scapy (PyPI): affected all versions up to 2.6.1; no fix listed

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-cq46-m9x9-j8w2/ (Markdown: https://insights.sbomify.com/GHSA-cq46-m9x9-j8w2/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-cq46-m9x9-j8w2

---
From sbomify Insights: https://insights.sbomify.com/GHSA-cq46-m9x9-j8w2/
Summaries are generated and may contain mistakes; the official description above is the record.
