
Defending Against Local File Inclusion (LFI) And Directory Traversal Exploits
November 7, 2026A supply chain attack that began with a compromised CI/CD runner cost one Fortune 500 firm an estimated $45 million in incident response costs and regulatory fines in 2025 — not from a sophisticated zero-day exploit, but from a misconfigured self-hosted GitHub Actions runner with excessive IAM permissions running directly on a production VPC subnet. The attacker pivoted from the runner to cloud credential theft within eleven minutes of initial access. This is the threat model that keeps cloud security architects awake: the build system itself becoming the breach vector.
Self-hosted CI/CD runners — whether GitHub Actions, GitLab Runners, Buildkite agents, or Jenkins nodes — are uniquely dangerous assets. They sit at the intersection of trusted code, cloud credentials, secrets stores, and network access. They often carry elevated permissions by operational necessity, yet they receive a fraction of the security scrutiny applied to production workloads. As organizations accelerate DevOps cadences, the attack surface expands in direct proportion to the number of runners deployed, the breadth of their permissions, and the absence of compensating controls around them.
This guide addresses the full hardening lifecycle: architectural isolation, identity and access discipline, secrets hygiene, runtime behavioral controls, and continuous monitoring. Each layer corresponds to a real attack class. Miss one, and your build pipeline becomes a highway into your most sensitive cloud environments.
Understanding the Threat Landscape for CI/CD Runners
The 2025 Verizon Data Breach Investigations Report cited CI/CD pipeline compromise as a contributing factor in 18% of cloud-origin breaches — a figure that doubled from 2023. The attack taxonomy has matured considerably: threat actors now specifically enumerate public repositories for self-hosted runner indicators, probe runner ephemeral environments for credential leakage, and weaponize dependency confusion to execute code in build contexts. The SolarWinds and 3CX supply chain incidents illustrated the downstream damage that originates at the build layer; more recent campaigns show attackers operationalizing this insight at scale.
Primary Attack Vectors Against Runners
Understanding what attackers actually target clarifies where hardening investment yields the highest return:
- Persistent runner compromise: Non-ephemeral runners accumulate state. Malware planted in one job’s workspace may persist across subsequent jobs from different repositories.
- Secrets extraction via environment variable enumeration: Runners frequently have access to CI secrets injected as environment variables. An injected build step — via a malicious pull request or poisoned dependency — can exfiltrate these trivially.
- IMDS credential harvesting: On cloud VMs, the Instance Metadata Service (IMDS) is accessible by default on 169.254.169.254. Any code executing on a runner can query IMDS and obtain the instance’s attached IAM role credentials.
- Lateral movement via runner’s network position: Runners deployed on internal subnets with broad egress rules can function as jump hosts into databases, Kubernetes API servers, or private S3 endpoints.
- Fork pull request exploitation: GitHub Actions workflows triggered by
pull_request_targetevents can expose secrets to untrusted code from forked repositories — a well-documented misconfiguration that continues to appear in enterprise repositories.
The “Trusted Insider” Problem
Runners are implicitly trusted by design. Build orchestration systems hand them secrets, they communicate with artifact registries, they deploy to staging and sometimes production environments. This trust is structurally necessary — and structurally exploitable. The hardening discipline is not about eliminating runner trust but about scoping it precisely, verifying it continuously, and containing the blast radius when it is abused.
Architectural Isolation: Building the Security Foundation
Architecture is the highest-leverage layer of runner security. Controls implemented at the network and compute architecture level are the hardest for attackers to bypass and the least dependent on operational discipline to maintain. A 2024 Wiz Research analysis of misconfigured cloud CI environments found that 67% of compromised runner incidents involved runners with direct internet ingress or unrestricted east-west traffic within a VPC — both architectural failures, not configuration mistakes.
Network Segmentation and Egress Control
Runners should reside in dedicated subnets — isolated from both production workloads and development environments. The principle is defense in depth through blast radius containment: if a runner is compromised, the attacker’s ability to traverse the network should be severely limited before they ever reach a valuable target.
- Dedicated runner subnet: Create a purpose-built subnet (e.g.,
10.0.100.0/24) with no inbound routes from the internet. Runners pull jobs from the CI orchestrator; they should never accept inbound connections. - Strict egress allowlisting: Define explicit allow-list rules for outbound traffic: CI orchestrator endpoints, artifact registries (Nexus, Artifactory, ECR), package mirrors, and your secrets manager. Block all other egress at the security group and network ACL layer.
- IMDS v2 enforcement: On AWS, enforce IMDSv2 (session-oriented requests with token-based authentication) on all runner instances. Set
HttpPutResponseHopLimitto 1 to prevent containerized workloads from reaching the IMDS. Azure and GCP have analogous metadata service hardening options. - VPC endpoint routing: Route traffic to AWS services (S3, Secrets Manager, ECR) through VPC endpoints, eliminating the need for internet gateway routes entirely.
Ephemeral Runner Architecture
The single most impactful architectural decision for runner security is enforcing ephemerality. Each job should execute on a fresh runner instance that is provisioned immediately before the job and terminated immediately after. This eliminates persistent compromise, cross-job workspace contamination, and the accumulation of sensitive state on long-lived hosts.
Implementation patterns include AWS EC2 Auto Scaling groups triggered by job queue depth, Kubernetes-based runners using the GitHub Actions Runner Controller (ARC) or GitLab’s Kubernetes executor, and container-based runners on AWS Fargate or Google Cloud Run. The Kubernetes model is particularly compelling: each job executes in an isolated pod, the pod terminates on job completion, and the underlying node can be periodically recycled to clear any node-level persistence. Organizations using ephemeral Kubernetes runners report a near-zero rate of cross-job contamination incidents compared to persistent VM fleets.
Identity, Permissions, and Secrets Discipline
The 2025 Cloud Security Alliance report on DevOps security found that 71% of CI/CD-related cloud breaches involved credentials with significantly broader permissions than the pipeline actually required. Overprivileged runners are the norm, not the exception, because developers provision runner permissions once at setup and rarely revisit them as the runner’s responsibilities evolve — or shrink.
Least-Privilege IAM for Runner Identities
Every runner needs an identity — an IAM role on AWS, a service account on GCP, a managed identity on Azure. That identity should be scoped to the minimum permissions necessary for the specific pipeline it serves, not for the broadest pipeline in the organization.
- Per-pipeline IAM roles: Avoid shared runner roles. A runner serving the front-end build pipeline should not carry permissions to push container images to the backend’s ECR repository. Terraform modules or CDK constructs can codify role boundaries and make them auditable.
- Short-lived credentials via OIDC federation: GitHub Actions, GitLab CI, and Buildkite all support OIDC token exchange — the runner presents a short-lived OIDC token to your cloud provider’s STS, which issues temporary credentials scoped to the specific repository and branch. This eliminates long-lived secrets from the runner environment entirely. Configure AWS IAM trust policies to validate the
subclaim (e.g.,repo:org/repo:ref:refs/heads/main) so that credentials issued for a main branch build cannot be claimed by a fork or feature branch. - Permission boundaries: Attach IAM permission boundaries to all runner roles. Even if a misconfiguration or attack succeeds in modifying the role’s policies, the permission boundary acts as a ceiling that cannot be exceeded.
Secrets Management and Injection Hygiene
Secrets stored as CI environment variables are the low-hanging fruit of runner compromise. The correct architecture routes secrets through a dedicated secrets manager — AWS Secrets Manager, HashiCorp Vault, Azure Key Vault — and injects them into the build environment only at the moment of use, never persisting them on disk or in environment variable dumps.
Practical controls include: masking secrets in CI log output (available natively in GitHub Actions and GitLab CI), auditing which jobs have access to which secret scopes, rotating all secrets on a defined schedule with automatic propagation, and scanning build logs retroactively for secret patterns using tools like TruffleHog or Gitleaks integrated into the pipeline itself. Never allow secrets access in workflows triggered by external pull requests — scope secret availability to protected branches and trusted actors only.
Runtime Security Controls and Host Hardening
Even within a well-architected environment, the runner’s operating system and runtime configuration represent an attack surface that requires active hardening. The 2024 NIST SP 800-218A (Secure Software Development Framework) explicitly calls out build environment integrity as a first-class security requirement for software supply chain assurance.
OS and Container Hardening Baseline
For VM-based runners, apply a CIS Benchmark hardened image as the base. Key configurations include:
- Disable SSH password authentication; use instance connect or SSM Session Manager for administrative access, eliminating the need for SSH port exposure entirely.
- Enable and configure auditd to log file system changes, privilege escalations, and network socket creation.
- Remove unnecessary packages and services — a build runner does not need a web server, mail daemon, or graphical interface.
- Apply kernel hardening parameters: set
kernel.dmesg_restrict=1,net.ipv4.conf.all.rp_filter=1, and enable seccomp profile enforcement. - Mount the workspace directory with
noexecwhere possible, or use separate mount points for trusted tooling versus untrusted build artifacts.
For container-based runners, enforce non-root execution, apply read-only root filesystems where the build toolchain allows it, use minimal base images (Distroless or Alpine), and enforce OPA/Gatekeeper policies in Kubernetes to prevent privileged pod creation, host path mounts, and hostNetwork access from runner pods.
Behavioral Monitoring and Anomaly Detection
Static hardening is necessary but insufficient against in-process attacks. Deploy runtime behavioral monitoring to detect deviations from expected runner behavior. Falco (CNCF graduated project) is the standard choice for Kubernetes-based runners: define rules that alert on unexpected outbound connections, shell spawning from non-build processes, reads of /etc/shadow or credential files, and modifications to runner configuration files outside of approved update windows.
At the cloud provider layer, enable AWS CloudTrail with anomaly detection for the runner’s IAM role — an alert should fire immediately if the runner role makes API calls to services it has never historically accessed. GuardDuty’s threat intelligence integration will flag known malicious IPs contacted from runner instances. Similar capabilities exist via Azure Defender for Servers and GCP Security Command Center.
Pipeline Workflow Security and Repository Hygiene
The workflow definition file — .github/workflows/*.yml, .gitlab-ci.yml, or equivalent — is itself attack surface. Attackers who can modify workflow files can direct runner behavior. Supply chain research from Legit Security in 2024 identified workflow injection as the attack class with the fastest-growing exploitation rate across public SaaS CI platforms, increasing 340% year-over-year.
Workflow Hardening Controls
- Pin third-party Actions to full commit SHA: Using
actions/checkout@v4instead ofactions/checkout@a81bbbf8means you’re trusting a mutable tag. A compromised action maintainer account can redirect a tag to malicious code. SHA pinning is immutable. - Restrict workflow permissions at the repository level: Set the default GITHUB_TOKEN permission to
read-onlyand explicitly elevate only the permissions each workflow requires. Audit and reject any workflow grantingwrite-allwithout documented justification. - Require code review for workflow file changes: Enforce branch protection rules that require approval from a designated security reviewer for any change to workflow definition files — these are infrastructure changes, not code changes.
- Disable fork pull request access to secrets: Never set
pull_request_targetwithout understanding its trust model. If you must use it, explicitly gate secrets and runner selection on a verified condition (e.g., actor is organization member with specific role).
Dependency and Artifact Integrity
Builds consume dependencies and produce artifacts. Both are tamper surfaces. Implement dependency pinning with hash verification (pip-compile with hash checking, npm lockfiles with npm ci, Go module sum verification). For artifacts, sign all build outputs using Sigstore/Cosign before pushing to registries — and verify signatures in deployment pipelines before consuming them. This creates a verifiable chain of custody from source commit to deployed artifact, enabling rapid forensic analysis when pipeline integrity is questioned.
Monitoring, Auditing, and Incident Response Readiness
Hardening without visibility is a false sense of security. The IBM Cost of a Data Breach Report 2025 found that organizations with mature CI/CD security monitoring identified pipeline-related incidents 47% faster than those relying solely on endpoint or network controls. Speed of detection is a direct multiplier on breach cost reduction.
Centralized Log Aggregation and SIEM Integration
All runner activity should stream to a centralized SIEM in real time: build logs, OS audit logs, cloud API call logs (CloudTrail/Cloud Audit Logs), network flow logs, and container runtime events. Define detection rules specific to runner threat models — not generic rules tuned for production servers. Key detections include:
- IMDS query activity from containerized workloads (should never occur in a properly configured environment)
- Runner IAM role accessing services outside its established behavioral baseline
- Outbound connections to non-allowlisted IP ranges or domains
- Secrets manager access volume spikes (may indicate secret harvesting)
- Runner binary or configuration file modification outside of provisioning windows
Tabletop Exercises and Runner-Specific Runbooks
Include CI/CD runner compromise in quarterly incident response tabletop exercises. The runbook for a suspected runner compromise should include: immediate job queue drain and runner isolation, IAM role credential revocation and rotation, forensic snapshot of runner state before termination, audit of all jobs executed on the runner in the preceding 72 hours for privilege abuse or data exfiltration indicators, and downstream artifact integrity verification for any artifacts produced during the compromise window. Organizations that practice this scenario respond measurably faster when it happens in production.
Key Takeaways
- Ephemerality is non-negotiable: Persistent runners accumulate risk with every job they execute. Kubernetes-based or auto-scaled ephemeral runners eliminate the cross-job contamination vector entirely and should be the architectural default for any cloud-hosted CI/CD environment.
- OIDC federation eliminates long-lived secrets: Replace static IAM credentials and stored CI secrets with OIDC token exchange. Short-lived, scoped credentials that cannot be reused outside their originating pipeline context dramatically reduce the blast radius of a runner compromise.
- Workflow files are infrastructure — treat them accordingly: SHA-pin all third-party actions, enforce branch
💡 Enjoyed this article?
Subscribe for more expert insights delivered to your inbox.
Follow us or subscribe below xe2x80x94 free, no spam.





