Repository navigation
fix(fast_io): resolve an absolute operator rename endpoint by ownership - #7398
Merged
Merged
Conversation
confined_rename left an endpoint outside the confinement root to ambient AT_FDCWD resolution. That is the temp file staged by an absolute --temp-dir: its creation is confined, but the commit re-resolves its path, so a parent component flipped to a foreign-owned symlink in between redirects the rename source and lands attacker content in the destination. Upstream's do_rename_at() resolves each side by three arms, not two: a relative side beneath the tree via secure_relative_open (syscall.c:1945), an absolute operator side via the ownership walk (:1926), and a slashless name via AT_FDCWD (:1949). oc had the first and third and folded the second into the third; owner_walk.rs already implemented the walk but was wired only into the backup path. The ownership rule is more permissive than the confined walk, so it is selected by provenance only - the destination keeps the confined walk, which is why upstream does not set operator_path_resolve for this call. The (dirfd, name) mapping moves onto ConfinedEndpoint as resolved(). Four copies of that match existed, and the exhaustive enum surfaced a consumer the change had not accounted for; those copies are how the O_TMPFILE linkat commit and the named-temp rename drifted apart once before.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…ip (#7398) confined_rename left an endpoint outside the confinement root to ambient AT_FDCWD resolution. That is the temp file staged by an absolute --temp-dir: its creation is confined, but the commit re-resolves its path, so a parent component flipped to a foreign-owned symlink in between redirects the rename source and lands attacker content in the destination. Upstream's do_rename_at() resolves each side by three arms, not two: a relative side beneath the tree via secure_relative_open (syscall.c:1945), an absolute operator side via the ownership walk (:1926), and a slashless name via AT_FDCWD (:1949). oc had the first and third and folded the second into the third; owner_walk.rs already implemented the walk but was wired only into the backup path. The ownership rule is more permissive than the confined walk, so it is selected by provenance only - the destination keeps the confined walk, which is why upstream does not set operator_path_resolve for this call. The (dirfd, name) mapping moves onto ConfinedEndpoint as resolved(). Four copies of that match existed, and the exhaustive enum surfaced a consumer the change had not accounted for; those copies are how the O_TMPFILE linkat commit and the named-temp rename drifted apart once before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
confined_renameresolved an absolute endpoint outside the confinement rootwith
AT_FDCWDand the whole path. That is the temp file staged by an absolute--temp-dir: its creation is confined, but the commit re-resolves its path,so a parent component flipped to a foreign-owned symlink in between redirects
the rename source and lands attacker content in the destination.
That is the escape upstream's
temp-dir-symlink-injectiontest demonstrates. Onmaster it fails intermittently on the root leg - it loops for a race budget, so
it passes only when the flipper misses the window.
Upstream rule
do_rename_at()(syscall.c:1866-1990) resolves each side independently,by three arms, not two:
secure_relative_open()- confined beneath the tree:1945owner_walk_parent()- the ownership walk:1926AT_FDCWD+ the name:1949The split exists because location cannot be the trust signal for an operator
path - it may legitimately point outside the tree - so authority (ownership)
is used instead: follow a symlink owned by uid 0 or our euid, refuse any other.
oc had the first and third arms and folded the second into the third.
crates/fast_io/src/owner_walk.rsalready implements the walk; it was wiredonly into the backup path (
engine/src/local_copy/overrides.rs).Keying oc's first arm on beneath the root rather than on relative is the
equivalent test: upstream has already
chdir'd the receiver into thedestination, so its transfer paths are relative where oc's are
absolute-but-beneath-root.
The trap this deliberately avoids
The ownership rule is more permissive than the confined walk. Applying it to
both sides - or to any endpoint beneath the root - would weaken the
destination while fixing the source. Upstream does not set
operator_path_resolvefor this call, and neither does this change: the arm isselected by provenance, and the destination keeps the confined walk.
Design
ConfinedEndpointgains anOwnerWalkedarm, and the(dirfd, name)mappingmoves onto the type as
resolved(). There were four copies of that match,and the compiler found a fourth consumer I had not accounted for
(
confined_clone_file) precisely because the enum is exhaustive. Those copiesare how the two commit strategies drifted apart once before - the
O_TMPFILElinkatpath skipped confinement while the named-temp rename enforced it - so anew arm must now be impossible to handle in only some of them.
Tests
endpoint_provenance::*- three cases pinning which resolver each provenanceselects. The absolute-outside-root case is the fix.
an_out_of_tree_source_behind_an_owned_symlink_still_commits- the direction ablanket refusal would break: an operator path may legitimately live behind a
symlink they own, and the walk must follow it.
RED/GREEN measured. Removing only the absolute arm, leaving everything else:
Exactly one test flips, and it is the discriminator.
The cross-uid refusal is not duplicated here. Planting a foreign-owned
component needs a second uid, so an unprivileged assertion would pass
vacuously; the refusal is proven by the root leg of the upstream 3.5.0 suite.
This is the same division
crates/fast_io/tests/owner_walk.rsalready documentsfor the backup path.
Known gap, pre-existing, not introduced
Upstream gates the ownership walk on
symlink_optout_allowed()(
--insecure-links/ theinsecure linksmodule directive). oc has thatpredicate -
fast_io::confinement::Activation, truth-tabled - with zeroproduction constructors, so no site consults it. The sibling operator-path
call (
backup_rename->operator_link/operator_rename) applies the walkunconditionally on Unix for the same reason. This change follows that
precedent rather than inventing a second policy; wiring the opt-out belongs to
both sites at once and is tracked separately.
Verification
cargo fmt --all -- --check- cleancargo clippy --workspace --all-targets --all-features --no-deps -- -D warnings- exit 0, zero warningscargo nextest run -p fast_io --all-features- 746 passedcargo nextest run -p engine --all-features- 5008 passedFull-workspace and cross-platform coverage is left to the required CI contexts.
Behavioural proof, with a negative control
The cross-uid refusal cannot be observed unprivileged, so it was measured
directly: upstream 3.5.0's own
temp-dir-symlink-injectiontest, run as rooton aarch64 Linux against two
--releasebinaries that differ only by thiscommit. Same host, same harness, same built helper programs, same loop.
6c88fca(pre-fix)24280b3The control's failures carry the escape verbatim:
The test loops for a race budget, so a single pass proves nothing - which is
why the control matters. At the control's ~40% per-run failure rate, 20
consecutive passes would occur by chance with probability ~4e-5.
That budget is also why this test is worth closing rather than baselining: a
failrow in the expect manifest would make a required CI context a coin flip,and a
passrow would have waived a live escape.