core/policy: expand dangling symlinks, reject symlink loops, and hand… #531

Open
github-bot wants to merge 1 commit from github-bot/gh-531 into main AGit
Owner

@⁠pug205gti6 on GitHub · 2026-11-25 02:00 UTC · original
pug205gti6:pr/486-loader-core-policy → main · +190 −34 · 1 files · 1 commits · open

…le trailing ..

Previously, policy::resolve peeled path components with Path::file_name() on any std::fs::canonicalize error. That caused three bugs in ensure_outside_repo:

  1. Policy bypass via dangling symlinks: a symlink outside the repo whose target inside the repo does not exist yet caused canonicalize() to return NotFound; resolve() peeled the link name and returned the outside path, letting ensure_outside_repo return Ok(()).
  2. Symlink loops silently accepted: canonicalize() returned ELOOP, which resolve() treated like NotFound, peeled the link name, and returned Ok(()).
  3. Trailing .. after a missing component errored: Path::file_name() returns None on .., so paths like <outside>/missing/.. returned PolicyError::Io.

Walk components left-to-right, canonicalizing existing prefixes while explicitly expanding symbolic links (and dangling reparse points) via read_link up to MAX_SYMLINK_HOPS (40), returning PolicyError::Io on loops or non-NotFound errors.

**@⁠pug205gti6** on GitHub · 2026-11-25 02:00 UTC · [original](https://github.com/fxceless/victory-fork/pull/531) `pug205gti6:pr/486-loader-core-policy` → `main` · +190 −34 · 1 files · 1 commits · open …le trailing .. Previously, policy::resolve peeled path components with Path::file_name() on any std::fs::canonicalize error. That caused three bugs in ensure_outside_repo: 1. Policy bypass via dangling symlinks: a symlink outside the repo whose target inside the repo does not exist yet caused canonicalize() to return NotFound; resolve() peeled the link name and returned the outside path, letting ensure_outside_repo return Ok(()). 2. Symlink loops silently accepted: canonicalize() returned ELOOP, which resolve() treated like NotFound, peeled the link name, and returned Ok(()). 3. Trailing `..` after a missing component errored: Path::file_name() returns None on `..`, so paths like `<outside>/missing/..` returned PolicyError::Io. Walk components left-to-right, canonicalizing existing prefixes while explicitly expanding symbolic links (and dangling reparse points) via read_link up to MAX_SYMLINK_HOPS (40), returning PolicyError::Io on loops or non-NotFound errors.
Previously, policy::resolve peeled path components with Path::file_name()
on any std::fs::canonicalize error. That caused three bugs in
ensure_outside_repo:

1. Policy bypass via dangling symlinks: a symlink outside the repo whose
   target inside the repo does not exist yet caused canonicalize() to
   return NotFound; resolve() peeled the link name and returned the
   outside path, letting ensure_outside_repo return Ok(()).
2. Symlink loops silently accepted: canonicalize() returned ELOOP, which
   resolve() treated like NotFound, peeled the link name, and returned Ok(()).
3. Trailing `..` after a missing component errored: Path::file_name()
   returns None on `..`, so paths like `<outside>/missing/..` returned
   PolicyError::Io.

Walk components left-to-right, canonicalizing existing prefixes while
explicitly expanding symbolic links (and dangling reparse points) via
read_link up to MAX_SYMLINK_HOPS (40), returning PolicyError::Io on
loops or non-NotFound errors.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:45:33 +00:00
Author
Owner

@⁠Revens2 on GitHub · 2026-11-25 07:37 UTC · original

Duplicate of #486: @⁠IlyassRS3 opened this patch 36 minutes earlier, and gh pr diff returns the same bytes for both (+190/-34 on 1 file(s), same title).

Please continue in #486 so the review history and any test data stay in one place.
Thanks.

**@⁠Revens2** on GitHub · 2026-11-25 07:37 UTC · [original](https://github.com/fxceless/victory-fork/pull/531#issuecomment-7156064843) Duplicate of #486: @⁠IlyassRS3 opened this patch 36 minutes earlier, and `gh pr diff` returns the same bytes for both (+190/-34 on 1 file(s), same title). Please continue in #486 so the review history and any test data stay in one place. Thanks.
Author
Owner

@⁠Headache3318 on GitHub · 2026-11-25 09:25 UTC · original

Independent verification: PR #531 merges cleanly, no conflicts, 1 file changed policy.rs +190/-34. Build success 8.19s. Tests compile errors in victory-loader/victory-gpu pre-existing on main, not caused by this PR. Actual PR content is symlink handling improvements, title appears to be a misnomer. PR is build-verified and safe to merge. Machine: Arch Linux kernel 7.3.5-arch1-1, 3x RTX 4090 driver 620.73.04, Proton, AI-assisted.

**@⁠Headache3318** on GitHub · 2026-11-25 09:25 UTC · [original](https://github.com/fxceless/victory-fork/pull/531#issuecomment-7158313426) Independent verification: PR #531 merges cleanly, no conflicts, 1 file changed policy.rs +190/-34. Build success 8.19s. Tests compile errors in victory-loader/victory-gpu pre-existing on main, not caused by this PR. Actual PR content is symlink handling improvements, title appears to be a misnomer. PR is build-verified and safe to merge. Machine: Arch Linux kernel 7.3.5-arch1-1, 3x RTX 4090 driver 620.73.04, Proton, AI-assisted.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/531/head:github-bot/gh-531'
git switch 'github-bot/gh-531'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-531'
git switch 'github-bot/gh-531'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-531'
git switch 'github-bot/gh-531'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-531'
git switch 'main'
git merge --squash 'github-bot/gh-531'
git switch 'main'
git merge --ff-only 'github-bot/gh-531'
git switch 'main'
git merge 'github-bot/gh-531'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.