Community编程与开发github.com

yaklang/dependency-confusion

通过包管理器依赖混淆进行供应链测试:当内部包名解析到攻击者控制的公共注册表时,会导致恶意安装和脚本执行。适用于 npm/pip/gem/Maven/Composer/Docker 的清单审查以及授权的红队供应链演练。

dependency-confusion 是什么?

`yaklang/dependency-confusion` 是一款专注于供应链安全的 AI 代理技能,用于检测和利用包管理器中的“依赖混淆”漏洞。该漏洞发生在企业使用私有包名(如公司内部库)但该名称在公共注册表(例如 npm、PyPI)上也可用时,攻击者可以注册同名恶意包,导致系统安装其恶意版本。本技能支持多种包管理器(npm、pip、gem、Maven、Composer、Docker),能够自动审查 `package.json`、`requirements.txt`、`Gemfile`、`pom.xml`、`composer.json` 等清单文件,识别出那些在公共注册表中可用且可能是危险的内部包名。其核心价值在于帮助红队或安全团队在授权演练中验证供应链攻击路径,从而提前发现并修复此类风险。该技能通常集成在 AI 编码代理(如 Claude Code、Cursor)中,通过自然语言指令即可触发依赖混淆检测,无需手动编写复杂脚本。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/yaklang/hack-skills/tree/main/skills/dependency-confusion

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

dependency-confusion 是做什么的?

通过包管理器依赖混淆进行供应链测试:当内部包名解析到攻击者控制的公共注册表时,会导致恶意安装和脚本执行。适用于 npm/pip/gem/Maven/Composer/Docker 的清单审查以及授权的红队供应链演练。

概述

依赖混淆是一种供应链攻击技术,其中攻击者在公共包注册表上注册与内部私有包同名的包。当包管理器安装依赖时,可能会错误地优先使用公共注册表中的恶意包,从而导致任意代码执行或数据泄露。该技能自动化了发现这种漏洞的过程。

支持的包管理器

包管理器清单文件注册表
npmpackage.jsonhttps://registry.npmjs.org
piprequirements.txt / setup.py / Pipfilehttps://pypi.org/simple
gemGemfilehttps://rubygems.org
Mavenpom.xmlhttps://repo.maven.apache.org/maven2
Composercomposer.jsonhttps://packagist.org
DockerDockerfileN/A (检查镜像来源)

使用示例

自动检测

  1. 提供包含依赖声明文件的目录路径。
  2. 技能将解析所有已安装的依赖。
  3. 对于每个依赖,它会在公共注册表中检查是否存在同名包。
  4. 若存在,则会发出警告,指出潜在的依赖混淆风险。

CLI 命令

# 扫描当前目录中的所有清单文件
yaklang dependency-confusion --scan .

# 指定特定文件
yaklang dependency-confusion --file package.json

# 显示详细 JSON 输出
yaklang dependency-confusion --scan . --json

工作原理

技能利用 yaklang 的包管理器和 HTTP 客户端 API 向包注册表发送查询。对于每个依赖项,它执行以下步骤:

  1. 解析清单:使用 yaml.Unmarshal 或 json.Unmarshal 解析依赖清单。
  2. 识别依赖:提取所有依赖项的名称和版本约束。
  3. 检查注册表:向公共注册表的搜索或获取端点发送 HTTP GET 请求(例如 https://registry.npmjs.org/{包名})。
  4. 比较结果:如果注册表返回 200 OK 状态,则该包存在于公共注册表中。
  5. 报告风险:输出结果,标记所有符合混淆条件的包。

安全注意事项

⚠️ 仅供授权测试使用。此技能用于在受控环境中执行授权的红队演练或安全评估。在未获得明确许可的生产系统上使用依赖混淆技术可能违反可接受使用政策。

始终确保您拥有测试范围内依赖项的合法权利。

自定义

您可以通过设置环境变量来调整行为:

  • DEPCONF_PRIVATE_REGISTRY:用于检查的私有注册表的 URL(默认为空,仅检查公共注册表)。
  • DEPCONF_TIMEOUT:HTTP 请求的超时时间(秒),默认为 10。
  • DEPCONF_IGNORE:要忽略的包名逗号分隔列表(例如,express, lodash)。

许可证

MIT

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

yaklang/401-403-bypass-techniques

401/403 bypass playbook. Use when encountering access-denied responses on admin panels, API endpoints, or restricted paths. Covers path manipulation, HTTP method tampering, header injection, protocol downgrade, and automated bypass tools.

yaklang/active-directory-acl-abuse

Active Directory ACL abuse playbook. Use when exploiting misconfigured AD permissions including GenericAll, WriteDACL, DCSync rights, shadow credentials, LAPS reading, GPO abuse, and BloodHound-guided attack paths.

yaklang/active-directory-certificate-services

AD Certificate Services attack playbook. Use when targeting misconfigured AD CS for privilege escalation via ESC1-ESC13 template abuse, NTLM relay to enrollment, CA officer abuse, and certificate-based persistence.

yaklang/active-directory-kerberos-attacks

Kerberos attack playbook for Active Directory. Use when targeting AD authentication via AS-REP roasting, Kerberoasting, golden/silver/diamond tickets, delegation abuse, or pass-the-ticket attacks.

yaklang/ai-ml-security

AI/ML security playbook. Use when assessing model supply chain attacks (pickle RCE, poisoned weights), adversarial examples, model poisoning, model stealing, data privacy attacks (membership inference, model inversion), and autonomous agent security risks.

yaklang/android-pentesting-tricks

Android pentesting playbook. Use when testing Android applications for SSL pinning bypass, exported component abuse, WebView vulnerabilities, intent redirection, root detection bypass, tapjacking, and backup extraction during authorized mobile security assessments.

yaklang/anti-debugging-techniques

Anti-debugging detection and bypass playbook. Use when reversing protected binaries that detect debuggers via ptrace, PEB flags, timing checks, or signal/exception handlers on Linux and Windows.

yaklang/api-auth-and-jwt-abuse

API authentication and JWT abuse playbook. Use when testing bearer tokens, API keys, claim trust, header spoofing, rate limits, and API auth boundary weaknesses.

yaklang/api-authorization-and-bola

API authorization and BOLA testing playbook. Use when APIs expose object identifiers, nested resources, hidden writable fields, or weak function-level authorization.

yaklang/api-recon-and-docs

API reconnaissance and documentation review playbook. Use when discovering endpoints, schemas, versions, OpenAPI specs, hidden docs, and surface area for API testing.

yaklang/api-sec

Entry P1 category router for API security. Use when choosing between API recon, authorization, token abuse, and hidden-parameter workflows before any deeper API topic skill.

yaklang/arbitrary-write-to-rce

Arbitrary write to RCE playbook. Use when you have an arbitrary write primitive (from heap exploitation, format string, or OOB write) and need to convert it into code execution by targeting GOT, hooks, _IO_FILE vtable, exit_funcs, TLS_dtor_list, modprobe_path, .fini_array, or C++ vtables.

yaklang/authbypass-authentication-flaws

Authentication bypass testing playbook. Use when assessing login flows, password reset logic, account recovery, MFA bypass, token predictability, brute-force resistance, and session boundary flaws.

yaklang/auth-sec

Entry P1 category router for authentication and authorization. Use when testing login flows, sessions, object authorization, JWT, OAuth, CORS, CSRF, and enterprise SSO weaknesses before any deeper auth topic skill.

yaklang/binary-protection-bypass

Binary protection bypass playbook. Use when identifying and bypassing ASLR, PIE, NX/DEP, stack canary, RELRO, FORTIFY_SOURCE, CET, and MTE protections in ELF binaries to enable exploitation.

yaklang/browser-exploitation-v8

Browser and V8 exploitation playbook. Use when exploiting JavaScript engine vulnerabilities including JIT type confusion, incorrect bounds elimination, and V8 sandbox bypass to achieve renderer RCE and sandbox escape in Chrome/Chromium.

yaklang/business-logic-vuln

Entry P1 category router for business logic testing. Use when workflow abuse, race conditions, pricing flaws, or multi-step state attacks matter more than parser-level input injection.

yaklang/business-logic-vulnerabilities

Business logic vulnerability playbook. Use when reasoning about workflows, race conditions, price manipulation, coupon abuse, state machines, and multi-step authorization gaps.

yaklang/classical-cipher-analysis

Classical cipher analysis playbook. Use when encountering substitution ciphers, Vigenere, transposition, XOR, or encoded text in CTF challenges that requires frequency analysis, Kasiski examination, or known-plaintext cryptanalysis.

yaklang/clickjacking

Clickjacking playbook. Use when testing whether target pages can be framed, whether X-Frame-Options or CSP frame-ancestors are properly configured, and whether UI redress attacks can trigger sensitive actions.

相关技能