Chuyển đến nội dung
Skillpedia
Bảo mật35k · #7821

detecting-dependency-confusion

Skill này làm gì

Công cụ này giúp bảo vệ dự án phần mềm của bạn khỏi một cuộc tấn công gọi là “dependency confusion”. Nó kiểm tra xem các gói nội bộ mà công ty bạn dùng có thể bị kẻ tấn công “chiếm” bằng cách đăng gói cùng tên lên kho công khai hay không.

Khi nào nên dùng

  • ✓Khi bắt đầu một sáng kiến bảo mật mới cho công ty.
  • ✓Khi hệ thống build của bạn dùng cả nguồn gói công khai và riêng tư.
  • ✓Sau một sự cố bảo mật mà tên gói nội bộ có thể đã bị lộ.

Liên kết skill

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/detecting-dependency-confusion/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/detecting-dependency-confusion/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Kiểm tra xem có gói nội bộ nào của chúng tôi dễ bị tấn công dependency confusion không.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ quét tên các gói nội bộ được dùng trong dự án. Sau đó, nó kiểm tra kho gói công khai để xem kẻ tấn công có thể đăng gói cùng tên không. Nếu tên nội bộ chưa được đăng ký công khai, nó có thể được “giữ chỗ” để phòng ngừa.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Detecting Dependency Confusion

Legal Notice: This skill is for authorized security testing, defensive engineering, and educational purposes only. Registering or claiming package namespaces you do not own, or testing build pipelines without written authorization, may be illegal and may violate the terms of service of public registries. Only run namespace-claiming or resolution-testing activities against names and infrastructure you control or are explicitly authorized to assess.

Overview

Dependency confusion (also called a substitution or namespace-shadowing attack) was popularized by Alex Birsan in 2021 when he forced malicious code into the internal build systems of Apple, Microsoft, PayPal, and dozens of others. The root cause is that many package managers, when configured to resolve from both an internal/private registry and a public one, will prefer whichever copy has the higher version number rather than honoring the source. An attacker who learns the name of a private package (@acme/internal-utils, acme-billing-sdk) can publish a malicious package of the same name to the public registry (npmjs.com, PyPI, Maven Central) with a very high version (e.g. 99.0.0). When the victim's CI/CD runner or a developer machine resolves dependencies, it pulls the attacker's public package, executes its install scripts, and the supply chain is compromised.

This skill covers both halves of the problem: detection — enumerating internal package names that are not registered (squatted defensively) on public registries and are therefore claimable, using confused and OWASP dep-scan — and prevention — pinning scopes/namespaces to private registries, registering placeholder packages, and enforcing source restrictions in .npmrc, pip.conf/pyproject.toml, and Maven settings.xml. Internal package names leak constantly: in committed lockfiles, sourcemaps, public JS bundles, Docker layers, and error stack traces, so this is treated as an attack-surface management problem, not a one-time check.

When to Use

  • When onboarding a repository or organization to a supply-chain security program and you need to baseline which internal packages are claimable on public registries.
  • When CI/CD pipelines resolve dependencies from both private and public registries (mixed/hybrid feeds).
  • After any incident where internal package names may have been exposed (leaked source, public bundle, breached repo).
  • When auditing package.json, requirements.txt, pom.xml, composer.json, or Gemfile.lock files for confusable dependencies.
  • As a recurring scheduled control to detect newly added internal packages that have not yet been defensively registered.

Prerequisites

  • Go 1.20+ to install confused:
    go install github.com/visma-prodsec/confused@latest
    # binary lands in $(go env GOPATH)/bin/confused
    
  • Python 3.10+ for OWASP dep-scan:
    pip install owasp-depscan
    # or container: docker pull ghcr.io/owasp-dep-scan/dep-scan
    
  • Node.js + npm (for .npmrc and npm config remediation) and access to your private registry (Artifactory, Nexus, Azure Artifacts, GitHub Packages, AWS CodeArtifact).
  • Read access to the repositories / lockfiles being assessed and write access to your private registry for defensive registration.

Objectives

  • Enumerate every internal dependency declared in project manifests across npm, PyPI, Maven, Composer, and RubyGems.
  • Determine which internal names are not present on the corresponding public registry and are therefore claimable.
  • Distinguish true exposure from false positives (scoped packages, already-mirrored names).
  • Apply registry-pinning and scope-restriction controls that make public substitution impossible.
  • Defensively register placeholder packages for unclaimed internal names.
  • Establish a recurring detection control in CI to catch newly introduced confusable dependencies.

MITRE ATT&CK Mapping

Technique ID Technique Name Relevance
T1195.001 Supply Chain Compromise: Compromise Software Dependencies and Development Tools Core technique — attacker substitutes a malicious public package for an internal dependency.
T1195.002 Supply Chain Compromise: Compromise Software Supply Chain Broader category covering the compromised build artifacts produced once confusion succeeds.

…

Câu hỏi thường gặp

“Dependency confusion” là gì?

Đây là cuộc tấn công trong đó kẻ xấu đăng một gói độc hại cùng tên với gói nội bộ của công ty lên kho công khai. Nếu hệ thống build của công ty ưu tiên phiên bản công khai (ví dụ vì nó có số phiên bản cao hơn), nó sẽ tải về và chạy mã độc.

Vì sao đây là vấn đề?

Nó có thể dẫn đến việc thực thi mã độc trong hệ thống công ty, làm ảnh hưởng dữ liệu, hệ thống và chuỗi cung ứng phần mềm.

Công cụ bảo vệ khỏi điều này bằng cách nào?

Nó xác định các tên gói nội bộ chưa đăng ký công khai và do đó dễ bị tấn công. Nó cũng giúp cấu hình các công cụ luôn dùng đúng gói nội bộ, ngay cả khi có gói công khai trùng tên.

Chi tiết

Mô tả gốc của tác giả

Detect and prevent dependency confusion (public-over-private package name resolution) in npm, PyPI, and Maven by enumerating claimable internal package names with tools like `confused` and OWASP `dep-scan`, then enforcing source restrictions via `.npmrc`, `pip.conf`/`pyproject.toml`, and Maven `settings.xml`. Use when onboarding a repo to a supply-chain security program, auditing lockfiles/manifes

repo: mukul975/Anthropic-Cybersecurity-Skills

Độ phổ biến

Sao GitHub
35k
Vị trí xếp hạng
#7821
Giấy phép
Apache-2.0
Cập nhật
31/8/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự