Skip to content

fs origin: a FIFO swapped in between resolve and open still blocks a blocking-pool thread #2802

In review

Description

@yigitdot

Follow-up to #2775 / #2793.

FilesystemOrigin::resolve_regular stats the canonical path and refuses anything that is not a regular file, before any read opens it. The readers then open the path with plain tokio::fs::File::open, which opens read-only without O_NONBLOCK. If someone with write access to cache.origin.path renames a FIFO into place between that stat and the open, the open blocks until a writer appears. fetch and fetch_outboard re-check the type on the opened file, but that check runs after the open returns. fetch_range_data does not re-check.

Cost: within_origin_timeout ends the request, but the blocking-pool thread stays stuck in open(2). An attacker who keeps swapping a file and a FIFO can pin one thread per race they win, and enough wins exhaust tokio's blocking pool. The same window lets a symlink swapped in after canonicalize point outside the base. The fstat does not re-check containment.

Fix options:

  • Open with O_NONBLOCK through std::os::unix::fs::OpenOptionsExt::custom_flags, then clear it, or rely on the fstat is_file check that follows, since regular-file reads ignore O_NONBLOCK.
  • Open the canonical path with O_NOFOLLOW so a swapped-in symlink fails, which closes the containment half too. openat2(RESOLVE_BENEATH) on Linux closes it fully.

Both need a libc constant (or rustix). The workspace has no libc dependency today; crates/common/src/identity.rs defers an O_NOFOLLOW open for the same reason. This issue decides whether the cache crate takes that dependency.

Done when a FIFO or symlink swapped in after the resolve cannot block or escape any filesystem-origin read, with a test that renames a FIFO into place and asserts each read returns within a bound.

Activity

  1. added
    kind:security
    prio:low
    area:cache
    on Oct 31, 2026
  2. added a commit that references this issue on Nov 1, 2026
  3. yigitdot commented on Nov 1, 2026

    @yigitdot
    ContributorAuthor

    Since PR #2815, FilesystemOrigin::size() opens the file too, so the probe and rescan paths reach the same race. The fix for this issue must cover size() as well as fetch, fetch_range_data and fetch_outboard.

    🤖 Generated with Claude Code

  4. self-assigned this
    on Nov 26, 2026
  5. moved this from Backlog to In progress in deCDNon Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:cachekind:securityprio:low

Type

No type

Fields

Priority

None yet

Projects

  • Status
    In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions