# GHSA-w5w5-8vfh-xcjq: whoami stack buffer overflow on several Unix platforms

> A stack buffer overflow in the whoami Rust crate allows attackers to cause denial of service or potentially execute code on Unix platforms.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Not stated
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 28 Feb 2024
- **Also known as:** RUSTSEC-2024-0020

## What is GHSA-w5w5-8vfh-xcjq?

GHSA-w5w5-8vfh-xcjq is a memory corruption vulnerability in whoami, published on 28 Feb 2024. 

### Official description

With versions of the whoami crate >= 0.5.3 and < 1.5.0, calling any of these functions leads to an immediate stack buffer overflow on illumos and Solaris:

- `whoami::username`
- `whoami::realname`
- `whoami::username_os`
- `whoami::realname_os`

With versions of the whoami crate >= 0.5.3 and < 1.0.1, calling any of the above functions also leads to a stack buffer overflow on these platforms:

- Bitrig
- DragonFlyBSD
- FreeBSD
- NetBSD
- OpenBSD

This occurs because of an incorrect definition of the `passwd` struct on those platforms.

As a result of this issue, denial of service and data corruption have both been observed in the wild. The issue is possibly exploitable as well.

This vulnerability also affects other Unix platforms that aren't Linux or macOS.

This issue has been addressed in whoami 1.5.0.

For more information, see [this GitHub issue](https://github.com/ardaku/whoami/issues/91).

## Which versions are affected by GHSA-w5w5-8vfh-xcjq?

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


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `whoami` | crates.io | From 0.5.3 | 1.5.0 |
| `whoami` | crates.io | From 0.5.3 | 1.5.0 |
| `whoami` | crates.io | From 0.5.3 | 1.5.0 |

## How do I fix GHSA-w5w5-8vfh-xcjq?

Upgrade whoami to 1.5.0 or later.

## Is GHSA-w5w5-8vfh-xcjq being exploited?

There is no known exploitation of GHSA-w5w5-8vfh-xcjq in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-w5w5-8vfh-xcjq and fix it if it is affected.

What it is: GHSA-w5w5-8vfh-xcjq is a memory corruption vulnerability in whoami, published on 28 Feb 2024. 
Exploitation: There is no known exploitation of GHSA-w5w5-8vfh-xcjq in the wild and no public exploit code.

Affected packages and fixed versions:
- whoami (crates.io): affected from 0.5.3; fixed in 1.5.0
- whoami (crates.io): affected from 0.5.3; fixed in 1.5.0
- whoami (crates.io): affected from 0.5.3; fixed in 1.5.0

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-w5w5-8vfh-xcjq/ (Markdown: https://insights.sbomify.com/GHSA-w5w5-8vfh-xcjq/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-w5w5-8vfh-xcjq

---
From sbomify Insights: https://insights.sbomify.com/GHSA-w5w5-8vfh-xcjq/
Summaries are generated and may contain mistakes; the official description above is the record.
