मुख्य सामग्री पर जाएँ
Skillpedia
एजेंट35k · #7845

detecting-malicious-npm-packages

यह क्या करती है

यह टूल जांचता है कि प्रोग्रामिंग के लिए बने सॉफ़्टवेयर पैकेज (जिन्हें 'npm packages' कहा जाता है) में कोई हानिकारक कोड तो नहीं है। यह ऐसे प्रोग्राम ढूंढता है जो जानकारी चुराते हैं, खुद को फैलाते हैं या बिना मर्ज़ी के काम करते हैं।

कब इस्तेमाल करें

  • ✓अपने प्रोजेक्ट में कोई नया सॉफ़्टवेयर पैकेज जोड़ते समय।
  • ✓किसी और के कोड की समीक्षा करते समय, ताकि कोई जोखिम न हो।
  • ✓जब किसी पहले से इस्तेमाल हो रहे पैकेज के खतरनाक वर्ज़न की चेतावनी मिले।

Skill का लिंक

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/detecting-malicious-npm-packages/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/detecting-malicious-npm-packages/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“'expresss' पैकेज में मैलिशियस कोड है या नहीं, यह जांचो।”

हर हफ़्ते 5 नई skills, 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 install runs 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.json during 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-scripts when 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.

…

अक्सर पूछे जाने वाले सवाल

पैकेज इंस्टॉल करना खतरनाक क्यों हो सकता है?

कुछ पैकेज इंस्टॉल होते समय अपने आप कोड चलाते हैं, जिससे आपका मुख्य प्रोग्राम शुरू होने से पहले ही पासवर्ड या एक्सेस की (access keys) चोरी हो सकती है।

'install scripts' क्या होते हैं?

ये छोटे प्रोग्राम हैं जो किसी पैकेज के इंस्टॉल होने पर चलते हैं। हानिकारक पैकेज इन्हीं स्क्रिप्ट का इस्तेमाल बुरे काम के लिए कर सकते हैं।

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

repo: mukul975/Anthropic-Cybersecurity-Skills

लोकप्रियता

GitHub स्टार
35k
रैंकिंग में स्थान
#7845
लाइसेंस
Apache-2.0
अपडेट की गई
31/8/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills