Skip to content

fix(security): remove postinstall script, download binary on first run only#306

Merged
rhuanbarreto merged 1 commit into
mainfrom
security/remove-postinstall-script
May 11, 2026
Merged

fix(security): remove postinstall script, download binary on first run only#306
rhuanbarreto merged 1 commit into
mainfrom
security/remove-postinstall-script

Conversation

@rhuanbarreto

Copy link
Copy Markdown
Contributor

Summary

  • Remove scripts/postinstall.cjs and all references from package.json — postinstall scripts are a known npm supply chain attack vector that execute arbitrary code during npm install
  • The bin shim (bin/archgate.cjs) already handles on-demand binary download from GitHub Releases, making the postinstall purely a convenience pre-download
  • After this change, npm install -g archgate only places the lightweight shim on disk — no code executes until the user explicitly runs archgate
  • Fix ARCH-010 warnings in src/commands/adr/import.ts by replacing readFileSync + JSON.parse with Bun.file().json() (ADR check now reports 0 warnings)

Test plan

  • bun run validate passes (828 tests, 26 ADR rules, 0 violations, 0 warnings)
  • npm pack --dry-run confirms tarball contains only package.json, README.md, LICENSE.md, bin/archgate.cjs — no scripts/postinstall.cjs
  • Zero stale postinstall references in codebase (verified via grep)
  • CI pipeline passes

…n only

Postinstall scripts are a known npm supply chain attack vector — they
execute arbitrary code the moment a package is installed. The bin shim
(`bin/archgate.cjs`) already handles on-demand binary download, making
the postinstall purely a convenience pre-download.

After this change, `npm install -g archgate` only places the lightweight
shim on disk. No code executes until the user explicitly runs `archgate`.

Also fixes ARCH-010 warnings in `src/commands/adr/import.ts` by
replacing `readFileSync` + `JSON.parse` with `Bun.file().json()`.

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
@sentry

sentry Bot commented May 11, 2026

Copy link
Copy Markdown

✅ All tests passed.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying archgate-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: 76ff1d5
Status: ✅  Deploy successful!
Preview URL: https://cdb270f9.archgate-cli.pages.dev
Branch Preview URL: https://security-remove-postinstall.archgate-cli.pages.dev

View logs

@rhuanbarreto rhuanbarreto merged commit 41696f4 into main May 11, 2026
11 checks passed
@rhuanbarreto rhuanbarreto deleted the security/remove-postinstall-script branch May 11, 2026 21:18
@archgatebot archgatebot Bot mentioned this pull request May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant