# GHSA-wfg4-322g-9vqv: memoffset allows reading uninitialized memory

- Severity: Medium (rating, scored by GitHub)
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Published: 2023-06-21T12:00:00.000Z
- Modified: 2023-11-08T04:23:47.381Z
- Also known as: RUSTSEC-2023-0045

## Description

memoffset allows attempt of reading data from address `0` with arbitrary type. This behavior is an undefined behavior because address `0` to `std::mem::size_of<T>` may not have valid bit-pattern with `T`. Old implementation dereferences uninitialized memory obtained from `std::mem::align_of`. Older implementation prior to it allows using uninitialized data obtained from `std::mem::uninitialized` with arbitrary type then compute offset by taking the address of field-projection. This may also result in an undefined behavior for "father" that includes (directly or transitively) type that [does not allow to be uninitialized](https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html).

This flaw was corrected by using `std::ptr::addr_of` in <https://github.com/Gilnaa/memoffset/pull/50>.

(As written by GitHub Advisory Database.)

## Affected

- memoffset (crates.io): before 0.6.2; from 0.0.0-0 before 0.6.2

## References

- <https://github.com/Gilnaa/memoffset/issues/24> (report, web)
- <https://github.com/Gilnaa/memoffset/pull/50> (web)
- <https://github.com/Gilnaa/memoffset> (package)
- <https://rustsec.org/advisories/RUSTSEC-2023-0045.html> (advisory, web)
- <https://crates.io/crates/memoffset> (package)

## Sources

- GitHub Advisory Database: [GHSA-wfg4-322g-9vqv](https://github.com/advisories/GHSA-wfg4-322g-9vqv), CC-BY-4.0, modified 2023-11-08
- RustSec Advisory Database: [RUSTSEC-2023-0045](https://rustsec.org/advisories/RUSTSEC-2023-0045.html), CC0-1.0, modified 2023-11-08

---

Page: https://cve.day/GHSA-wfg4-322g-9vqv · Whole record: https://cve.day/GHSA-wfg4-322g-9vqv.json · Rebuilt by cve.day 2026-11-25T22:56:43.150Z
