Commit b581d5f
authored
fix(security): harden clerk init dependency-install spawn (#302)
* fix(security): harden clerk init dependency-install spawn
`clerk init` spawns the project's package manager in attacker-controlled
cwd to install the framework SDK. On pnpm this autoloaded `.pnpmfile.cjs`
from cwd at install startup, executing arbitrary JS via `require()`
before any package resolved. Every PM additionally runs lifecycle
scripts (`preinstall`/`install`/`postinstall`) from the project's
`package.json`.
Pass `--ignore-pnpmfile` (pnpm) and `--ignore-scripts` (all PMs) to the
install spawn so a cloned-then-`clerk init`'d attacker repo can't gain
arbitrary code-exec at install time.
Decouple `globalInstallCommand` from `pmInstallCommand` — the
upgrade-Clerk hint message is a copy-pasteable instruction to the user
and must not inherit the hardening flags (lifecycle scripts are how
some PMs link the binary into PATH).
Fixes AIE-969.
* refactor(init): apply self-review feedback to security hardening
- Extract PM_INSTALL_HARDENING_FLAGS as single source of truth so the
`clerk init --starter` install path in bootstrap-registry.ts shares the
flags with the SDK install in heuristics.ts. Without this, the two
PM_INSTALL_COMMANDS tables drift independently and the `--starter` path
loses the hardening.
- Fix `satisfies` constraint on installer.ts GLOBAL_UPDATE_COMMANDS to bind
against Installer (not PackageManager) — those types are independently
maintained, and the lookup is called with an Installer.
- Replace per-PM for-loops in the test with `test.each(PACKAGE_MANAGERS)`
so each PM becomes its own named test case.
- Drop the AIE-969 ticket reference from the test comment (ticket refs
belong in PR description, not source).1 parent da2e3cf commit b581d5f
5 files changed
Lines changed: 76 additions & 14 deletions
File tree
- .changeset
- packages/cli-core/src
- commands/init
- lib
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 11 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
150 | 156 | | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
155 | 161 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
| |||
353 | 352 | | |
354 | 353 | | |
355 | 354 | | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
356 | 367 | | |
357 | 368 | | |
358 | 369 | | |
359 | 370 | | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
| 371 | + | |
364 | 372 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
11 | 30 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
16 | 35 | | |
17 | 36 | | |
18 | 37 | | |
| |||
0 commit comments