Why CI/CD Needs Runtime Security: Lessons From Railway

Why CI/CD Needs Runtime Security: Lessons From Railway

The transition to OpenID Connect for cloud authentication significantly reduces risk by replacing long-lived static secrets with short-lived, identity-based credentials for deployments. This fundamental shift is no longer just a best practice but a necessity in a landscape where software supply chain attacks target the heart of the development process: the Continuous Integration and Continuous Deployment (CI/CD) pipeline. A recent security report concerning a breach on October 20 and 21, 2026, involving the platform Railway, serves as a stark reminder of the vulnerabilities inherent in automated build environments. When an attacker gains a foothold in a build job, they are not just executing code in a vacuum; they operate with the permissions and network access granted to that specific job. The incident demonstrated how a partial build-isolation escape allowed an attacker to move from build infrastructure to systems containing customer secrets, eventually accessing internal source code and decrypted variables. By examining these access paths, organizations can better understand the critical need for monitoring build activity and restricting outbound connections. The challenge is that build jobs are dynamic by nature, often requiring access to external registries and internal APIs, making it difficult to distinguish between legitimate developer activity and malicious lateral movement. Addressing these gaps requires a move toward runtime security that provides visibility into the processes occurring during execution rather than relying solely on static configuration checks.

1. Evaluating Your Pipeline Security: Identifying High-Risk Access Points

A thorough security review of modern CI/CD pipelines must begin with an exhaustive identification of high-risk access points, particularly focusing on jobs that interact with production environments. Security teams must move beyond simply listing the permissions defined in a YAML configuration file and instead investigate the entire lifecycle of a build job. This includes every step that executes third-party code, from initial package installations and test scripts to build tools and automated release scripts. Each of these steps represents a potential entry point for an attacker who could use the job’s network access to probe internal services or reach cloud endpoints. By tracing the lineage of a build, organizations can determine exactly which jobs have the capability to retrieve sensitive production credentials or access private cloud resources. It is critical to recognize that a job with seemingly narrow permissions may still be running on a host with much broader access, potentially exposing internal APIs or metadata services that were never intended to be accessible from a CI/CD runner. This discovery process allows security architects to map the attack surface and identify where additional isolation or network restrictions are most urgently needed to prevent a single compromised build from escalating into a catastrophic data breach.

Following the identification of access points, the next priority is establishing the capability to trace all internal activity back to specific workflow steps and processes. Organizations often find themselves in a position where they can see a network connection occurring but cannot definitively say which line of code or which dependency initiated it. Effective pipeline security requires the ability to pinpoint the exact process behind every outbound request, whether it is a legitimate call to a package registry or an unauthorized attempt to exfiltrate secrets. This involves auditing existing network policies and cloud trust configurations to ensure they are actually functioning as intended under real-world conditions. Regular testing of these restrictions through simulated attacks or automated security validation helps confirm that a runner cannot reach internal databases or production clusters unless explicitly authorized. Furthermore, reviewing the identities that a job can obtain during its execution is essential; a job token might be ephemeral, but if it allows the assumption of a broad administrative role, the risk remains significant. By closing the gap between what a policy says and what a job can actually do at runtime, organizations create a more transparent and verifiable security posture that can withstand the scrutiny of a post-incident investigation.

2. Implementing Stronger Build Isolation: Protecting the Execution Environment

Protecting the build environment is a multilayered effort that relies heavily on utilizing clean, disposable execution environments. Every single build job should be assigned its own ephemeral virtual machine or container, ensuring that no data or state persists between runs. This approach prevents cross-job data exposure and limits the ability of an attacker to plant persistent backdoors on a runner host. The Railway incident report highlights the danger of shared infrastructure, noting that multiple builds running on the same virtual machine can lead to isolation escapes if file system vulnerabilities are exploited. By moving to a model where each job is strictly isolated within its own security boundary, organizations can significantly reduce the risk of lateral movement. This isolation must also extend to credentials; a build credential should be scoped to the minimum necessary actions, such as pushing a single specific container image rather than having broad access to an entire registry. Where shared caches or artifact storage are necessary for performance, they must be treated as untrusted and accessed through restricted interfaces that enforce strict separation between different levels of workload trust.

For organizations utilizing advanced orchestration like the Actions Runner Controller (ARC) in Kubernetes, implementing these principles requires a focus on container-specific security controls. Workloads must be separated by trust levels, keeping untrusted builds isolated from privileged deployment jobs and production applications. This can be achieved through dedicated node pools, namespaces, and Kubernetes Network Policies that restrict traffic between pods. Furthermore, it is essential to limit host access by preventing build containers from accessing sensitive host directories or container runtime sockets, which are frequent targets for escape exploits. Deploying runtime monitoring agents, such as StepSecurity Harden-Runner, provides the necessary visibility into outbound traffic and process behavior within these ephemeral environments. For ARC deployments, these agents can be deployed as a DaemonSet to provide consistent protection across the entire cluster. This combination of infrastructure-level isolation and runtime-level monitoring ensures that even if a container’s boundaries are tested, the resulting activity is immediately detected and recorded, providing a robust defense against sophisticated attackers who seek to exploit the complexity of modern containerized CI/CD pipelines.

3. Combining Runtime Defense With Access Control: Building Defense in Depth

A resilient “defense in depth” strategy for CI/CD environments must integrate observation, restriction, and authorization into a cohesive security framework. Observation through runtime telemetry allows security teams to link every network connection and process event directly to the responsible workflow step. This context is vital because a simple list of network logs is often insufficient to determine if a connection to a specific IP address was caused by a legitimate npm install or a malicious script attempting to exfiltrate an environment variable. By capturing process names and arguments alongside network metadata, organizations can reconstruct the exact sequence of events that led to a specific action. This level of visibility transforms the CI/CD pipeline from a “black box” into a transparent system where every execution is logged and verifiable. This is particularly important for detecting supply chain compromises where a trusted dependency might be updated to include malicious code that only activates during the build process, attempting to reach out to an external command-and-control server while the developer is unaware.

Once visibility is established, the next layer involves implementing strict egress allowlists to restrict outbound destinations. Rather than allowing build runners to connect to the entire internet, security teams should enforce policies that only permit connections to approved registries, cloud endpoints, and internal APIs. Tools like Harden-Runner facilitate this by offering an audit mode to observe a job’s normal traffic patterns, which can then be converted into a blocking policy that denies any unauthorized requests. This restriction is a powerful tool for stopping credential theft; even if an attacker successfully obtains a secret, they cannot send it to their own server if the connection is blocked at the runner level. This must be paired with identity-based authorization through OpenID Connect (OIDC) and cloud IAM roles. By moving away from long-lived static secrets and instead using OIDC to issue short-lived tokens, organizations ensure that credentials only exist for the duration of a specific job and are bound to a verified identity. This two-pronged approach—blocking unauthorized network paths and eliminating permanent secrets—creates a formidable barrier that protects production environments from the impact of a compromised build job.

4. Strengthening Cloud and Secret Security: Moving Beyond Static Credentials

Strengthening the security of cloud deployments requires a fundamental shift away from static credentials toward dynamic, identity-based authentication. Enforcing OIDC for all cloud-related tasks is the most effective way to minimize the risk of credential leakage. By using short-lived tokens that are issued only when a job is running, organizations eliminate the danger of a leaked secret being used hours or days after a build has finished. These tokens must be strictly configured with issuer and subject conditions that validate the specific repository, environment, and even the branch from which the deployment is originating. This level of granularity ensures that a developer cannot accidentally or maliciously use a staging job to push changes to a production environment. Furthermore, the role of IAM policies cannot be overstated; cloud roles must be granted the absolute minimum permissions required to perform their specific tasks. A deployment role should have permission to update a specific service or upload to a specific bucket rather than possessing broad administrative access to the entire cloud account, which would turn any minor breach into a full-scale infrastructure takeover.

In addition to technical controls, process-based safeguards like manual environment approvals and job isolation provide a final layer of protection against unauthorized changes. By utilizing GitHub environment protection rules, organizations can mandate that a human reviewer must explicitly approve any job that attempts to access production credentials. This human-in-the-loop requirement acts as a critical gatekeeper, preventing automated attacks from reaching sensitive targets even if an attacker manages to trigger a workflow. It is also a best practice to isolate privileged deployment steps from the rest of the build process. By keeping third-party code, such as linting tools or test suites, in a separate job with lower permissions, security teams ensure that these dependencies never have access to the OIDC tokens or production secrets used during the final deployment phase. Similarly, sensitive credentials used for publishing software packages should be moved from the general repository scope to protected environment scopes where they are subject to the same approval and branch restriction rules. These combined measures create a hardened path to production where every step is authenticated, authorized, and overseen by both automated systems and human operators.

5. Managing Enterprise-Wide Security: Scaling Protection Across Repositories

Managing security across hundreds or thousands of repositories requires a centralized approach that moves away from manual, repo-by-repo configuration. Organizations must utilize a centralized policy store to manage egress rules and security settings at the organization or cluster scope. This allows security teams to update network policies globally and push changes to all attached workflows without needing to edit individual YAML files. Such a system provides a single source of truth for CI/CD security and ensures that all projects, regardless of their size or importance, adhere to the same baseline standards. Centralized management also simplifies compliance and auditing, as security professionals can easily review the history of policy changes and verify that all runners are operating within approved parameters. Without this level of automation, maintaining a consistent security posture across a large enterprise becomes impossible, leading to “security drift” where older or less active repositories become the weakest links in the software supply chain.

Scaling enterprise security also depends on leveraging anomaly detection and automated alerting to respond to threats in real time. By using tools that learn the baseline behavior of every build job, organizations can identify unexpected deviations—such as a new network connection or an unusual file modification—that could indicate a compromise. Anomaly detection is particularly valuable in a CI/CD context because builds are generally consistent; a job that has made the same five connections for months and suddenly attempts a sixth is a clear signal for investigation. These detections must be routed to the appropriate personnel through communication tools like Slack or Microsoft Teams to ensure a rapid response. Automating these alerts means that security teams are only notified of high-confidence events, reducing alert fatigue and allowing them to focus on genuine threats. This proactive monitoring, combined with the ability to block unauthorized connections instantly, creates a resilient enterprise environment where security is integrated into the development lifecycle rather than being a manual hurdle that slows down the pace of innovation.

6. The Implementation of Resilient Infrastructure: Strategic Next Steps

The successful hardening of CI/CD environments requires a proactive approach that integrates runtime visibility with strict access controls. Organizations that adopted these measures found themselves better prepared to detect and mitigate the types of lateral movement seen in recent infrastructure compromises. By prioritizing the isolation of build workloads and implementing granular network allowlists, security teams significantly reduced the blast radius of potential exploits. The transition to identity-based authentication, such as OpenID Connect, effectively eliminated the danger of static credential theft, while the use of manual environment approvals provided a final human check against unauthorized deployments. These strategies not only improved the technical security of the pipelines but also fostered a culture of transparency and accountability within development teams. In the end, the focus on runtime security proved to be the most effective defense against the evolving threats targeting the software supply chain, ensuring that every code change was validated and every connection was authorized before reaching production systems.

Moving forward, the focus shifted toward the continuous refinement of these security policies and the expansion of monitoring coverage. Organizations recognized that security was not a one-time setup but an ongoing process of adaptation to new vulnerabilities and attack vectors. They integrated automated security testing into their pipelines to validate that network blocks and identity checks remained effective after every infrastructure update. Furthermore, the data gathered from runtime monitoring provided invaluable insights for future architecture decisions, allowing teams to identify and remove unnecessary dependencies that increased the attack surface. By treating CI/CD security as a foundational component of the engineering lifecycle, businesses were able to maintain a rapid pace of delivery without compromising on safety. This holistic approach, combining technical innovation with rigorous process oversight, established a new standard for infrastructure resilience in the modern cloud-native era. The lessons learned from previous incidents paved the way for a more secure and reliable automated future where developers could build with confidence.

Subscribe to our weekly news digest.

Join now and become a part of our fast-growing community.

Invalid Email Address
Thanks for Subscribing!
We'll be sending you our best soon!
Something went wrong, please try again later