A Practical Guide to Using eBPF for Safer Deployments: Lessons from GitHub

By

Introduction

GitHub itself runs on github.com, creating a classic circular dependency: if the site goes down, engineers can't access the code they need to fix it. While a mirror helps, deployment scripts can still introduce subtle circular dependencies—for example, a script that downloads a tool from GitHub during an outage. To break this cycle, GitHub turned to eBPF (extended Berkeley Packet Filter). This guide shows you how to apply the same technique: monitor and block deployment scripts from making unsafe network or system calls that could create circular dependencies.

A Practical Guide to Using eBPF for Safer Deployments: Lessons from GitHub
Source: github.blog

What You Need

Step-by-Step Guide

Step 1: Identify Circular Dependencies in Your Deployment Scripts

Before you can block dangerous calls, you need to know what to look for. Circular dependencies fall into three categories:

Review each step in your deployment scripts and note every external network call or system file read. Pay special attention to package managers, update checkers, and API calls.

Step 2: Set Up eBPF Monitoring to Trace Calls During Deployments

Use existing eBPF tools to capture what your scripts actually do. For example:

# Trace network connections
sudo opensnoop -p $(pgrep -f deploy-script)
# Trace executed commands
sudo execsnoop -p $(pgrep -f deploy-script)

Run these in parallel with a test deployment in staging. Collect a list of all connections (IP addresses and ports) and executables launched. This becomes your baseline of potential circular dependencies.

Step 3: Define Policies to Block Unsafe Connections

Based on your monitoring data, decide which calls are unsafe during an outage. For example:

Write these policies as simple IP/domain allow lists or deny lists. eBPF lets you enforce them at the kernel level, so even a well-hidden call can’t escape.

Step 4: Write a Custom eBPF Program to Intercept and Filter Calls

With BCC, you can create a small C program that runs inside the kernel. Here’s a skeleton that attaches to the connect syscall and blocks connections to a specific IP:

A Practical Guide to Using eBPF for Safer Deployments: Lessons from GitHub
Source: github.blog
from bcc import BPF

bpf_text = """
#include <uapi/linux/ip.h>
#include <net/sock.h>

int block_connect(struct pt_regs *ctx, struct sockaddr_in *addr)
{
    if (addr->sin_addr.s_addr == blocked_ip) {
        return -EPERM;  // block
    }
    return 0;
}
"""

blocked_ip = 0x0a000001  # 10.0.0.1 for example
b = BPF(text=bpf_text)
b.attach_kprobe(event="tcp_v4_connect", fn_name="block_connect")
# alternative: use cgroup/connect4 for container-level filtering

Test this program in isolation—first log, then gradually enforce denials.

Step 5: Test the eBPF Program in a Staging Environment

Simulate an outage scenario (e.g., add a firewall rule to block GitHub temporarily). Run your deployment script with the eBPF program active. Verify that:

If you detect false positives, refine your policy. Repeat until the script works perfectly under the simulated outage.

Step 6: Integrate eBPF into Your Deployment Pipeline

Once stable, incorporate the eBPF programs into your deployment process:

Tips and Conclusion

Start small: monitor before you block. Use eBPF to log all network connections for a week to identify unexpected dependencies. Then progressively enforce blocks. Remember that even hidden dependencies—like a tool checking for updates—can cause failures during an incident.

GitHub’s approach shows that eBPF provides a low-overhead, fine-grained way to enforce deployment safety without modifying application code. By following these steps, you can break circular dependencies and make your own deployments more resilient.

Tags:

Related Articles

Recommended

Discover More

7 Critical Facts About JanelaRAT: The Malware Targeting Latin American Finance10 Essential Insights into the Microsoft Agent Framework for .NET DevelopersKubernetes Gateway API v1.5 Goes Live with Major Stability Upgrades and Scalable ListenerSet FeatureWhy Traditional Weather Forecasting Still Outshines AI for Extreme Events: 10 Key InsightsWindows 11 Run Menu Gets a Modern Makeover: Dark Mode, New Commands, and More