# GHSA-r24f-hg58-vfrw: unsafe-libyaml unaligned write of u64 on 32-bit and 16-bit platforms

> An attacker can cause a crash in unsafe-libyaml on 32-bit or 16-bit platforms due to unaligned memory writes, leading to denial of service.

- **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:** 20 Dec 2023
- **Also known as:** RUSTSEC-2023-0075

## What is GHSA-r24f-hg58-vfrw?

GHSA-r24f-hg58-vfrw is a memory corruption vulnerability in unsafe-libyaml, published on 20 Dec 2023. 

### Official description

Affected versions allocate memory using the alignment of `usize` and write data to it of type `u64`, without using `core::ptr::write_unaligned`. In platforms with sub-64bit alignment for `usize` (including wasm32 and x86) these writes are insufficiently aligned some of the time.

If using an ordinary optimized standard library, the bug exhibits Undefined Behavior so may or may not behave in any sensible way, depending on optimization settings and hardware and other things. If using a Rust standard library built with debug assertions enabled, the bug manifests deterministically in a crash (non-unwinding panic) saying _"ptr::write requires that the pointer argument is aligned and non-null"_.

No 64-bit platform is impacted by the bug.

The flaw was corrected by allocating with adequately high alignment on all
platforms.

## Which versions are affected by GHSA-r24f-hg58-vfrw?

3 open source packages ship an affected version, including unsafe-libyaml.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `unsafe-libyaml` | crates.io | All versions | 0.2.10 |
| `unsafe-libyaml` | crates.io | All versions | 0.2.10 |
| `unsafe-libyaml` | crates.io | From 0.0.0-0 | 0.2.10 |

## How do I fix GHSA-r24f-hg58-vfrw?

Upgrade unsafe-libyaml to 0.2.10 or later.

## Is GHSA-r24f-hg58-vfrw being exploited?

There is no known exploitation of GHSA-r24f-hg58-vfrw in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-r24f-hg58-vfrw and fix it if it is affected.

What it is: GHSA-r24f-hg58-vfrw is a memory corruption vulnerability in unsafe-libyaml, published on 20 Dec 2023. 
Exploitation: There is no known exploitation of GHSA-r24f-hg58-vfrw in the wild and no public exploit code.

Affected packages and fixed versions:
- unsafe-libyaml (crates.io): affected all versions; fixed in 0.2.10
- unsafe-libyaml (crates.io): affected all versions; fixed in 0.2.10
- unsafe-libyaml (crates.io): affected from 0.0.0-0; fixed in 0.2.10

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-r24f-hg58-vfrw/ (Markdown: https://insights.sbomify.com/GHSA-r24f-hg58-vfrw/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-r24f-hg58-vfrw

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