supply-chain-attack-response – skill DevOps & Hạ tầng cho agent AI
Phát hiện, ứng phó và ngăn chặn các cuộc tấn công chuỗi cung ứng phần mềm nhắm vào package registry, container image và pipeline CI/CD, với kiểm tra lockfile và xác minh provenance.
Cài skill supply-chain-attack-response bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/supply-chain-attack-response-00bc7.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /supply-chain-attack-response – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/supply-chain-attack-response-00bc7.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $supply-chain-attack-response – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/supply-chain-attack-response-00bc7.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /supply-chain-attack-response – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/supply-chain-attack-response-00bc7.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /supply-chain-attack-response – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
> ⚠️ AUTHORIZED USE ONLY
> This skill is for educational purposes or authorized security assessments only.
> You must have explicit, written permission from the system owner before using this tool.
> Misuse of this tool is illegal and strictly prohibited.
> Mandatory confirmation gate
> Before running any command that probes, exploits, changes, persists on, extracts data from, or attempts credential access against a target:
> 1. Ask the user to state the exact target URL, IP, account, or resource.
> 2. Ask the user to confirm written authorization and the permitted scope.
> 3. Show the exact command(s) and explain their expected effect.
> 4. Wait for explicit confirmation in the current conversation.
>
> Without that confirmation, remain read-only and provide defensive guidance only. Prefer a sandbox, disposable VM, or controlled lab.
Supply Chain Attack Response
Software supply chain attacks target the dependencies, build systems, and distribution channels that developers trust implicitly. When a package on PyPI, npm, or crates.io is compromised, downstream consumers may receive malicious content; execution and exposure depend on installation/build/runtime paths. This skill provides detection techniques, emergency response playbooks, and hardening strategies to protect your software supply chain end to end.
---
2. Detection
2.1 npm Audit
# Full audit of installed packages
npm audit
# JSON output for programmatic processing
npm audit --json | jq '.vulnerabilities | to_entries[] | select(.value.severity == "critical")'
# Review a repair proposal in an isolated trusted copy; do not auto-fix an incident host.
npm audit fix --dry-run --ignore-scripts
# Check the current reviewed Socket CLI documentation and data-transfer policy before installing/running it.2.2 pip Audit
# Install pip-audit (maintained by Google/OSSF)
pip install pip-audit
# Audit known advisories for the current environment (select OSV explicitly when required)
pip-audit
# Audit a requirements file directly
pip-audit --no-deps --disable-pip -r requirements.txt --format json
# pip-audit detects known vulnerability advisories, not typosquatting; --strict affects dependency-audit failures.2.3 Cargo Audit
# Install cargo-audit
cargo install cargo-audit
# Run audit against RustSec Advisory Database
cargo audit
# JSON output for CI integration
cargo audit --json
# Check for yanked crates
cargo audit --deny yanked2.4 Sigstore / Cosign Verification
# Verify a container image signature with cosign
cosign verify \
--certificate-identity "https://github.com/myorg/myrepo/.github/workflows/build.yml@refs/heads/main" \
--certificate-oidc-issuer "https://token.actions.githubusercontent.com" \
ghcr.io/myorg/myimage@sha256:<full-reviewed-digest>
# Verify an artifact with sigstore-python
pip install sigstore
python -m sigstore verify identity \
--cert-identity "[email protected]" \
--cert-oidc-issuer "https://accounts.google.com" \
artifact.tar.gz2.5 SLSA Provenance Checks
# Install slsa-verifier
go install github.com/slsa-framework/slsa-verifier/v2/cli/slsa-verifier@latest
# Verify provenance of a binary
slsa-verifier verify-artifact my-binary \
--provenance-path my-binary.intoto.jsonl \
--source-uri github.com/myorg/myrepo \
--source-tag v1.2.3---
3. Emergency Response Playbook
When a dependency is confirmed compromised, execute these steps in order.
Step 1: Contain -- Pin and Freeze
# Pin the last known-good version immediately in package.json
npm install <package>@<safe-version> --save-exact --ignore-scripts
# Only in a clean isolated repair copy, after preserving incident evidence.
# For pip, pin with hash verification
python -m pip download --only-binary=:all: --require-hashes -r reviewed-requirements.txt -d ./vendor/
# reviewed-requirements.txt must pin all dependencies and verified artifact hashes.
# For cargo, pin in Cargo.toml
# Replace: some_crate = "^1.2" with:
# some_crate = "=1.2.3"
cargo update -p some_crate --precise 1.2.3Step 2: Audit Exposure
# Determine which versions you pulled and when
# npm
npm ls <compromised-package>
cat package-lock.json | jq '.packages | to_entries[] | select(.key | contains("<compromised-package>"))'
# pip
pip show <compromised-package>
pip cache list <compromised-package>
# Check git history for when the dependency version changed
git log --all -p -- package-lock.json | grep -A2 -B2 "<compromised-package>"Step 3: Scan for Indicators of Compromise
# Search for known IOCs from the advisory
grep -r "suspicious-domain.com" ./node_modules/<compromised-package>/
rg --fixed-strings -- "atob" ./node_modules/<compromised-package>/
# Check for unexpected post-install scripts
cat node_modules/<compromised-package>/package.json | jq '.scripts'
# For Python packages, inspect setup.py and __init__.py
rg -l --glob "*.py" -- "subprocess|os[.]system|exec|eval" ./reviewed-package-copy/Step 4: Notify Stakeholders
SUBJECT: [SECURITY INCIDENT] Compromised dependency: <package-name>
SEVERITY: Critical
IMPACT: <package-name> versions <affected-range> contain malicious code.
AFFECTED SYSTEMS: <list of repos/services consuming this dependency>
STATUS: Contained -- pinned to safe version <safe-version>
ACTIONS TAKEN:
1. Pinned all repositories to last known-good version
2. Initiated audit of all systems that pulled affected versions
3. Scanning for indicators of compromise
RECOMMENDED ACTIONS:
- Do NOT deploy any build that consumed affected versions
- Review CI/CD logs for the timeframe <start> to <end>
- Rotate any secrets that were accessible to the build environmentStep 5: Replace or Fork
# If the package maintainer account was compromised, fork the last safe version
git clone https://github.com/original-author/<package>.git
cd <package>
git checkout v<safe-version>
# Publish to your private registry or vendor directly
# For npm, point to your fork via package.json
# "dependencies": { "<package>": "git+https://github.com/yourorg/<package>.git#v1.2.3" }---
4. Lockfile Auditing
Lockfiles are your first line of defense. Tampered or inconsistent lockfiles indicate something is wrong.
4.1 Verify Lockfile Integrity
# npm: ensure lockfile matches package.json (fails CI if out of sync)
npm ci --ignore-scripts
# Yarn: check lockfile integrity
YARN_ENABLE_SCRIPTS=false yarn install --immutable # modern Yarn; verify installed version
# pip: generate a hash-locked requirements file
pip-compile --generate-hashes requirements.in -o requirements.txt
# Verify no unexpected changes in lockfile during PR
git diff --name-only origin/main...HEAD | grep -E "(package-lock|yarn.lock|Cargo.lock|requirements.txt)"4.2 Detect Typosquatting
# Use separately reviewed package-risk tooling; do not fetch an unverified npx tool during containment.
# Python: check package names against popular packages
# pip-audit is not a typosquatting detector.
# Custom check: compare package names to known popular packages
# Illustrative SequenceMatcher similarity against a tiny list; this is not edit distance or a malware verdict.
python3 -c "
import json, sys
from difflib import SequenceMatcher
with open('package-lock.json') as f:
lock = json.load(f)
popular = ['express','lodash','react','axios','chalk','debug','commander','inquirer']
for pkg in lock.get('packages', {}):
name = pkg.split('node_modules/')[-1] if 'node_modules/' in pkg else pkg
for p in popular:
ratio = SequenceMatcher(None, name, p).ratio()
if 0.75 < ratio < 1.0 and name != p:
print(f'WARNING: {name} is suspiciously similar to {p} (similarity: {ratio:.2f})')
"4.3 Lockfile Diff in CI
# .github/workflows/lockfile-check.yml
name: Lockfile Audit
on: pull_request
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for lockfile changes
run: |
LOCKFILES="package-lock.json yarn.lock pnpm-lock.yaml Cargo.lock requirements.txt poetry.lock"
for f in $LOCKFILES; do
if git diff --name-only origin/main...HEAD | grep -q "$f"; then
echo "::warning::Lockfile $f was modified -- review dependency changes carefully"
git diff origin/main...HEAD -- "$f" | head -100
fi
done
- name: Run npm audit
if: hashFiles('package-lock.json') != ''
run: npm audit --audit-level=high---
5. Package Pinning and Verification
5.1 pip Hash Checking
# requirements.txt with hashes (generated by pip-compile --generate-hashes)
<package>==<reviewed-version> \
--hash=sha256:<full-verified-artifact-hash># Install with mandatory hash verification
pip install --require-hashes -r requirements.txt… (nội dung đầy đủ có trong gói tải về)
Skill liên quan
- terraform-aws – Cấp phát hạ tầng AWS bằng Terraform. Tạo module, quản lý state và áp dụng thực hành tốt…
- terraform-aws-modules – Tạo module Terraform cho AWS — module tái sử dụng, quản lý state và thực hành tốt nhất…
- terraform-azure – Cấp phát hạ tầng Azure bằng Terraform. Cấu hình provider, quản lý state và triển khai…
- terraform-gcp – Cấp phát hạ tầng GCP bằng Terraform. Cấu hình provider và triển khai tài nguyên Google…
- terraform-infrastructure – Quy trình hạ tầng dưới dạng code với Terraform để cấp phát tài nguyên cloud, tạo module…
- terraform-module-library – Các mẫu module Terraform sẵn sàng cho production cho hạ tầng AWS, Azure và GCP.
- terraform-skill – Thực hành tốt nhất về hạ tầng dưới dạng code với Terraform
- terraform-specialist – Chuyên gia Terraform/OpenTofu, thành thạo tự động hóa IaC nâng cao, quản lý state và các…