alexcrichton opened PR #14219 from alexcrichton:vendor-cap-primitives to bytecodealliance:main:
This PR is a series of commits which vendors the
cap-primitivescrate, or what Wasmtime needs, within thewasmtime-wasicrate. This is done as an acknowledgement of the current maintenance and state of the cap-std repository and project where having a security-critical dependency external of Wasmtime itself is becoming more and more of a burden. This was discussed in today's Wasmtime meeting and had unanimous agreement about this transition. The Bytecode Alliance TSC will, I believe, ask if anyone would like to end up maintaining the cap-std crates in parallel to this but our decision was that regardless of that outcome it's still best to vendor the code here within Wasmtime itself.This PR is structured as a sequential list of commits which tell a story of sorts of how this was vendored. This is a very large change so the intention is to be as methodical and "obviously correct" as possible. The
cap-primitivescrate contains quite a bit of functionality which Wasmtime doesn't need and can thus be deleted. Additionally the tests forcap-primitivesare all written against thecap-stdlayer which has a differently-shaped API surface area. To that end the major adjustments from cap-primitives are:
- Only the
fs,rustix, andwindowssubmodules are vendored here.- All dead code and dead #[cfg]-related code has been deleted.
- Tests were copied verbatim from cap-std, and then adjusted/deleted as necessary. Due to the scale of the change this step was primarily done with LLM assistance and manual review.
- A minor debug-only bug was fixed for me to run tests locally.
- All dependencies of
cap-primitives, added towasmtime-wasi, were subsequently removed as they were pretty light dependencies.The end result is intended to be a source-wise pretty much line-for-line vendor of cap-primitives. The tests are spiritually all ported over but greatly differ at the source level due to API differences. This PR is intended to be proactively backported to supported release branches of Wasmtime to avoid the need to patch external code should future security issues arise with the
wasi:filesystemimplementation. This includes Wasmtime 36, 47, and 48. To this end the switch-over here was audited to ensure that the public API of thewasmtime-wasicrate does not change as a result of this commit and is thus semver-compatible to backport. This means that there's a single remaining vestigal use of thecap-primitivescrate to simply reexport theSystemTimeSpectype at the root of thewasmtime-wasicrate. This isn't actually used anywhere, though, so the only purpose is its reexport. This reexport will be deleted onmainafter this PR, but will not be deleted in backports.The backport situation for Wasmtime 36 and 47 is going to be more complicated because they do not contain https://github.com/bytecodealliance/wasmtime/pull/13872. Despite that I think we'll still be able to basically pull it off, but I've not yet proven this out.
alexcrichton requested pchickey for a review on PR #14219.
alexcrichton requested wasmtime-wasi-reviewers for a review on PR #14219.
alexcrichton requested fitzgen for a review on PR #14219.
alexcrichton requested wasmtime-default-reviewers for a review on PR #14219.
fitzgen unassigned fitzgen from PR #14219 Vendor the cap-primitives crate within the wasmtime-wasi crate.
alexcrichton updated PR #14219.
alexcrichton updated PR #14219.
alexcrichton updated PR #14219.
alexcrichton updated PR #14219.
alexcrichton updated PR #14219.
alexcrichton updated PR #14219.
github-actions[bot] added the label wasi on PR #14219.
alexcrichton updated PR #14219.
alexcrichton commented on PR #14219:
Ok I've completed backports:
- https://github.com/bytecodealliance/wasmtime/pull/14224
- https://github.com/bytecodealliance/wasmtime/pull/14225
I've opted to skip 47.0.x since it's more complicated than the 48.0.x backport and different from the 36.0.x backport. Basically I'm gambling that we're not going to discover a new security vulnerability in cap-std in the next month. If we do, then I'll need to end up doing the work for the backport anyway.
:thumbs_up: pchickey submitted PR review:
Not a review of cap-primitives itself but of the vendoring
Last updated: Aug 30 2026 at 09:07 UTC