Repository navigation
ci: add malware-protection workflow (PolinRider-era TTP scanning) - #879
Merged
Merged
Conversation
…ise on walk errors
…andalone constructs, plain appends)
…d exec false positives
…d workflow rule precision
…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'.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.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-widecontents: read, no secrets passed to any job, and never executes project code (static-only — nonpm install,pull_requestnotpull_request_target).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.jsoncurl-to-shell, token-exfil patterns, malicious npm lifecycle hooks, pwn-request workflows,${{ github.event.* }}script injection, unpinned actions (per-jobsecrets: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..gitleaks.toml(baseline of 20 pre-existing findings,targetRules-scoped so new secrets still fail),docs/malware-protection.mdmaintainer guide, and 152 unit tests with inert fixtures undertests/malware-scan/fixtures/.docs/compose/.Design notes
scripts/malware-scan/andtests/malware-scan/only, so attackers cannot hide payloads in<any>/malware-scan/directories.ghp_secret still fails history scans after baselining.malware-protection.yml(pre-existingci.ymlfindings are out of scope for this PR); actionlint runs repo-wide.Verification
python3 -m unittest discover -s tests/malware-scan -v→ 152 tests OKscan.py --paths .→ exit 0 (allowlist suppresses fixture/doc false positives);--paths src→ exit 0gitleaks detect --source . --exit-code 1(v8.30.1) → exit 0 after config fix + baselinezizmor --persona auditor .github/workflows/malware-protection.yml→ 0 findingsactionlint→ cleanuses:pinned to verified 40-hex SHAs with version commentsFollow-ups (tracked, out of scope here)
ci.ymlactions and images (17 high zizmor findings)SUSP-HIGH-ENTROPYnoise onpackage-lock.jsonintegrity hashes is allowlisted; revisit thresholds if it growsCloses nothing (new CI); spec:
docs/compose/specs/2026-11-19-malware-protection-ci-design.md