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.mdSao 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
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
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, orGemfile.lockfiles 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
.npmrcandnpm configremediation) 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
Độ 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
Bình luận
- …
Thêm skill từ kho mã này
abusing-dpapi-for-credential-access
35kCung cấp cho agent AI của bạn hướng dẫn có sẵn cho một tác vụ cụ thể, giúp nó làm việc tốt hơn và nhanh hơn.
abusing-shadow-credentials-for-privesc
35kDạy agent AI của bạn viết văn bản rõ ràng và có cấu trúc tốt.
achieving-cmmc-level-2-compliance
35kGiúp agent của bạn chuẩn bị môi trường để tuân thủ CMMC Level 2. Triển khai các yêu cầu bảo mật và quản lý tài liệu cần thiết.
acquiring-disk-image-with-dd-and-dcfldd
35kGiúp agent của bạn tạo bản sao chính xác của ổ đĩa. Cách này đảm bảo không mất hay thay đổi thông tin trong quá trình điều tra.
Skill tương tự
reverse-engineer-anything
422kGiúp agent của bạn xem bên trong các app và package đã phát hành để giải thích tính năng, so sánh phiên bản hoặc hướng dẫn dựng lại bằng công cụ REA.
1password
394kGiúp agent của bạn cài đặt CLI của 1Password, đăng nhập, và đọc hoặc đưa thông tin bí mật vào mà không in giá trị ra cuộc trò chuyện.
healthcheck
394kGiúp agent của bạn rà soát bảo mật máy tính hoặc máy chủ đang chạy OpenClaw, như SSH, tường lửa, cập nhật và sao lưu, rồi đề xuất cách sửa an toàn.