Skip to content

feat: snare shield, and shellcheck in CI - #19

Merged
AviOfLagos merged 2 commits into
mainfrom
ci/shellcheck
Aug 27, 2026
Merged

feat: snare shield, and shellcheck in CI#19
AviOfLagos merged 2 commits into
mainfrom
ci/shellcheck

Conversation

@AviOfLagos

Copy link
Copy Markdown
Owner

Closes #18.

snare shield — the hook stops a payload leaving; the shield stops one running. Wraps npm/pnpm/yarn/bun/npx (checks cwd before running) and git clone (scans the fresh clone before you cd in). ~22ms, bounded check — no git walking.

Verified live: clean dir runs, infected dir blocked with exit 1, SNARE_SKIP_SHIELD=1 bypasses, clone of an infected repo warns immediately, install/uninstall restores the profile byte-for-byte.

Two bugs found by testing it, not by reading it:

  • gated on [ -t 1 ], so npm install > log 2>&1 skipped the check entirely — a trivial bypass, now removed
  • uninstall left a stray blank line, so install/uninstall cycles grew the profile

shellcheck in CI — the pass that found the guard evasion hole in #17 now runs on every push. CI also validates the generated shield snippet: it lives in a heredoc, so neither bash -n nor shellcheck parses it, and a deleted if-body slipped through that gap during this work.

shield (#18)
  The hook stops a payload leaving; the shield stops one running. Both known
  execution routes fire without the user typing anything malicious, so a check
  that runs BEFORE the package manager means the payload never gets its
  trigger.

  'snare shield install' wraps npm, pnpm, yarn, bun, npx and git clone in the
  user's shell profile. The package managers are checked against the working
  directory before they run; git clone scans the fresh clone and warns before
  you cd into it. SNARE_SKIP_SHIELD=1 bypasses.

  The check is deliberately bounded — config files, .vscode/tasks.json and
  asset magic bytes, no git walking — because it runs before every npm
  install. Measured at ~22ms.

  Two things found while testing it:

  - The first version gated on [ -t 1 ], so 'npm install > log 2>&1' silently
    skipped the check. Redirecting output is common and would have been a
    trivial bypass. The tty test is gone; rc files only load in interactive
    shells anyway, so scripts were never affected.
  - Uninstall left a stray blank line, so install/uninstall cycles grew the
    profile. It now restores the file byte-for-byte.

shellcheck in CI
  A two-minute shellcheck pass found a guard evasion hole that eight rounds of
  manual review missed. It now runs on every push and pull request.

  CI also validates the generated shield snippet. That snippet lives inside a
  heredoc, so neither 'bash -n' nor shellcheck ever parses it — a deleted
  if-body slipped through exactly that gap during this work and was only
  caught by running the thing.

Closes #18
@AviOfLagos
AviOfLagos merged commit d6976c3 into main Aug 27, 2026
2 checks passed
@AviOfLagos
AviOfLagos deleted the ci/shellcheck branch August 27, 2026 13:42
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.

snare shield — scan before npm/pnpm/yarn/bun/git clone runs anything

2 participants