Skip to content

fix(cache): contain and bound the fs origin's outboard read; zeroize node key buffers - #2793

Merged
yigitdot merged 5 commits into
mainfrom
fix/2775-fs-outboard-guard-key-zeroize
Nov 1, 2026
Merged

yigitdot merged 5 commits into
mainfrom
fix/2775-fs-outboard-guard-key-zeroize

Conversation

@yigitdot

Copy link
Copy Markdown
Contributor

Two local-hardening fixes from #2775.

Filesystem origin outboard read. FilesystemOrigin::fetch_outboard read {hex}.obao4 with no symlink containment and no regular-file check. A symlink to /dev/zero passed the metadata length gate and grew memory without bound (the origin timeout cannot cancel the blocking read), a FIFO pinned a blocking-pool thread, and a symlink out of cache.origin.path read foreign files.

  • One helper now canonicalizes, checks containment under the canonical base, and stats for a regular file before any open. fetch, fetch_range_data, size and fetch_outboard all use it, so a FIFO or device inside the base no longer blocks fetch at open either.
  • fetch_outboard re-checks the opened handle and reads through take(outboard_max_bytes + 1) into a buffer sized from the stat, so the cached Bytes holds no spare capacity.
  • An outboard symlinked to a file outside the base is now a permanent failure, as fetch already treats data objects; the engine falls back to a whole-blob pull.
  • Tests: symlink escape, symlink to /dev/zero, a directory and a socket in place of the outboard, a special file for each read method, and no spare buffer capacity.

Identity key buffers. load_from and the two key writes in decdn-common now hold the key bytes in zeroize::Zeroizing buffers, so they do not linger in freed memory. decdn-common gains a direct zeroize dependency (already a workspace dependency).

Closes #2775

🤖 Generated with Claude Code

Copilot AI balanced review requested due to automatic review settings October 30, 2026 22:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@github-code-quality

github-code-quality Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Rust, Solidity

Rust / code-coverage/cargo-llvm-cov

main c21a969 fix/2775-fs-outboard... 9fe33f9 +/-
77% 77% 0%
View coverage of the 6 most impacted files.
File main c21a969 fix/2775-fs-outboard... 9fe33f9 +/-
crates/node/src/dht/publish.rs 80% 78% -2%
crates/node/src...gin/pull_leg.rs 84% 84% 0%
crates/node/src...s/client/mod.rs 91% 91% 0%
crates/client/src/lib.rs 89% 90% +1%
crates/common/src/identity.rs 81% 82% +1%
crates/cache/src/origin/fs.rs 69% 75% +6%

Solidity / code-coverage/forge

main c21a969 fix/2775-fs-outboard... 9fe33f9 +/-
92% 92% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated November 01, 2026 01:47 UTC

The filesystem outboard read presized its buffer with Vec::with_capacity,
which aborts the process when the allocator refuses. It now goes through
read_capped, which reserves with try_reserve_exact and returns an
OutOfMemory error for that one read, as std::fs::read does. New tests
cover the reservation failure and the one-byte-past-the-cap bound.

Comments, the Origin trait docs and the engine's outboard doc now state
what the checks cover: the fstat re-check catches a swapped-in device
but not a FIFO, and the filesystem origin's escape and non-regular-file
refusals are origin errors. The CHANGELOG entry moves to Security and
splits the identity-key change into its own common bullet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yigitdot

Copy link
Copy Markdown
Contributor Author

Review fix pass in 42fa94e:

  • The outboard read presizes its buffer with try_reserve_exact in a new read_capped helper. An allocation failure now fails that one read with OutOfMemory instead of aborting the node, as std::fs::read did before. New tests cover the reservation failure and the one-byte-past-the-cap bound. Both cap mutations, no take and no +1, fail the new test.
  • Comments and the CHANGELOG now say what the checks cover. A FIFO swapped in after the resolve is not covered. The Origin trait docs name the filesystem origin's escape and non-regular-file refusals as errors. The CHANGELOG entry moves to Security, with the key-zeroize change as its own common: bullet.

Issues that were already there before this PR and that the review turned up:

…guard-key-zeroize

# Conflicts:
#	CHANGELOG.md
…guard-key-zeroize

# Conflicts:
#	CHANGELOG.md

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Successful reads can retain unbudgeted spare capacity in the outboard cache, and partial key reads on I/O failure can leave sensitive bytes unwiped.

2 open issues

Review effort: Balanced

Comment thread crates/cache/src/origin/fs.rs Resolved
Comment thread crates/common/src/identity.rs Resolved
…file straight into a wiped buffer

read_capped presizes from the stat, but a file that grows or shrinks
before the read leaves spare capacity that the outboard cache does not
budget. The successful buffer is now shrunk to its length.

load_from built its Zeroizing wrapper around fs::read's result, so a
read that failed partway dropped std's unwiped buffer. It now opens the
file and reads into a wiped [u8; 32], with a one-byte probe to refuse
an over-long file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@yigitdot
yigitdot merged commit 4ebf92d into main Nov 1, 2026
40 checks passed
@yigitdot
yigitdot deleted the fix/2775-fs-outboard-guard-key-zeroize branch November 1, 2026 04:18
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.

node: local hardening — fs-origin outboard symlink/special-file guard, identity-key buffer zeroization

3 participants