Executive Summary & Direct Answer

RUSTSEC-2026-0482 describes a critical sandbox escape in cap-primitives: a trailing slash could make the final path component behave as an intermediate component, bypassing the resolver’s O_NOFOLLOW protection. An in-sandbox symlink such as escape -> ../outside could therefore expose paths outside the sandbox. Upgrade to cap-primitives 3.4.6 or 4.0.3 or later, and ensure dependent crates resolve to a patched version. Removing trailing slashes from input is not a fix: a symlink’s own target can end in /.

The bug affects fallback path-resolution code on several platforms and can expose both read and write operations. Treat it as a dependency-level security update, then test the exact symlink-and-trailing-slash case on the platforms and configurations where your application uses capability-based filesystem access.

Environment and affected configurations

This guide covers Rust applications using cap-primitives directly or through crates built on it, including cap-std. The advisory also identifies Wasmtime’s WASI filesystem support as affected; Wasmtime’s issue is tracked separately as RUSTSEC-2026-0269.

Use Rust 1.82+ (Edition 2021) for the examples below. The vulnerability is in path resolution, not in a Rust compiler version. The advisory’s patched versions are:

  • cap-primitives 3.4.6 or later within the 3.x line
  • cap-primitives 4.0.3 or later within the 4.x line

RUSTSEC-2026-0482, also identified as GHSA-hp8f-xmx4-4qrg, assigns the issue CVSS 3.1 score 9.0 Critical. The resolver is used on Windows and macOS, on FreeBSD when O_RESOLVE_BENEATH is unavailable, and on Linux when openat2 is unavailable—for example, on kernels before 5.6—or rejected by a seccomp policy. Do not assume a Linux deployment is protected just because it usually runs on a recent kernel.

The vulnerable mechanism

A capability filesystem library aims to make filesystem operations relative to a directory capability, rather than allowing arbitrary ambient paths. A resolver can walk the path one component at a time and use O_NOFOLLOW when opening the final component. That protection is intended to prevent a final symlink from redirecting the operation outside the sandbox.

The defect was in how cap-primitives handled a trailing slash. Its resolver re-added / to the last component before opening it. But a pathname ending in / requires the operating system to treat the preceding component as a directory, effectively making it non-final for symlink-following purposes. As a result, O_NOFOLLOW no longer protected that component. The resolver could follow the symlink and return the resulting file descriptor without the required containment check.

For example, if a sandbox contains escape -> ../outside, opening escape/ could follow the link outside the sandbox. The same issue can arise without a slash in the caller’s input: if the symlink target itself ends in /, the operating system’s path handling can still defeat a strategy that only strips trailing slashes from user-provided paths.

This is a filesystem-resolution bug, not a path-string validation bug. A check such as “reject paths ending in /” does not address symlink targets, nor does it replace descriptor-relative resolution and containment enforcement.

Naive workaround versus production fix

A tempting workaround is to normalize the input:

// Not a security boundary.
let path = user_path.trim_end_matches('/');

This is insufficient. It only edits the caller’s string; it does not control how the operating system resolves a symlink target. It can also change path semantics, such as how a directory is requested, without proving the resulting operation remains within the capability root.

The production fix is to update the vulnerable resolver. The advisory says the fix stops re-adding the trailing slash. Prefer upgrading the crate that owns the resolver and every affected dependency that brings it into your application. Do not copy a local string-normalization patch and consider the issue closed.

For a direct dependency, pin a patched compatible release:

[dependencies]
cap-primitives = "4.0.3"

If your application uses cap-std, update that dependency to a release whose resolved dependency graph includes a patched cap-primitives. Confirm the actual resolution rather than assuming a top-level version change was sufficient:

cargo tree -i cap-primitives
cargo update
cargo tree -i cap-primitives

For a workspace or deployment that must preserve a dependency graph, inspect and record the lockfile change. If an upstream crate constrains cap-primitives to an affected release, update that upstream crate or apply a reviewed, temporary patch that contains the actual resolver fix. A Cargo override is not itself a fix unless the source being substituted is patched and the resulting graph is verified.

What operations to audit

The advisory reports that the flaw can affect more than file reads. Depending on the API and path involved, exposure includes:

  • open, open_dir, read_dir, and canonicalize
  • create_dir, remove_dir, and rename

Audit code that accepts untrusted relative paths and performs any of these operations through cap-std, cap-primitives, or a dependent library. Include WASI filesystem integrations in the review where applicable. A safe-looking operation such as “only list a directory” can still disclose outside information if the resolver returns a descriptor reached through the escaped symlink.

Keep the capability boundary explicit: construct access from the intended root directory and use capability-relative operations. This design reduces ambient authority, but it does not compensate for a vulnerable resolver underneath it. For complementary file-name and upload validation concerns, see Hardening Rust File Upload Endpoints Against Path Traversal and Filename Abuse. If filesystem paths originate in configuration, also consider the parsing boundary discussed in Preventing Unsafe YAML Deserialization in Rust: Parsing Configuration Files Securely.

Regression test for the vulnerable shape

Add a test that creates a sandbox, places a symlink inside it pointing outside, and attempts to open the link with a trailing slash. On Unix, the following illustrates the security assertion using cap_std APIs; adapt setup and error handling to your application’s version and platform support.

#[cfg(unix)]
#[test]
fn symlink_with_trailing_slash_cannot_escape_capability_root() {
    use cap_std::ambient_authority;
    use cap_std::fs::Dir;
    use std::os::unix::fs::symlink;
    use tempfile::tempdir;

    let sandbox = tempdir().unwrap();
    let outside = tempdir().unwrap();

    std::fs::write(outside.path().join("secret.txt"), b"outside").unwrap();

    let sandbox_dir =
        Dir::open_ambient_dir(sandbox.path(), ambient_authority()).unwrap();

    symlink(outside.path(), sandbox.path().join("escape")).unwrap();

    // The security property is rejection: this path must not expose
    // the outside directory through the capability.
    assert!(sandbox_dir.open_dir("escape/").is_err());
}

This is a regression test, not a substitute for upgrading. The exact result can depend on platform APIs and library versions; the required property is that the operation does not succeed in granting access outside the capability root. Add corresponding tests for the operations your application relies on, especially where directories can be created, removed, renamed, or enumerated.

Use a separate test case for a symlink target that itself ends in /, if the platform and test setup preserve that target form. This guards against the incorrect assumption that normalizing only the caller-supplied path is sufficient. Run the test on every supported OS and on Linux configurations that exercise fallback behavior; a successful test on a host using openat2 does not prove that the fallback resolver is safe.

Quantitative trade-offs and verification

The advisory describes two patched release lines and platform-dependent resolution paths; it does not publish performance benchmarks. The table therefore reports concrete version and security differences, not invented timing or gas-style measurements.

ApproachVersion or configurationTrailing-slash symlink boundaryOperational trade-off
Vulnerable resolvercap-primitives before 3.4.6 in 3.x or before 4.0.3 in 4.xCan follow a symlink outside the sandbox when the slash defeats final-component O_NOFOLLOWNo safe workaround from input trimming alone
Patched resolver3.4.6+ or 4.0.3+Fix stops re-adding the trailing slash; use the patched dependencyRequires dependency update and regression testing
Linux openat2 pathKernel 5.6+ when available and permittedResolver may use kernel containment mechanisms instead of the affected fallbackAvailability is environment-dependent; seccomp can force fallback
Linux fallback pathOlder kernel or openat2 rejectedMust be covered by the patched fallback implementationTest under the actual deployment restrictions

Run the following checks in CI and release validation:

cargo tree -i cap-primitives
cargo test
cargo clippy --all-targets --all-features -- -D warnings
cargo audit

cargo audit should report no applicable vulnerable cap-primitives release after the update. Keep the generated lockfile and dependency tree in review so transitive upgrades are visible. Run platform-specific tests in CI rather than treating one Linux result as proof for Windows, macOS, or FreeBSD.

When Linux production uses seccomp, test with the same policy that can reject openat2; otherwise, CI may exercise a different resolution path from production. For robust differential verification, run the symlink regression test in at least two environments: one where openat2 is available and permitted, and one where it is unavailable or blocked. The expected security result must remain the same: no operation may return access to a target outside the sandbox. Run cargo test against both the patched dependency graph and any supported platform targets, and verify the resolved version with cargo tree -i cap-primitives in each build.

Production pitfalls

Do not rely on trimming input. A symlink target may carry the trailing slash, and string normalization does not establish containment.

Do not assume a modern Linux kernel guarantees the safe path. A seccomp policy can reject openat2, causing the library to use fallback resolution. Kernel version and policy are part of the security environment.

Audit transitive users. Applications may not name cap-primitives directly. cap-std and other crates built on the primitive layer can inherit its behavior. Check the dependency tree and the advisory database.

Test more than open. The advisory lists directory enumeration, canonicalization, creation, removal, and rename operations. Test the operations relevant to your application’s threat model, particularly those that can disclose or modify outside state.

Keep the test meaningful. A test that only checks that a path string was normalized does not test the vulnerable boundary. Construct an actual symlink and assert that the capability operation cannot access its outside target.

Frequently Asked Questions (FAQ)

Which cap-primitives versions fix RUSTSEC-2026-0482?

The advisory lists cap-primitives 3.4.6 or later for the 3.x line and 4.0.3 or later for the 4.x line. Verify the resolved version with cargo tree -i cap-primitives, especially when the crate is included transitively.

Does removing a trailing slash prevent the cap-primitives sandbox escape?

No. The symlink target itself can end in /, so the caller’s path does not need one. The root cause is how the vulnerable resolver re-added a slash before opening the final component, not just acceptance of user input with a trailing slash.

Is Linux openat2 enough to avoid RUSTSEC-2026-0482?

Do not rely on its availability as a complete mitigation. The resolver uses fallback code on kernels before 5.6 or when seccomp rejects openat2, and other listed platforms also use fallback resolution. Upgrade to a patched release and test the fallback path used by your deployments.

Learn more with useful resources