# GHSA-cf4g-fcf8-3cr9: `pnet_packet` buffer overrun in `set_payload` setters

> A buffer overrun in the pnet_packet library allows attackers to cause memory corruption, potentially leading to code execution or denial of service.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 19 Jun 2020
- **Also known as:** RUSTSEC-2020-0167

## What is GHSA-cf4g-fcf8-3cr9?

GHSA-cf4g-fcf8-3cr9 is a memory corruption vulnerability in pnet_packet, published on 19 Jun 2020. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

As indicated by this [issue](https://github.com/libpnet/libpnet/issues/449#issuecomment-663355987), a buffer overrun is possible in the `set_payload` setter of the various mutable "Packet" struct setters. The offending `set_payload` functions were defined within the struct `impl` blocks in earlier versions of the package, and later by the `packet` macro.

Fixed in the `packet` macro by [this](https://github.com/libpnet/libpnet/pull/455) PR.

## Which versions are affected by GHSA-cf4g-fcf8-3cr9?

3 open source packages ship an affected version, including pnet_packet.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `pnet_packet` | crates.io | All versions | 0.27.2 |
| `pnet_packet` | crates.io | All versions | 0.27.2 |
| `pnet_packet` | crates.io | From 0.0.0-0 | 0.27.2 |

## How do I fix GHSA-cf4g-fcf8-3cr9?

Upgrade pnet_packet to 0.27.2 or later.

## Is GHSA-cf4g-fcf8-3cr9 being exploited?

There is no known exploitation of GHSA-cf4g-fcf8-3cr9 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-cf4g-fcf8-3cr9 and fix it if it is affected.

What it is: GHSA-cf4g-fcf8-3cr9 is a memory corruption vulnerability in pnet_packet, published on 19 Jun 2020. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-cf4g-fcf8-3cr9 in the wild and no public exploit code.

Affected packages and fixed versions:
- pnet_packet (crates.io): affected all versions; fixed in 0.27.2
- pnet_packet (crates.io): affected all versions; fixed in 0.27.2
- pnet_packet (crates.io): affected from 0.0.0-0; fixed in 0.27.2

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-cf4g-fcf8-3cr9/ (Markdown: https://insights.sbomify.com/GHSA-cf4g-fcf8-3cr9/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-cf4g-fcf8-3cr9

---
From sbomify Insights: https://insights.sbomify.com/GHSA-cf4g-fcf8-3cr9/
Summaries are generated and may contain mistakes; the official description above is the record.
