Skip to content

fix(fire_vmm): harden Firecracker binary/kernel staging and the API transport - #171

Merged
markovejnovic merged 12 commits into
mainfrom
fix/firecracker-trust-and-transport
Nov 16, 2026
Merged

markovejnovic merged 12 commits into
mainfrom
fix/firecracker-trust-and-transport

Conversation

@markovejnovic

@markovejnovic markovejnovic commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

No description provided.

@codecov

codecov Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.27799% with 20 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
lib/hyper/firecracker/api/transport.ex 83.69% 15 Missing ⚠️
lib/hyper/node/vmlinux.ex 83.33% 1 Missing ⚠️
lib/redist/targz.ex 91.66% 1 Missing ⚠️
native/hyperrs-fs/src/dir.rs 92.85% 1 Missing ⚠️
native/hyperrs-process/src/binary.rs 97.43% 1 Missing ⚠️
native/suidhelper/src/config.rs 87.50% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Test Results

    4 files  ± 0    346 suites  +10   4m 34s ⏱️ +36s
1 634 tests +41  1 634 ✅ +41    0 💤 ± 0  0 ❌ ±0 
2 267 runs  +51  1 634 ✅ +41  633 💤 +10  0 ❌ ±0 

Results for commit c570bd5. ± Comparison against base commit a9da789.

This pull request removes 3 and adds 44 tests. Note that renamed tests count towards both.
hyperrs-process ‑ binary::tests::rejects_relative_path_or_wrong_basename::case_1_bare_name
hyperrs-process ‑ binary::tests::rejects_relative_path_or_wrong_basename::case_2_dot_relative
hyperrs-process ‑ binary::tests::rejects_relative_path_or_wrong_basename::case_3_wrong_basename
Elixir.Hyper.Firecracker.Api.TransportCapPropertiesTest ‑ property a reply is refused exactly when its body exceeds 1 MiB, under every framing and status
Elixir.Hyper.Firecracker.Api.TransportCapPropertiesTest ‑ test a drip-fed reply is cut off before Client.run/2's call timeout
Elixir.Hyper.Firecracker.Api.TransportCapPropertiesTest ‑ test a lying content-length is refused once the cap is crossed, not after the advertised length
Elixir.Hyper.Firecracker.Api.TransportCapPropertiesTest ‑ test a typed reply that is not a JSON object is never {:ok, non-struct}
Elixir.Hyper.Firecracker.Api.TransportCapPropertiesTest ‑ test after a refused reply on a kept-alive connection the next request reads its own reply
Elixir.Hyper.Firecracker.Api.TransportCapPropertiesTest ‑ test an endless chunked stream is refused rather than read forever
Elixir.Hyper.Firecracker.Api.TransportHostileHeadersTest ‑ test a header block past the cap is not a successful call, however it is shaped
Elixir.Hyper.Node.VmlinuxTest ‑ test a symlink is judged by its target, as the helper judges it
Elixir.Hyper.Node.VmlinuxTest ‑ test refuses exactly what the helper refuses
Elixir.Redist.TargzSymlinkChainTest ‑ test a symlink chain out of dest_dir is refused promptly and writes nothing outside
…

♻️ This comment has been updated with latest results.

@markovejnovic
markovejnovic marked this pull request as ready for review November 15, 2026 22:30
@markovejnovic
markovejnovic force-pushed the fix/firecracker-trust-and-transport branch from 6b88ee9 to 386f20e Compare November 16, 2026 02:56
… stage set-id

KernelImage::open opened the source O_RDONLY before checking its type, so a
FIFO with no writer hung the helper. Vet it through an O_PATH fd first, then
reopen for reading.

A set-id root-owned source was hard-linked into the jail as root, handing the
jail a set-id inode protected_hardlinks would refuse; such a source is now
always copied at KERNEL_MODE.
… rewrite

The jailer is handed Firecracker by path and canonicalizes and copies it
itself, so vetting the file alone left a window: whoever can write a parent
directory could rename another file over the vetted path. RootSafeBinPathBuf
now also requires every directory above the binary to be root-owned and not
group/other-writable (sticky directories excepted), checked from / down.

The provisioning script and firecracker.install's printed steps chown the
install directory to root accordingly.
Req/Mint buffered response headers without limit and reset receive_timeout
on every chunk, so a compromised Firecracker could make the node buffer
unbounded headers or hold a call past Client.run/2's 35 s cap. The transport
now speaks HTTP/1.1 over the socket itself: 8 KiB per head line, at most 100
headers or trailers, the 1 MiB body cap, and one 30 s deadline for the call.

A typed 2xx reply that is not a JSON object is {:error, {:unexpected_body, _}}
instead of {:ok, raw}, which crashed AwaitingApi.
The helper canonicalizes the kernel path before vetting it, but the boot check
lstat-ed the link itself and refused every symlinked kernel the first launch
would have accepted.
A chain of individually in-tree symlinks (s -> ., t -> s/..) followed by an
entry through it spun :erl_tar.extract/2 forever. The pinned Firecracker
releases ship no symlinks, so any symlink entry is refused up front.
…t root

Stage set-id kernels as the caller too, pin that a plain kernel is
hard-linked on one filesystem, and prove RootSafeBinPathBuf passes / and
sticky /tmp and refuses at the first caller-owned parent. Exclude the
equivalent disjoint-bit `|` -> `^` mutants and the `|` -> `&` one only a
root-owned writable parent can tell apart.
Replace the lstat-based root_only_writable validator with an openat descent
from `/` through SafeFile<IsDirectory, RootOwner, StickyOrOwnerOnlyWritable>,
so each parent is checked on the fd the next lookup resolves from. Fold
ParentStat/UnsafeParent into Parent { source: file::ValidationError }.
Kills the three surviving check mutants (Ok(()), & -> |, & -> ^) by
opening real directories at each mode as the unprivileged caller.
…once

- RootSafeBin{,PathBuf}::open take &SafePath<IsAbsolute, StrictComponents>;
  [tools] paths deserialize as SafePathBuf, so a loose path fails at config
  load. Drops the strict(), required() and default_work_dir() helpers and the
  safe_path deserializer.
- The parent walk moves to SafeFile::<IsDirectory, R, O>::open_parent, which
  reports the failing directory as ParentError.
- RootSafeBinError is { path, kind } with #[from] kinds, so the checks use
  plain ? instead of per-call error closures.
@markovejnovic
markovejnovic force-pushed the fix/firecracker-trust-and-transport branch from 9601f32 to c570bd5 Compare November 16, 2026 04:50
@markovejnovic
markovejnovic merged commit 208224a into main Nov 16, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant