Home

Awesome

<p align="center"> <picture> <source media="(prefers-color-scheme: light)" srcset="images/banner.png" width="400"> <img alt="Dark Banner" src="images/banner-dark.png" width="400"> </picture> </p> <div align="center">

Maintained by stepsecurity.io OpenSSF Scorecard License: Apache 2.0

</div>

Table of Contents

Introduction

Harden-Runner provides network egress filtering and runtime security for GitHub-hosted and self-hosted runners. It is called Harden-Runner because it hardens the runner on which GitHub Actions workflows run.

Learn how Harden-Runner works through the video below, which shows how it detected a supply chain attack on a Google open-source project.

<a href="https://youtu.be/Yz72qAOrN9s" target="_blank"><img src="images/case-study-thumbnail1.png" alt="Harden-Runner detected supply chain attack in a Google open-source project" title="This case study video shows how StepSecurity Harden-Runner detected a CI/CD supply chain attack in real-time in Google’s open-source project Flank"></a>

4,000+ open source projects use Harden-Runner

Harden-Runner is trusted by leading open source projects and enterprises to secure their CI/CD pipelines.

Trusted by

CISAMicrosoftGoogleDataDogIntelKubernetesNode.jsAWS
CISA<br>ExploreMicrosoft<br>ExploreGoogle<br>ExploreDataDog<br>ExploreIntel<br>ExploreKubernetes<br>ExploreNode.js<br>ExploreAWS<br>Explore

Case Studies

Why use Harden-Runner

There are two main threats from compromised workflows, dependencies, and build tools in a CI/CD environment:

  1. Exfiltration of CI/CD credentials and source code
  2. Tampering of source code, dependencies, or artifacts during the build to inject a backdoor

Harden-Runner monitors process, file, and network activity to:

CountermeasurePrevent Security Breach
1.Monitor and block outbound network traffic at the DNS, HTTPS (Layer 7), and network layers (Layers 3 and 4) to prevent exfiltration of code and CI/CD credentialsTo prevent the Codecov breach scenario
2.Detect if source code is being tampered during the build process to inject a backdoorTo detect the XZ Utils and SolarWinds incident scenarios
3.Detect poisoned workflows and compromised dependencies that exhibit suspicious behaviorTo detect Dependency confusion and Malicious dependencies scenarios
4.Determine minimum GITHUB_TOKEN permissions by monitoring HTTPS calls to GitHub APIsTo set minimum GITHUB_TOKEN permissions to reduce the impact of exfiltration

Getting Started

Hardening GitHub-Hosted Runners

  1. Add the step-security/harden-runner GitHub Action to your GitHub Actions workflow file as the first step in each job. You can automate adding Harden-Runner Action to your workflow file by pasting your workflow in the StepSecurity online tool.

    steps:
      - uses: step-security/harden-runner@446798f8213ac2e75931c1b0769676d927801858 # v2.10.0
        with:
          egress-policy: audit
    
  2. In the workflow logs and the job markdown summary, you will see a link to security insights and recommendations.

    <p align="left"> <img src="images/buildlog1.png" alt="Link in build log" > </p>
  3. Click on the link (example link). You will see a process monitor view of network and file events correlated with each step of the job.

    <p align="left"> <img src="images/network-events1.png" alt="Insights from harden-runner" > </p>
  4. In the Recommended Policy tab, you'll find a recommended block policy based on outbound calls aggregated from the current and past runs of the job. You can update your workflow file with this policy, or alternatively, use the Policy Store to apply the policy without modifying the workflow file. From now on, any outbound calls not in the allowed list will be blocked.

    <p align="left"> <img src="images/recommended-policy1.png" alt="Policy recommended by harden-runner" > </p>

Hands-On Tutorials

You can use GitHub Actions Goat to try Harden-Runner. You only need a GitHub Account and a web browser.

Hands-on Tutorials for GitHub Actions Runtime Security:

  1. Filter Egress Network Traffic
  2. Detect File Tampering

Support for Private Repositories

Hardening of runners used in private repositories is supported with a commercial license. Check out the documentation for more details.

Read this case study on how Kapiche uses Harden-Runner to improve software supply chain security in their private repositories.

Hardening Self-Hosted Runners

Hardening of self-hosted runners is supported with a commercial license. Check out the documentation for more details. For hardening of self-hosted runners you must install the StepSecurity GitHub App.

Self-Hosted Actions Runner Controller (ARC) Runners

Explore demo workflows using self-hosted ARC Runner and ARC Harden-Runner here.

Actions Runner Controller (ARC) is a Kubernetes operator that orchestrates self-hosted runners for GitHub Actions.

Self-Hosted VM Runners (e.g. on EC2)

Explore demo workflows using self-hosted VM Runners and Harden-Runner here.

Features at a glance

For details, check out the documentation at https://docs.stepsecurity.io

View outbound network traffic at the job level

Applies to both GitHub-hosted and self-hosted runners

Harden-Runner monitors all outbound traffic from each job at the DNS and network layers

View outbound network traffic at the organization level

Applies to both GitHub-hosted and self-hosted runners

You can view all unique network destinations from all workflow runs in your organization on the Runtime Security tab.

For more details refer Unified Network Egress View: Centralize GitHub Actions Network Destinations for Your Enterprise

<p align="left"> <img src="images/org-level.png" width="400" alt="View outbound network traffic at the organization level" > </p>

View outbound HTTPS traffic at the job level

Applies to GitHub-hosted and self-hosted VM runners

Harden-Runner can monitor outbound HTTPS requests. This feature is supported with a commercial license.

<p align="left"> <img src="images/https-events.png" alt="View outbound HTTPS traffic at the job level" > </p>

Detect anomalous outbound network traffic

Applies to both GitHub-hosted and self-hosted runners

You can detect suspicious/ anomalous traffic using this feature even in egress-policy:audit mode.

For more details, refer to Anomalous Outbound Call Detection Using Machine Learning

Filter outbound network traffic to allowed endpoints

Applies to both GitHub-hosted and self-hosted runners

You can see recommended egress block policy in the Recommendations tab for each job. This is based on observed traffic across multiple runs of the job.

<p align="left"> <img src="images/recommended-policy1.png" alt="Policy recommended by harden-runner" > </p>

Once you set these allowed endpoints in the workflow file, or in the Policy Store and switch to using egress-policy:block

<p align="left"> <img src="images/blocked-outbound-call-3.png" alt="Policy recommended by harden-runner" > </p>

Determine minimum GITHUB_TOKEN permissions using Harden-Runner

Applies to GitHub-hosted runners

Harden-Runner monitors outbound HTTPS requests using eBPF and uses the PATHs and VERBs of these HTTPS calls to recommend the minimum GITHUB_TOKEN permissions for each job in your workflow. This feature is supported with a commercial license.

For more details, refer to Determine Minimum GITHUB_TOKEN Permissions Using eBPF with Harden-Runner.

<p align="left"> <img src="images/token-perms-recommendation.png" alt="View recommendation for minimum GITHUB_TOKEN permissions" > </p>

View the name and path of every file written during the build process

Applies to both GitHub-hosted and self-hosted runners

View the name and path of every file that was written during the build process. This feature is supported with a commercial license.

<p align="left"> <img src="images/file-write-events.png" alt="View the name and path of every file written during the build process" > </p>

View process names and arguments

Applies to both GitHub-hosted and self-hosted runners

View process names, PIDs, and process arguments. This feature is supported with a commercial license.

<p align="left"> <img src="images/process-events-3.png" alt="View process names and arguments" > </p>

Detect tampering of source code during build

Applies to both GitHub-hosted and self-hosted runners

Harden-Runner monitors file writes and can detect if a file is overwritten.

<p align="left"> <img src="images/file-events.png" alt="Policy recommended by harden-runner" > </p>

Run your job without sudo access

Applies to GitHub-hosted runners

GitHub-hosted runner uses passwordless sudo for running jobs.

Get real-time security alerts

Applies to both GitHub-hosted and self-hosted runners

Install the StepSecurity GitHub App to get security alerts/ notifications.

Discussions

How does it work?

GitHub-Hosted Runners

For GitHub-hosted runners, Harden-Runner GitHub Action downloads and installs the StepSecurity Agent.

Self-Hosted Actions Runner Controller (ARC) Runners

Self-Hosted VM Runners (e.g. on EC2)

Limitations

GitHub-Hosted Runners

  1. Only Ubuntu VM is supported. Windows and MacOS GitHub-hosted runners are not supported. There is a discussion about that here.
  2. Harden-Runner is not supported when job is run in a container as it needs sudo access on the Ubuntu VM to run. It can be used to monitor jobs that use containers to run steps. The limitation is if the entire job is run in a container. That is not common for GitHub Actions workflows, as most of them run directly on ubuntu-latest. Note: This is not a limitation for Self-Hosted runners.

Self-Hosted Actions Runner Controller (ARC) Runners

  1. Since ARC Harden Runner uses eBPF, only Linux jobs are supported. Windows and MacOS jobs are not supported.

Self-Hosted VM Runners (e.g. on EC2)

  1. Only Ubuntu VM is supported. Windows and MacOS jobs are not supported.