abhayclasher/CVE-2026-39866

GitHub: abhayclasher/CVE-2026-39866

这是一个针对 CVE-2026-39866 的概念验证实验室,用于演示和复现 GitHub Actions 工作流中因未加引号输入导致的命令注入漏洞。

Stars: 0 | Forks: 0

# CVE-2026-39866 — 通过未加引号的 workflow dispatch 输入实现命令注入

CVE GHSA CWE-78 Patched

GitHub Actions workflow dispatch 命令注入的概念验证实验室

## 目的 CVE-2026-39866 是 Lawnchair 的 GitHub Actions 发布工作流中的一个命令注入漏洞。`release_update.yml` 文件将用户输入直接传递给 bash 而未加引号,因此攻击者可以注入命令。此仓库同时运行易受攻击和已修补的版本。 ## 快速概览 | 字段 | 值 | |-------|-------| | CVE ID | [CVE-2026-39866](https://nvd.nist.gov/vuln/detail/CVE-2026-39866) | | GHSA | [GHSA-9prc-pp2c-3427](https://github.com/LawnchairLauncher/lawnchair/security/advisories/GHSA-9prc-pp2c-3427) | | CWE | [CWE-78](https://cwe.mitre.org/data/definitions/78.html) (对 OS 命令中使用的特殊元素的过滤不恰当) | | 产品 | [LawnchairLauncher/lawnchair](https://github.com/LawnchairLauncher/lawnchair) | | 受影响版本 | fcba413 以下的所有版本 | | 已修复版本 | fcba413 | | 发现者 | [Abhay Kumar (@abhayclasher)](https://github.com/abhayclasher) | ## 漏洞详情 该漏洞存在于 `release_update.yml` 工作流文件中。该操作接收一个 `artifactName` 参数,并将其直接传递给 bash 命令而未加引号。 ``` - name: Rename artifact run: mv ${{ inputs.artifactName }}.zip lawnchair.zip ``` GitHub Actions 在 shell 运行命令之前将变量值替换到字符串中。由于 `${{ inputs.artifactName }}` 周围没有引号,shell 会将空格和分号解释为命令分隔符。 如果攻击者提供 `file.zip; touch pwned.txt #` 作为 `artifactName`: **GitHub Actions 解析方式:** `${{ inputs.artifactName }}` → `file.zip; touch pwned.txt #` **Shell 执行方式:** ``` mv file.zip; touch pwned.txt #.zip lawnchair.zip ``` Shell 执行 `mv file.zip`,然后执行 `touch pwned.txt`,并将其余部分作为注释忽略。 ## 影响 - 在 GitHub Actions runner 上执行任意命令。 - 窃取暴露给 runner 环境的仓库密钥(如 `GITHUB_TOKEN` 或发布签名密钥)。 - 在发布工件上传之前对其进行篡改。 - 如果 runner 是自托管的,则转向连接的基础设施。 ## 系统要求 - Node.js 18 或更高版本 - Docker(可选,用于容器化实验室) - 500 MB 可用磁盘空间 ## 设置 ### 选项 1:直接运行 ``` git clone https://github.com/abhayclasher/CVE-2026-39866.git cd CVE-2026-39866/app npm install node server.js ``` ### 选项 2:使用 Docker 运行 ``` git clone https://github.com/abhayclasher/CVE-2026-39866.git cd CVE-2026-39866 docker compose up -d ``` ## 使用方法 服务器启动后,访问以下 URL: | URL | 描述 | |-----|-------------| | `http://localhost:3000/workflow/vulnerable` | 易受攻击的工作流 — 提交时执行命令注入 | | `http://localhost:3001/workflow/patched` | 应用了 fcba413 补丁的相同工作流 | 易受攻击的版本将在 runner 上执行你注入的命令。已修补的版本会将输入视为字面量字符串。 你也可以运行独立的 PoC: ``` cd poc node exploit.js ``` 这会在 3000 端口启动一个最小的服务器,在没有完整应用上下文的情况下演示相同的漏洞。 ## 工作原理 ### 检测流程 ``` 1. Attacker controls the artifactName input parameter 2. GitHub Actions expands ${{ inputs.artifactName }} into the YAML 3. The run step sends this to bash 4. Bash sees unquoted special characters and treats them as command syntax 5. Commands execute with runner environment privileges ``` ### 攻击链 ``` ┌────────────────────────────────────────────────────┐ │ 1. Malicious input: │ │ │ │ artifactName = "file.zip; id #" │ │ │ │ 2. GitHub Actions substitutes into YAML: │ │ │ │ run: mv file.zip; id #.zip lawnchair.zip │ │ │ │ 3. Bash sees: │ │ - mv file.zip │ │ - id <-- Arbitrary command │ │ - #.zip lawnchair.zip (ignored) │ │ │ │ 4. Shell executes arbitrary command │ └────────────────────────────────────────────────────┘ ``` ## 修复方案 fcba413 版本在插值变量周围添加了引号: ``` - name: Rename artifact run: mv "${{ inputs.artifactName }}.zip" lawnchair.zip ``` 引号防止 shell 解析特殊字符。payload 将被视为字面量文件名字符串。 最佳实践是使用环境变量来完全隔离用户输入: ``` - name: Rename artifact env: ARTIFACT_NAME: ${{ inputs.artifactName }} run: mv "$ARTIFACT_NAME.zip" lawnchair.zip ``` 查看完整提交:[fcba413](https://github.com/LawnchairLauncher/lawnchair/commit/fcba413) ## 项目结构 ``` CVE-2026-39866/ ├── README.md # This file ├── docker-compose.yml # Docker lab configuration ├── app/ │ ├── Dockerfile # Container build configuration │ ├── package.json # Node.js dependencies │ └── server.js # Vulnerable + patched workflow runner simulation └── poc/ └── exploit.js # Standalone minimal proof-of-concept ``` ## 参考资料 - [NVD — CVE-2026-39866](https://nvd.nist.gov/vuln/detail/CVE-2026-39866) - [GitHub Security Advisory](https://github.com/LawnchairLauncher/lawnchair/security/advisories/GHSA-9prc-pp2c-3427) - [Patch Commit](https://github.com/LawnchairLauncher/lawnchair/commit/fcba413) - [CWE-78](https://cwe.mitre.org/data/definitions/78.html) 由 [**Abhay Kumar**](https://github.com/abhayclasher) 报告。此仓库仅用于本地教育目的。请勿将易受攻击的服务器部署在公共网络上。

仅供教育目的 — 请在隔离环境中使用

标签:Bash, Command Injection, CVE-2026-39866, CWE-78, DevSecOps, GHSA-9prc-pp2c-3427, GitHub Actions, Go语言工具, Lawnchair, MITM代理, OS命令注入, Proof of Concept, RCE, 上游代理, 命令注入, 安全漏洞, 工作流, 引号绕过, 数据可视化, 未过滤输入, 概念验证, 漏洞分析, 漏洞复现, 编程工具, 自动化运维, 自动笔记, 自定义脚本, 请求拦截, 路径探测, 远程代码执行