Skillpedia
الوكلاء35k · #7884

detecting-typosquatting-packages-in-npm-pypi

ما الذي تفعله

تتحقق هذه المهارة من الحزم التي تحمل أسماء شديدة الشبه بحزم شهيرة في مستودعي npm وPyPI. تبحث عن أسماء تبدو كأخطاء كتابية أو تغييرات مقصودة صُممت لخداع المستخدمين.

متى تستخدمها

  • ✓عند مراجعة اعتماديات مشروعك للتأكد من أنه لا توجد حزمة «مزيفة».
  • ✓لمراقبة ما إذا كان أحد يحاول إنشاء حزمة «مزيفة» باسم شركتك.
  • ✓عندما تشك في أن مطورًا ثبّت حزمة خاطئة بالخطأ.

رابط المهارة

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

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/detecting-typosquatting-packages-in-npm-pypi/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“تحقق من وجود حزم بأسماء مشابهة لـ«react» في npm وPyPI.”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

تقارن هذه المهارة أسماء الحزم باستخدام مقاييس التشابه النصي، وتحلل تاريخ إنشائها وعدد التنزيلات. الحزم ذات الأسماء المتشابهة والمنشأة حديثًا وقليلة التنزيلات تُعلَّم بأنها مشبوهة.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

Detecting Typosquatting Packages in npm and PyPI

When to Use

  • Auditing project dependencies to identify packages whose names are suspiciously similar to popular libraries
  • Proactively scanning package registries for newly published packages that may be typosquats of your organization's packages
  • Investigating a suspected supply chain compromise where a developer installed a misspelled package name
  • Building automated monitoring that alerts when new packages appear with names close to critical dependencies
  • Assessing the risk profile of unfamiliar packages before adding them to a project's dependency tree

Do not use as the sole determination of malicious intent; name similarity alone does not prove a package is malicious. Do not use for bulk automated takedown requests without manual review of flagged packages. Do not use against private registries without authorization.

Prerequisites

  • Python 3.9+ with requests and python-Levenshtein (or rapidfuzz) packages installed
  • Network access to https://pypi.org/pypi/<package>/json (PyPI JSON API) and https://registry.npmjs.org/<package> (npm registry API)
  • A list of popular or critical packages to monitor (e.g., top 1000 PyPI packages, organization's dependency list)
  • Understanding of common typosquatting patterns: character omission, transposition, insertion, substitution, and hyphen/underscore manipulation

Workflow

Step 1: Build the Target Package Watchlist

Establish the set of legitimate packages to monitor for typosquats:

  • Extract project dependencies: Parse requirements.txt, Pipfile.lock, package.json, or package-lock.json to extract all direct and transitive dependency names
  • Include popular packages: Supplement with high-value targets from the top 1000 PyPI downloads (available from https://hugovk.github.io/top-pypi-packages/) or top npm packages by download count
  • Add organization packages: Include any packages published by your organization that attackers might target with typosquats to intercept internal installations
  • Normalize names: PyPI treats hyphens, underscores, and periods as equivalent (PEP 503 normalization: re.sub(r"[-_.]+", "-", name).lower()). npm package names are case-sensitive but scoped packages use @scope/name format. Normalize before comparison.

Step 2: Generate Candidate Typosquat Names

Produce potential typosquat variants for each target package:

  • Character omission: Remove each character one at a time (requests -> rquests, requets, reqests)
  • Character transposition: Swap adjacent characters (requests -> erquests, rqeuests, reques ts)
  • Character substitution: Replace characters with keyboard-adjacent keys using a QWERTY distance map (requests -> rrquests, requesta)
  • Character insertion: Insert common characters at each position (requests -> rrequests, reqquests)
  • Separator manipulation: For hyphenated names, try removing, doubling, or replacing separators (my-package -> mypackage, my--package, my_package)
  • Common prefix/suffix attacks: Prepend or append common strings (python-requests, requests-python, requests2, requests-lib)

Step 3: Query Registry APIs for Candidate Packages

Check whether generated candidate names actually exist in the registry:

  • PyPI JSON API: Send GET https://pypi.org/pypi/<candidate>/json for each candidate. A 200 response means the package exists; 404 means it does not. Extract from the response: info.name, info.version, info.author, info.summary, info.home_page, info.project_urls, and releases (keyed by version with upload_time_iso_8601 timestamps).
  • npm registry API: Send GET https://registry.npmjs.org/<candidate> with Accept: application/json. Extract: name, description, dist-tags.latest, time.created, time.modified, maintainers, and versions.
  • Rate limiting: PyPI has no published rate limits but respect reasonable request rates (1-2 requests/second). npm registry returns 429 when rate limited; implement exponential backoff.
  • Batch optimization: For large candidate lists, parallelize requests with connection pooling (requests.Session) and limit concurrency to avoid triggering abuse protections.

Step 4: Analyze Package Metadata for Suspicion Signals

Score each existing candidate package against multiple heuristic signals:

…

الأسئلة الشائعة

ما هو «typosquatting»؟

هو أن يسجّل شخص اسم نطاق أو حزمة شديدة الشبه باسم موجود، بهدف خداع الناس ليظنوا أنه الأصلي.

لماذا هذا خطير؟

قد تُستخدم الحزم الخبيثة لسرقة المعلومات أو إلحاق الضرر بالأنظمة أو نشر الفيروسات. وتثبيت حزمة «مزيفة» دون قصد قد يعرّض أمان مشروعك للخطر.

هل تضمن المهارة أن الحزمة خبيثة؟

لا، تعلّم المهارة الحزم المشبوهة بناءً على اسمها وبعض خصائصها فقط. ومن المهم المراجعة اليدوية قبل الحكم بأن الحزمة خطرة فعلًا.

التفاصيل

الوصف الأصلي من المؤلف

Detects typosquatting attacks in npm and PyPI package registries by analyzing package name similarity using Levenshtein distance and other string metrics, examining publish date heuristics to identify recently created packages mimicking established ones, and flagging download count anomalies where suspicious packages have disproportionately low usage compared to their legitimate targets. The analy

repo: mukul975/Anthropic-Cybersecurity-Skills

الشعبية

نجوم GitHub
35k
الترتيب
#7884
الترخيص
Apache-2.0
آخر تحديث
31‏/8‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة