Repository navigation
Conversation
A Build Result path is checked lexically against its Result directory, but a symbolic link inside the directory (for example one restored from an extracted project archive) still led openFile and value-document reads to any file on the host. Resolve the physical path and require it to stay below the Result directory before opening it.
Containment was checked against the physical Build directory, so a Build directory or date bucket that was itself a symbolic link (for example one pointing at the home directory) made every file below that link count as inside the Result. Resolve only the Result root physically, append the lexical bucket and Build, and require the physical file to stay below that. Treat ENOTDIR and ELOOP like a missing file, and report a missing value document directly instead of re-reading the lexical path.
SanHsien
added a commit
to SanHsien/hypit
that referenced
this pull request
Nov 7, 2026
…i#460-hypit-ai#474; advance watermarks No PR was merged upstream, so nothing was cherry-picked: 11 PRs = 5 defer (hypit-ai#464 hypit-ai#466 hypit-ai#467 hypit-ai#469 hypit-ai#471, pinned in monitored) + 6 not applicable; 5 issues = 1 defer (hypit-ai#473) + 4 not applicable. hypit-ai#464 npm pin is moot because the fork gates publish jobs to upstream (b641cce). ROADMAP row updated with the deferred items. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
SanHsien
added a commit
to SanHsien/hypit
that referenced
this pull request
Nov 7, 2026
… symlinks (port of upstream PR hypit-ai#467) Ported before upstream merge: containedResultPath was lexical only, so a symlink or a linked Build/date directory in an extracted Result archive led openFile and value-document reads outside the Result. physicalResultPath compares realpath against the Result root plus the Build location. Tests from the PR (directory links as junctions on Windows) fail before (2) and pass after (13/13). external-file is untouched, as upstream. Replace with upstream's version once hypit-ai#467 is merged. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This branch has not been deployed
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.
Closes #477
Scope
This PR closes the symbolic link vector for
build-filereads only. It does not addressexternal-filereferences: afile:URI in anexternal-filevalue (packages/result/src/types.ts,packages/result/src/file-reference.ts, andopenFileinpackages/result/src/node/store.ts) is still an unrestricted local read under the same untrusted-archive threat model. That remains a separate open issue and needs a design decision (for example, whetherexternal-fileURIs from an imported Result should be trusted at all, or limited to an allowed set of roots).Problem
FileBuildResultRepositorychecks eachbuild-filepath lexically:assertBuildResultPathrejects.., absolute paths and backslashes, andcontainedResultPathrejects a resolved path that leaves the Result directory. The existing test "filesystem decodes Result and writer data before exposing it" shows that../outside.mp4is meant to be refused.A symbolic link gets past both checks, whether it is a file or directory inside the Result directory, or the Build directory or its date bucket itself (
.hypit/results/2026-09-02/bld_X -> /home/user).openFile(and the read of a composite Output's value document) then follow the link to whatever file it targets.openFileusesfile.build ?? build, so a file reference naming such a linked Build is enough.Impact
Severity: low to medium. Result directories are not always produced locally. The complex-explainer example has users extract a downloaded
media.tar.gzstraight into the project, and that archive includes a portable Result under.hypit/results.tarrestores symbolic links as they are stored. If an archive containsfiles/video.mp4 -> ~/.ssh/id_rsa, a linked directory, or a linked Build directory, that host file is then read as the Output's bytes:hypit get <build> <output> --to ...copies it into the export destination.Reproduction
Linked Build directory variant:
Fix
physicalResultPathkeeps the lexical check, then measures containment from the Result root: the allowed directory isjoin(realpath(<results root>), <bucket>, <build>), andrealpath(target)must stay strictly below it. Only the Result root is resolved physically, so a linked Build directory or date bucket no longer moves the allowed directory along with it. The resolved path is the one opened.undefined(unavailable).ENOTDIRandELOOPfromrealpathare treated the same way asENOENT..hypit/resultsmoved to another disk) is unaffected.The value-document read of composite Outputs uses the same check, and a missing value document now fails with a direct "is missing value document" error instead of re-reading the lexical path.
Tests
filesystem repository refuses Result files that resolve outside their Resultcovers a file symlink out, a directory symlink out, a ranged read, a missing file and an in-Result alias.filesystem repository refuses Result files under a Build or date directory linked outside the rootcovers a linked Build directory, a linked date bucket, and a file reference naming a linked Build from another Build. It fails before this change ("Missing expected rejection").filesystem repository reads Result files when the Result root is itself a symbolic linkcovers a linked Result root and a path below a regular file (ENOTDIR, unavailable rather than an error).pnpm check: passes.node --import tsx --test packages/result/test/*.test.ts: 16 tests, 16 pass.packages/cli/test/*.test.ts: 124 tests, 123 pass, 0 fail.pnpm test: 1150 tests, 1127 pass, 23 skipped, 0 fail.