detecting-malicious-npm-packages
하는 일
이 도구는 프로그래밍에 쓰이는 소프트웨어 패키지('npm 패키지')에 악성 코드가 들어 있는지 확인하도록 돕습니다. 정보를 훔치거나, 스스로 퍼지거나, 원치 않는 행동을 하는 프로그램을 찾습니다.
사용하는 경우
- ✓프로젝트에 새 소프트웨어 패키지를 추가할 때.
- ✓다른 사람의 코드를 검토해 위험이 없는지 확인할 때.
- ✓이미 사용 중인 패키지의 위험한 버전에 대한 경고를 받은 경우.
스킬 링크
https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/detecting-malicious-npm-packages/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“'expresss' 패키지에 악성 코드가 있는지 확인해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
도구는 GuardDog이라는 스캐너를 사용해 패키지 코드를 실행하지 않고 분석합니다. 안전한 환경에서 패키지를 설치하는 것을 시뮬레이션해 동작을 관찰할 수도 있습니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Detecting Malicious npm Packages
Legal Notice: Analyze packages in an isolated, disposable environment. Some malicious packages execute on install (
npm installruns lifecycle scripts automatically) or on import. Never analyze a suspect package on a workstation with credentials, SSH keys, cloud tokens, or network access to production. This skill is for defensive analysis and authorized incident response only.
Overview
The npm registry is the largest software package ecosystem in the world and the most heavily targeted by supply-chain attackers. Malicious packages reach victims through typosquatting (expresss, crossenv), dependency confusion, account/maintainer takeover (the 2025 Shai-Hulud worm and the event-stream compromise are canonical examples), and starjacking. The defining danger of npm is that npm install automatically runs preinstall, install, and postinstall lifecycle scripts with the developer's full privileges before any application code is invoked — so simply installing a package is enough to be compromised. Roughly 2% of npm packages use install scripts, which makes them both common and a powerful malware delivery vehicle.
Typical malicious behaviors are: exfiltrating environment variables, ~/.npmrc tokens, SSH keys, and cloud credentials to an attacker-controlled URL; opening reverse shells; dropping cryptominers; reading and posting process.env; obfuscating payloads with base64/eval; and self-propagating (worming) by stealing the maintainer's npm token and republishing trojanized versions of other packages they own.
This skill provides a repeatable triage workflow centered on GuardDog (Datadog's open-source heuristic scanner built on Semgrep + metadata rules), supplemented by manual tarball inspection, lockfile-based compromise checks against known-bad version lists, and dynamic detonation with network and filesystem monitoring. The goal is to decide, quickly and safely, whether a given package or a project's dependency tree contains malicious code.
When to Use
- Triaging a specific npm package before adding it as a dependency.
- Vetting a full
package.json/package-lock.jsonduring code review or onboarding a third-party library. - Responding to a supply-chain advisory (e.g., a worm campaign) and needing to check whether your lockfiles pulled a known-bad version.
- Investigating an endpoint or CI runner suspected of having installed a trojanized package.
- Building a pre-install gate in CI/CD that blocks packages exhibiting malicious indicators.
Prerequisites
- An isolated VM or disposable container with no production credentials and snapshot/rollback capability.
- GuardDog:
pip install guarddog # or run via Docker without local install: docker pull ghcr.io/datadog/guarddog alias guarddog='docker run --rm ghcr.io/datadog/guarddog' - Node.js + npm (use
--ignore-scriptswhen downloading for analysis). jq,tar, and optionally OSV-Scanner for known-vulnerability/known-malicious cross-checks:go install github.com/google/osv-scanner/cmd/osv-scanner@v1- For dynamic analysis: a sandbox with egress logging (e.g.,
tcpdump, a DNS sink, or a network namespace).
Objectives
- Statically scan an npm package (or a whole dependency tree) for malicious heuristics without executing it.
- Identify install-script abuse, environment/credential exfiltration, obfuscation, and silent process execution.
- Cross-check lockfile-pinned versions against known-malicious version lists / OSV.
- Safely detonate a suspect package and observe network and filesystem behavior.
- Extract indicators of compromise (URLs, IPs, hashes) for blocking and threat intel.
- Produce a defensible verdict (benign / suspicious / malicious) with evidence.
MITRE ATT&CK Mapping
| Technique ID | Technique Name | Relevance |
|---|---|---|
| T1195.002 | Supply Chain Compromise: Compromise Software Supply Chain | Core technique — trojanized npm package delivered through the registry. |
| T1059.007 | Command and Scripting Interpreter: JavaScript | Malicious install scripts / module code execute attacker JavaScript. |
| T1552.001 | Unsecured Credentials: Credentials In Files | Packages steal ~/.npmrc, .env, SSH keys, and cloud credential files. |
| T1041 | Exfiltration Over C2 Channel | Stolen secrets posted to attacker HTTP(S) endpoints. |
…
자주 묻는 질문
패키지 설치가 왜 위험할 수 있나요?
일부 패키지는 설치 중에 자동으로 코드를 실행합니다. 이때 메인 프로그램이 시작되기도 전에 비밀번호나 액세스 키를 훔칠 수 있습니다.
'설치 스크립트'란 무엇인가요?
패키지가 설치될 때 실행되는 작은 프로그램입니다. 악성 패키지는 이 스크립트를 사용해 나쁜 일을 할 수 있습니다.
'GuardDog'이란 무엇인가요?
코드에서 의심스럽거나 악의적인 패턴을 분석해 위험한 패키지를 식별하도록 돕는 보안 프로그램입니다.
상세 정보
작성자의 원본 설명
Triage npm packages and lockfiles for install-script malware, credential exfiltration, and worming behavior using GuardDog, manual tarball inspection, and dynamic detonation with network/filesystem monitoring. Use when vetting a new dependency, reviewing a package.json/package-lock.json during code review, checking lockfiles against a supply-chain advisory's known-bad versions, or investigating a
인기도
- GitHub 스타
- 35k
- 순위
- #7845
- 라이선스
- Apache-2.0
- 업데이트
- 2026. 8. 31.
댓글
- …
이 저장소의 다른 스킬
abusing-dpapi-for-credential-access
35kAI 에이전트에게 특정 작업을 위한 준비된 지침을 제공해, 더 잘하고 더 빠르게 처리하도록 합니다.
abusing-shadow-credentials-for-privesc
35kAI 에이전트가 명확하고 잘 구성된 텍스트를 쓰도록 가르칩니다.
achieving-cmmc-level-2-compliance
35kCMMC Level 2 규정 준수를 위한 환경을 준비하도록 돕습니다. 보안 요구 사항을 구현하고 필요한 문서를 관리합니다.
acquiring-disk-image-with-dd-and-dcfldd
35k에이전트가 하드 드라이브의 정확한 복사본을 만들도록 돕습니다. 조사 중 정보가 손실되거나 변경되지 않도록 하는 데 유용합니다.
비슷한 스킬
add-model-provider
394k에이전트가 안전한 설정 명령으로 새 AI 모델 제공자를 OpenClaw에 연결하고, API 키를 평문으로 두지 않으며, 실시간 테스트를 실행하도록 돕습니다.
acp-router
394k에이전트가 OpenClaw를 통해 Claude Code나 Cursor 같은 코딩 도우미에 작업을 전달해, 작업이 그 도구에서 실행되도록 돕습니다.
browser-automation
394k에이전트가 로그인, 탭, 페이지 응답이 멈췄을 때의 복구를 포함해 웹 페이지를 단계별로 조작하도록 가르칩니다.