You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unresolved $HOME installs into a literal project directory #970
Confirmed fail-open path-expansion defect (audit finding BGO-008). Reproduced at 450733e with -O1 on 2026-09-03 (HOME removed from environment).
Source chain
At src/BuildGraphOps.w:546-559, a recognized $HOME/ prefix expands only when the env value is nonempty; otherwise execution falls through to the ordinary project-relative resolver. build_graph_install_file then checks whether the already-resolved result both equals the original string and starts with $HOME/ (:600-603) — a condition that cannot catch the prefixed root. Result: green build creating ./\/home/shawn/audit-installed; the requested home install never occurs.
Repair boundary
Status-bearing expansion that rejects missing/empty variables before project resolution; separate tests for missing, empty, set, absolute, DESTDIR, BINDIR, and PREFIX cases.
Verdict. Established on current main. When HOME is unset or empty, an Install target whose destination begins with $HOME/ runs green (rc 0) and installs into a literal $HOME directory under the project root. The guard intended to catch this is dead code: it compares the already-resolved absolute path to the original $HOME/... string, which can never be equal.
Tested revision and compiler
item
value
source
main @ 5809ac1 (2026-09-14), contains the reported 450733e
compiler
out/release/bin/with, self-reports with v0.15.1.7-g66d9b27d8, built from this tree by the last battery (not the seed)
platform
macOS Darwin 25.6.0, arm64
Repro
tool.bin = payload.
use std.build
pub fn build(ctx: BuildCtx) -> Build:
var out = ctx.new_build()
var i = target_new(.Install, "install-home", "tool.bin").output("$HOME/audit-installed")
out = out.add_target(move i)
out
environment
rc
result
env -u HOME with build :install-home
0
./$HOME/audit-installed created inside the project
HOME= with build :install-home
0
same
HOME=<tmp>/fakehome (control)
0
<tmp>/fakehome/audit-installed created, correct
Expected for the first two: a diagnostic ("could not resolve destination") and rc 1 with nothing written.
Root cause (read in source, confirmed by the runs)
src/BuildGraphOps.w:571-575: build_graph_expand_install_path expands $HOME/ only when the variable is non-empty; otherwise it falls through to build_graph_resolve_project_path(root, path) at :584, which joins the literal string onto the project root.
src/BuildGraphOps.w:628-631: the guard tests dest_path == target.output and dest_path.starts_with("$HOME/"). dest_path is <root>/$HOME/... by then, so the equality is always false and the branch is unreachable for this input.
The same non-status expansion shape applies to $INSTALL_BINDIR/ and $INSTALL_LIBDIR/ (:576-583), though those have defaults via PREFIX, so only an empty DESTDIR ++ bindir could fall through; I did not exercise that path.
Spec / docs
docs/with-build.md line 559 describes Install as "Copy/install an artifact"; build.w:3002 uses $HOME/.local/bin/with for :install-user, and build/wo.w:155-162 spells the bundle store under $HOME/. So a missing HOME on a CI runner or a sudo-scrubbed environment would today write the user-install into the checkout and report success. AGENTS.md §No Silent Fallbacks applies.
Related PRs
Commit 5655191 (install verification via verify=) touched this function after the report but did not change the expansion or the guard. No open PR touches it.
Would I champion a fix? Yes.
Acceptance criteria:
Expansion returns a status; a $HOME/, $INSTALL_BINDIR/, or $INSTALL_LIBDIR/ prefix whose variable resolves empty fails before mkdir_p with a diagnostic naming the target and variable.
The dead guard at :629 is removed or rewritten against the expansion status.
Behaviour tests for HOME missing, HOME empty, HOME set, an absolute destination, and the DESTDIR/BINDIR/PREFIX combinations assert both rc and the exact path written.
Untested
Linux and Windows not executed (Windows has no HOME by default, which makes this more likely there). The $INSTALL_* prefixes were read, not run.
Correction to the compiler-identity line above. The binary I ran, out/release/bin/with reporting with v0.15.1.7-g66d9b27d8, was built from commit 66d9b27 (2026-09-05), not from the HEAD I inspected (5809ac1). The source I cited and the behaviour I observed are for the functions in this issue, which are unchanged between those two commits apart from PR #1082's swap of a POSIX path[0] == '/' test for the shared runtime_path_is_absolute predicate (identical for the inputs used here). I verified that with git diff 66d9b27d8 5809ac10 -- src/BuildGraphOps.w src/BuildGraphSupport.w before posting. The verdict stands; the identity line should read: binary built from 66d9b27, source links pinned to 5809ac1.
Triage 2026-10-25, with v0.15.3.0 (main a261b65): reproduced. The $HOME/ guard in build_graph_install_file (src/BuildGraphOps.w:687) still cannot see the unexpanded prefix.
target_new(.Install, "inst", "f.txt").output("$HOME/triage-970-installed")
$ env -u HOME with build :inst
survey: all targets green
$ find . -name "triage-970*"
./$HOME/triage-970-installed
pre-release: an install silently lands in the project instead of failing, and the fix is a status from the expander.
Fixed on main by da991d1 (#2706), merged through stack 7 whose seed-driven battery was green on its top (gate, uat and survey all green). Regression test: test/internals/build_graph_install_prefix_test.w.
Activity
ehartford commentedon Sep 15, 2026
Review: reproduced
Verdict. Established on current
main. WhenHOMEis unset or empty, anInstalltarget whose destination begins with$HOME/runs green (rc 0) and installs into a literal$HOMEdirectory under the project root. The guard intended to catch this is dead code: it compares the already-resolved absolute path to the original$HOME/...string, which can never be equal.Tested revision and compiler
main@ 5809ac1 (2026-09-14), contains the reported 450733eout/release/bin/with, self-reportswith v0.15.1.7-g66d9b27d8, built from this tree by the last battery (not the seed)Repro
tool.bin=payload.env -u HOME with build :install-home./$HOME/audit-installedcreated inside the projectHOME= with build :install-homeHOME=<tmp>/fakehome(control)<tmp>/fakehome/audit-installedcreated, correctExpected for the first two: a diagnostic ("could not resolve destination") and rc 1 with nothing written.
Root cause (read in source, confirmed by the runs)
src/BuildGraphOps.w:571-575:build_graph_expand_install_pathexpands$HOME/only when the variable is non-empty; otherwise it falls through tobuild_graph_resolve_project_path(root, path)at:584, which joins the literal string onto the project root.src/BuildGraphOps.w:628-631: the guard testsdest_path == target.output and dest_path.starts_with("$HOME/").dest_pathis<root>/$HOME/...by then, so the equality is always false and the branch is unreachable for this input.$INSTALL_BINDIR/and$INSTALL_LIBDIR/(:576-583), though those have defaults viaPREFIX, so only an emptyDESTDIR ++ bindircould fall through; I did not exercise that path.Spec / docs
docs/with-build.mdline 559 describes Install as "Copy/install an artifact";build.w:3002uses$HOME/.local/bin/withfor:install-user, andbuild/wo.w:155-162spells the bundle store under$HOME/. So a missingHOMEon a CI runner or asudo-scrubbed environment would today write the user-install into the checkout and report success. AGENTS.md §No Silent Fallbacks applies.Related PRs
Commit 5655191 (install verification via
verify=) touched this function after the report but did not change the expansion or the guard. No open PR touches it.Would I champion a fix? Yes.
Acceptance criteria:
$HOME/,$INSTALL_BINDIR/, or$INSTALL_LIBDIR/prefix whose variable resolves empty fails beforemkdir_pwith a diagnostic naming the target and variable.:629is removed or rewritten against the expansion status.Untested
Linux and Windows not executed (Windows has no
HOMEby default, which makes this more likely there). The$INSTALL_*prefixes were read, not run.ehartford commentedon Sep 15, 2026
Correction to the compiler-identity line above. The binary I ran,
out/release/bin/withreportingwith v0.15.1.7-g66d9b27d8, was built from commit 66d9b27 (2026-09-05), not from the HEAD I inspected (5809ac1). The source I cited and the behaviour I observed are for the functions in this issue, which are unchanged between those two commits apart from PR #1082's swap of a POSIXpath[0] == '/'test for the sharedruntime_path_is_absolutepredicate (identical for the inputs used here). I verified that withgit diff 66d9b27d8 5809ac10 -- src/BuildGraphOps.w src/BuildGraphSupport.wbefore posting. The verdict stands; the identity line should read: binary built from 66d9b27, source links pinned to 5809ac1.ehartford commentedon Oct 25, 2026
Triage 2026-10-25,
with v0.15.3.0(main a261b65): reproduced. The$HOME/guard inbuild_graph_install_file(src/BuildGraphOps.w:687) still cannot see the unexpanded prefix.pre-release: an install silently lands in the project instead of failing, and the fix is a status from the expander.
build: an install under an unset $HOME, $INSTALL_BINDIR or $INSTALL_L…
build: an install under an unset $HOME, $INSTALL_BINDIR or $INSTALL_L…
ehartford commentedon Oct 26, 2026
Fixed on main by da991d1 (#2706), merged through stack 7 whose seed-driven battery was green on its top (gate, uat and survey all green). Regression test:
test/internals/build_graph_install_prefix_test.w.