Subject
zerocopy is a Rust library, maintained by Google, that provides safe, zero-cost primitives for treating arbitrary bytes as typed values and vice versa. Its public API centres on six unsafe-but-safely-derivable traits — FromBytes, IntoBytes, Unaligned, Immutable, KnownLayout, and TryFromBytes — together with the smart-pointer types Ref<B, T> and Ptr<'a, T, I> (the latter tracking aliasing, alignment, and validity invariants in its type parameter I), free functions for value/reference transmutation (transmute, try_transmute, transmute_ref, transmute_mut, plus the try_ variants), zero-copy parsing helpers (ref_from_bytes, ref_from_prefix, ref_from_suffix, read_from_*), and the byte-order-tagged integer wrappers U16<E>/U32<E>/U64<E>. Optional features pull in the zerocopy-derive proc-macro crate (derive), enable the alloc/std allocator-dependent API surface, and turn on SIMD-type trait impls for x86, x86_64, AArch64, and PowerPC.
Methodology
The published crate contents were compared against the upstream Git repository at the commit recorded in .cargo_vcs_info.json using diff -rq; the src/ and tests/ trees match byte-for-byte. find and wc -l were used to size the codebase (~28K LOC across 24 Rust files under src/; tests/ adds further files). grep enumerated the capability surface: std::net, std::fs, std::process, std::sync (atomics, Mutex), std::thread — none appear in the runtime source other than doc examples; Command::new appears only in build.rs; env::var_os appears only in build.rs. grep -c produced raw counts of the unsafe token (~1249 occurrences) and SAFETY: markers (~696). #[cfg(kani)] blocks were enumerated by grep — seven proof modules in src/byte_slice.rs, src/byteorder.rs, src/layout.rs, and src/util/mod.rs. The crate's documented soundness policy in POLICIES.md and the lint posture at src/lib.rs:220-287 were read. The build.rs file was read in full and its capability surface analysed. An Explore sub-agent was dispatched to produce a survey-level capability map; its findings were spot-checked against the source by re-grepping for the cited identifiers (impl_or_verify!, test_is_bit_valid_shared, FIXME(#429), FIXME(#899)). The code was not built or executed locally and a full soundness review of the unsafe surface was not undertaken; see FINDING-3 for the explicit scope statement.
Results
The published crate matches its upstream Git tree byte-for-byte in src/ and tests/. The differences are confined to cargo-generated metadata (.cargo_vcs_info.json, Cargo.lock, Cargo.toml.orig, normalised Cargo.toml), upstream-only repo plumbing (.github/, .gemini/, .cargo/), and the upstream sibling crates / workspace members (zerocopy-derive, anneal, hermes, testutil, tools, vendor) which are excluded from the published crate. There are no binary artefacts in the published crate (justifying has-binaries) and no install hooks (justifying has-install-exec).
A build.rs is present (justifying has-build-exec). Its capability surface is small and entirely documented in FINDING-4: it reads Cargo.toml from the source tree, invokes rustc --version via Command::new using the cargo-provided RUSTC environment variable, and emits cargo:rustc-cfg=no_zerocopy_*_X_Y_Z directives gating MSRV-sensitive features (core::error::Error impls, AVX-512 SIMD types, AArch64 SIMD, target_has_atomics, generic bounds in const fn, panic-in-const-fn). No filesystem writes occur outside cargo's directed output, no network access takes place, and the rustc invocation uses argv form with no shell interpolation. Justifies uses-environment, environment-safe, uses-filesystem, filesystem-safe, uses-exec, exec-safe, build-exec-safe, build-exec-deterministic, build-exec-no-network, build-exec-no-write-out, and build-exec-minimal.
The runtime crate makes no network calls (justifying uses-network), no cryptographic operations (justifying uses-crypto, impl-crypto), no JIT (justifying uses-jit, impl-jit), no embedded interpreter (justifying uses-interpreter, impl-interpreter), no concurrency primitives (justifying uses-concurrency, impl-concurrency), no protocol or data-structure or general-purpose-algorithm implementation in the senses the audit taxonomy uses those terms (justifying impl-protocol, impl-datastructure, impl-algorithm), and no parser in the data-format-or-language sense (justifying impl-parser — the byte-to-typed-value conversion the crate implements is transmutation, not parsing). The atomic-type trait impls in src/impls.rs are guarded behind cfg(target_has_atomics = ...) predicates and add no concurrency surface to zerocopy itself; the doc-example uses of std::thread::spawn and std::fs::File in src/error.rs and src/lib.rs appear inside /// comment blocks and are not compiled into the library.
The crate contains a large volume of unsafe code (justifying uses-unsafe) — ~1249 token occurrences across ~28K LOC, the bulk of which is the central trait machinery in src/util/, the layout reasoning in src/layout.rs, the pointer-with-invariants type in src/pointer/, the per-type trait impls in src/impls.rs, the wrappers in src/wrappers.rs, and the byte-slice operations in src/byte_slice.rs and src/split_at.rs. Each is the explicit purpose of the crate: zerocopy exists so that its consumers do not have to write the unsafe code themselves. Unsafe discipline is enforced by #![deny(unsafe_op_in_unsafe_fn)], #![deny(clippy::undocumented_unsafe_blocks)], #![deny(clippy::missing_safety_doc)], and #![deny(clippy::multiple_unsafe_ops_per_block)] at src/lib.rs:220-287, with a documented soundness policy in POLICIES.md requiring every SAFETY: comment to constitute an informal proof citing the Rust Reference or stdlib documentation and to hold under every Rust version from the MSRV forward. Five #[cfg(kani)] modules (src/byte_slice.rs, src/byteorder.rs, src/layout.rs, src/util/mod.rs) hold formal-verification proofs for the layout-arithmetic, byte-slice, and byteorder code paths; the tests/ directory carries codegen.rs, include.rs, and ui.rs integration suites (justifying has-integration-tests) and many in-tree #[test] modules (justifying has-unit-tests, unsafe-tested). No QuickCheck/proptest-style property tests are present (justifying has-property-tests) and no libfuzzer / cargo-fuzz harnesses ship with the published crate (justifying has-fuzz-tests — upstream Git does not appear to ship a fuzz/ workspace member for this crate at this commit either). The unsafe is minimal in the sense that each block has a defined purpose tied to the crate's transmutation contract (justifying unsafe-minimal), and the documentation discipline that supports unsafe-documented is the lint-enforced clippy::undocumented_unsafe_blocks plus the ~696 explicit SAFETY: markers.
Four low-severity findings were recorded. FINDING-1 documents a small, isolated, author-acknowledged unsoundness in test-only code: the impl_or_verify! macro in src/impls.rs (lines 1796 and 1807) constructs a Ptr via assume_initialized even though the inner type is not statically known to be IntoBytes. The flaw is confined to test-time differential verification of trait impls, is tracked under upstream issue #899, and is not reachable from any non-test API. FINDING-2 records the small population of pre-existing uncommented unsafe blocks tracked under upstream issue #429 — a documentation-hygiene gap, not a soundness defect, with the linter preventing regression. FINDING-3 is an explicit scope statement: a complete soundness audit of zerocopy's unsafe surface was not performed here, and the unsafe-safe assertion rests on the upstream project's review process, lint posture, Kani proofs, and ecosystem deployment rather than on an end-to-end proof performed in this audit. FINDING-4 documents the build script's capability surface (file reads in source tree, rustc --version invocation, cargo cfg emission) and supports the build-exec audit claims.
The crate carries no malicious calls — no telemetry, no data exfiltration, no obfuscated payloads, no targeted cfg branches (the per-arch cfg(target_arch = ...) blocks gate SIMD trait impls only). Supports is-benign.
Conclusion
zerocopy 0.8.50 is a large, well-documented, Google-maintained crate whose explicit purpose is to provide a safe surface over Rust transmutation. The published crate matches upstream Git byte-for-byte. The capability surface outside unsafe is small and well-bounded: a build script that reads Cargo.toml and invokes rustc --version for MSRV-conscious cfg gating, no network, no filesystem outside the build script, no exec outside the build script, no cryptographic operations, no parser/interpreter/JIT. The unsafe surface is large by design and is governed by a documented soundness policy, lint-enforced safety comments, Kani proofs on the core layout/pointer machinery, and an extensive in-tree and integration test suite. The audit recorded one isolated test-only unsoundness (FINDING-1, upstream-tracked as #899), an outstanding documentation-coverage gap (FINDING-2, upstream-tracked as #429), an explicit scope statement (FINDING-3), and a documented build-time capability note (FINDING-4). The crate's claim that it lets its users avoid writing unsafe rests on the soundness of its internal unsafe; the discipline visible from a survey-level review is consistent with that claim, but consumers with strict soundness requirements should rely on Kani, Miri, or an independent expert audit rather than treating this OpenVet review as proof.