Skip to content

ci: add malware-protection workflow (PolinRider-era TTP scanning) - #879

Merged
DeFiVC merged 31 commits into
mainfrom
feat/malware-protection-ci
Nov 20, 2026
Merged

DeFiVC merged 31 commits into
mainfrom
feat/malware-protection-ci

Conversation

@DeFiVC

@DeFiVC DeFiVC commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds .github/workflows/malware-protection.yml: 4 jobs (custom TTP scan, daily git-history sweep, gitleaks secret scan, zizmor+actionlint workflow lint) triggered on PRs to main, pushes to main, daily cron, and manual dispatch. SHA-pinned actions, workflow-wide contents: read, no secrets passed to any job, and never executes project code (static-only — no npm install, pull_request not pull_request_target).
  • Adds scripts/malware-scan/scan.py — a Python-3-stdlib malware scanner with 12 BLOCK/WARN rules covering PolinRider-era TTPs: config-file payload append, obfuscated JS, .vscode/tasks.json curl-to-shell, token-exfil patterns, malicious npm lifecycle hooks, pwn-request workflows, ${{ github.event.* }} script injection, unpinned actions (per-job secrets: escalation), high-entropy literals, typosquat dependencies, decode-and-execute commands, plus diff-only new-binary/new-dependency rules. Fail-safe exit codes (0 clean / 1 BLOCK / 2 scanner error), allowlist with mandatory reasons, GitHub annotations + Markdown job summary with an incident-response checklist.
  • Adds .gitleaks.toml (baseline of 20 pre-existing findings, targetRules-scoped so new secrets still fail), docs/malware-protection.md maintainer guide, and 152 unit tests with inert fixtures under tests/malware-scan/fixtures/.
  • Includes the spec + implementation plan under docs/compose/.

Design notes

  • Tiered enforcement: confirmed-malware indicators BLOCK (exit 1); suspicious heuristics WARN (annotations only); scanner crashes fail safe (exit 2).
  • Path exclusion is anchored to scripts/malware-scan/ and tests/malware-scan/ only, so attackers cannot hide payloads in <any>/malware-scan/ directories.
  • gitleaks baseline entries are path-anchored and rule-scoped; verified that a synthetic ghp_ secret still fails history scans after baselining.
  • zizmor runs scoped to malware-protection.yml (pre-existing ci.yml findings are out of scope for this PR); actionlint runs repo-wide.

Verification

  • python3 -m unittest discover -s tests/malware-scan -v → 152 tests OK
  • scan.py --paths . → exit 0 (allowlist suppresses fixture/doc false positives); --paths src → exit 0
  • gitleaks detect --source . --exit-code 1 (v8.30.1) → exit 0 after config fix + baseline
  • zizmor --persona auditor .github/workflows/malware-protection.yml → 0 findings
  • actionlint → clean
  • All workflow uses: pinned to verified 40-hex SHAs with version comments

Follow-ups (tracked, out of scope here)

  • Pin/fix ci.yml actions and images (17 high zizmor findings)
  • SUSP-HIGH-ENTROPY noise on package-lock.json integrity hashes is allowlisted; revisit thresholds if it grows
  • Mark the new checks as required status checks in branch protection

Closes nothing (new CI); spec: docs/compose/specs/2026-11-19-malware-protection-ci-design.md

…dings

The array-of-tables form [[allowlist]] fails to load on pinned gitleaks
v8.30.1 ('AllowList' expected a map, got 'slice'), so the secrets-scan job
exited 1 before scanning. Use the supported [[allowlists]] form (the
singular [allowlist] table is a deprecated 9.x-removal shim) and add
path-scoped entries with honest reasons for the 20 pre-existing
generic-api-key findings at c1d9d02 (ci.yml x7, src/config/index.ts x1,
tests/unit/config/stellar.test.ts x3,
tests/unit/services/idempotency.test.ts x9). Each baseline entry is
anchored to its exact file and targeted at the generic-api-key rule only,
so new leaks of other rules — or new leaks outside those paths — still
fail the scan.
…-wide

zizmor --persona auditor over .github/workflows/ exits 14 with 27
findings, all in pre-existing ci.yml (unpinned uses/images, artipacked,
excessive permissions). Spec [S7] puts ci.yml changes out of scope for
this feature, so the job could never go green as written. Run zizmor only
on malware-protection.yml (exits 0) while actionlint keeps linting every
workflow (passes repo-wide). Document the scope and that ci.yml
hardening is tracked separately.
Any path containing a bare 'malware-scan' component was excluded in
tree/diff/history modes, so an attacker PR could hide payloads under
<any>/malware-scan/ (e.g. src/malware-scan/payload.js silently
unscanned). Anchor the exclusion to exactly the scanner's own prefixes
relative to the repo root — scripts/malware-scan/ and tests/malware-scan/ —
via anchored rel checks in the iter_scan_paths walk prune and _excluded_rel
for diff/history; explicit file arguments inside those dirs still raise
loudly. A random src/malware-scan/ is now scanned and blocks on payloads.

TDD: added tests for src/malware-scan/evil.js being scanned and firing in
paths mode, scanner dirs being skipped, and a changed file under
src/malware-scan/ firing in diff mode (first two bypass tests red before
the fix).
Spec [S3] C1 / [S8] row 5 promise npm audit with high/critical as WARN
tier, but it was never wired into the workflow. Add a ttp-scan step:
npm audit --package-lock-only --audit-level=high with
continue-on-error (WARN semantics — never fails the job; the lockfile is
audited without installing packages or executing project code) and its
output tail appended to $GITHUB_STEP_SUMMARY. Document the step in the
coverage notes. No npm install added.
Diff mode now applies the same 5MB MAX_FILE_BYTES cap as tree/history
modes — oversized changed files are skipped with a stderr note instead of
being read whole. Implement the executable-bit half of the SUSP-NEW-BINARY
spec claim (added file mode & 0o111 -> WARN 'executable-bit file added')
and add its positive unit test plus the required NUL-bytes-via-diff-mode
positive test. Fix docs: non-PR secrets-scan scans full git HISTORY, not
'full tree'.
@DeFiVC
DeFiVC merged commit af81117 into main Nov 20, 2026
7 of 9 checks passed
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