fix(aztec-up): Do not leak node_modules/.bin into the PATH#22709
Merged
Conversation
nchamo
reviewed
Apr 22, 2026
Contributor
nchamo
left a comment
There was a problem hiding this comment.
Great finding and fix!
Bash is not my specialty, but looks pretty good. I left a few comments we can discuss if needed
Co-authored-by: Nicolas Chamo <nicolas@chamo.com.ar>
Co-authored-by: Nicolas Chamo <nicolas@chamo.com.ar>
Collaborator
|
❌ Failed to cherry-pick to |
vezenovm
added a commit
that referenced
this pull request
Apr 23, 2026
…22709) (#22740) Backport of #22709 to `v4-next`. ## Conflict resolution The automatic cherry-pick failed with a conflict in `docs/docs-developers/docs/resources/migration_notes.md`. The PR adds a new `### [CLI] aztec-up no longer exposes transitive npm bins on PATH` entry to the `## TBD` section. In `next` that section already contained a `### [Protocol] Domain separators introduced…` entry (from an unrelated change); in `v4-next` the `## TBD` section is empty, so 3-way merge couldn't place the new entry. Resolution: kept only the new `[CLI]` section from #22709, dropped the unrelated `[Protocol] Domain separators` context that isn't part of #22709 and doesn't apply to `v4-next`. Final diff stat matches #22709 exactly: `+56 / -5`, 4 files (`aztec-up/bin/0.0.1/aztec-install`, `aztec-up/bin/0.0.1/aztec-up`, `aztec-up/bin/0.0.1/install`, `docs/docs-developers/docs/resources/migration_notes.md`). ## Commits 1. `cherry-pick: ... (with conflicts)` — raw cherry-pick with conflict markers committed as-is. 2. `fix: resolve cherry-pick conflicts` — removes markers and the unrelated `[Protocol]` section. No build-fixes commit needed — only shell scripts and a Markdown doc touched, no compilation affected. ## Original PR summary The `aztec-up` installer was adding `$HOME/.aztec/current/node_modules/.bin` to the shell `PATH`, exposing ~40 transitive npm bins (`jest`, `tsc`, `tsserver`, `semver`, `uuid`, `json5`, `pino`, `mime`, `rlp`, ...) and silently shadowing user-installed versions. This PR exposes only the 7 `@aztec/*`-owned bins via a new `symlink_aztec_bins` function and drops `node_modules/.bin` from the `PATH` line and `aztec-up env` output. Backport triggered by `backport-to-v4-next` label on #22709. Original auto-backport run: https://github.com/AztecProtocol/aztec-packages/actions/runs/24837667070 ClaudeBox log: https://claudebox.work/s/c3ea95f8c16a721b?run=1
chrismarino
pushed a commit
to chrismarino/aztec-packages
that referenced
this pull request
May 5, 2026
BEGIN_COMMIT_OVERRIDE fix(aztec test): anchor contract log filter to avoid framework spam (AztecProtocol#22726) fix(aztec-up): Do not leak node_modules/.bin into the PATH (AztecProtocol#22709) END_COMMIT_OVERRIDE
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.
Summary
The
aztec-upinstaller adds$HOME/.aztec/current/node_modules/.binto the user's shell PATH. That directory contains the bin entries of every transitive npm dependency of the Aztec packages, so ~40 third-party bins (jest,tsc,tsserver,semver,uuid,json5,pino,mime,rlp, ...) end up on PATH, silently shadowing user-installed versions.This PR exposes only the 7 intended
@aztec/*-owned bins and dropsnode_modules/.binfrom the PATH line.Why
Two problems with the current setup:
jest@29pinned locally silently runs Aztec's bundledjest@30when typingjest, producing confusing errors (e.g. the renamed--testPathPatternflag). Same trap fortsc,semver, etc. The user has no way to enumerate what's been shadowed without reading the dep tree.postinstallor when Aztec uses it — but putting transitive bins on PATH adds a new invocation vector: a compromised transitive bin can fire on normal dev activity (jest,tsc) rather than only when Aztec calls it. Notably, that bypasses--ignore-scripts-style defenses and is stealthier than a postinstall payload. Standard package managers (npm install -g,pipx,brew,cargo install) do not expose transitive bins on PATH; they symlink only the package's declared entry points.Context: https://gist.github.com/AztecBot/fc2f40d50592c468429f922921a271f2 and https://www.notion.so/aztecnetwork/Getting-Started-Token-Tutorial-Walk-Through-348a1f6b0e35806a884edc16742866b9
Changes
aztec-up/bin/0.0.1/install— newsymlink_aztec_binsfunction, called afterinstall_aztec_packages. Iteratesnode_modules/.bin/*, keeps only symlinks whose target starts with../@aztec/, and re-links them into$version_path/bin/using relative paths (../node_modules/.bin/<name>). No hard-coded list: the set of exposed bins follows whatever@aztec/*packages declare.aztec-up/bin/0.0.1/aztec-install— drops$HOME/.aztec/current/node_modules/.binfrom the shell-profile PATH export.aztec-up/bin/0.0.1/aztec-up— dropsnode_modules/.binfromaztec-up envoutput so per-project.aztecrcswitching also skips the leak.Each version's
bin/stays self-contained, soaztec-up use <ver>flips the entire bin set atomically via thecurrentsymlink — same mechanism as today.Verification
Ran the new
symlink_aztec_binsfunction against an existing~/.aztec/currentinstall, mirrored into a throwawayAZTEC_HOME:7 bins exposed vs. 40 before; all resolve; end-to-end execution works.
Confirmed non-regressions
Audited Aztec production CLI code for bare-name shell-outs that could rely on transitive bins being on PATH:
yarn-project/aztec/scripts/aztec.sh— shells out toanvil,nargo,nc, and itself.anvil/nargolive incurrent/bin/(installed byaztec-install),ncis system. Unaffected.yarn-project/aztec/src/cli/cmds/compile.ts/profile_gates.ts— resolvebbviafindBbBinary()(absolute path from@aztec/bb.js), fall back to bare'bb'which remains reachable as a new symlink incurrent/bin/.yarn-project/cli/src/cmds/misc/update/npm.ts— intentionally invokes user's systemnpm/pnpm/yarn. Unaffected.No other bare-name invocations of transitive bins.
Migration
Fresh installs and
aztec-up install <ver>pick up the fix automatically. Existing users still have the oldexport PATH=…:current/node_modules/.bin:…line in their shell profile; that gets rewritten the next time they runaztec-install(the existing dedup ataztec-install:210strips old entries). Worth flagging in release notes.