本文へスキップ
Skillpedia
セキュリティ35k · #7821

detecting-dependency-confusion

できること

このツールは、「依存関係の混乱(dependency confusion)」と呼ばれる攻撃からソフトウェアプロジェクトを守るのに役立ちます。会社の社内パッケージと同じ名前のパッケージを攻撃者が公開のレジストリに登録して乗っ取れないかを確認します。

使う場面

  • ✓会社のセキュリティ対策を新しく始めるとき。
  • ✓ビルドシステムが公開と非公開の両方のパッケージソースを併用しているとき。
  • ✓社内パッケージ名が漏えいした可能性のあるセキュリティ事故の後。

スキルのリンク

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

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/detecting-dependency-confusion/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“私たちの社内パッケージに、依存関係の混乱攻撃を受ける危険がないか確認してください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

プロジェクトで使われている社内パッケージの名前をスキャンします。次に、公開レジストリを確認して、攻撃者が同じ名前のパッケージを公開できるかどうかを調べます。公開されていない社内名は、防御のために先に登録しておくことができます。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

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.

…

よくある質問

「依存関係の混乱」とは何ですか?

悪意のある攻撃者が、会社の社内パッケージと同じ名前の不正なパッケージを公開のレジストリに登録する攻撃です。会社のビルドシステムが(たとえばバージョン番号が高いという理由で)公開版を優先すると、不正なコードをダウンロードして実行してしまう可能性があります。

なぜこれが問題なのですか?

会社のシステム内で不正なコードが実行され、データやシステム、ソフトウェアのサプライチェーンが危険にさらされるおそれがあります。

このツールはどのようにして防ぐのですか?

公開レジストリに登録されておらず、そのため攻撃を受けやすい社内パッケージ名を特定します。また、同じ名前の公開パッケージが存在しても、常に正しい社内パッケージを使うようにツールの設定を行う手助けもします。

詳細

作者による元の説明

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

人気

GitHubのスター
35k
ランキング
#7821
ライセンス
Apache-2.0
更新日
2026/8/31

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル