# GHSA-gv7f-5qqh-vxfx: xous has unsound usages of `core::slice::from_raw_parts`

> Unsound pointer casting in xous library allows memory corruption, potentially leading to code execution or crashes.

- **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:** 23 Dec 2024
- **Also known as:** RUSTSEC-2024-0431

## What is GHSA-gv7f-5qqh-vxfx?

GHSA-gv7f-5qqh-vxfx is a memory corruption vulnerability in xous, published on 23 Dec 2024. 

### Official description

We consider `as_slice` and `as_slice_mut` unsound because: the pointer with any bit patterns could be cast to the slice of arbitrary types. The pointer could be created by unsafe new and deprecated `from_parts`. We consider that `from_parts` should be removed in latest version because it will help trigger unsoundness in `as_slice`. With new declared as unsafe, `as_slice` should also declared as unsafe.  

This was patched in by marking two functions as `unsafe`.

## Which versions are affected by GHSA-gv7f-5qqh-vxfx?

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


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

## How do I fix GHSA-gv7f-5qqh-vxfx?

Upgrade xous to 0.9.51 or later.

## Is GHSA-gv7f-5qqh-vxfx being exploited?

There is no known exploitation of GHSA-gv7f-5qqh-vxfx in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-gv7f-5qqh-vxfx and fix it if it is affected.

What it is: GHSA-gv7f-5qqh-vxfx is a memory corruption vulnerability in xous, published on 23 Dec 2024. 
Exploitation: There is no known exploitation of GHSA-gv7f-5qqh-vxfx in the wild and no public exploit code.

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

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-gv7f-5qqh-vxfx/ (Markdown: https://insights.sbomify.com/GHSA-gv7f-5qqh-vxfx/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-gv7f-5qqh-vxfx

---
From sbomify Insights: https://insights.sbomify.com/GHSA-gv7f-5qqh-vxfx/
Summaries are generated and may contain mistakes; the official description above is the record.
