How do you harden self-hosted CI runners?
AdvancedScenarioPipeline Security Scanning
Answer
Situation read → A persistent runner shared between repos is a lateral-movement path: one bad job can leave malware or steal tokens for the next.
What I'd do →
- Use ephemeral runners (one job per VM or pod, destroyed afterwards), for example Actions Runner Controller on Kubernetes.
- Never attach self-hosted runners to public repos.
- Give each runner minimal cloud permissions through short-lived credentials and IMDSv2 with hop limit 1.
- Network egress allowlist; no access to production networks.
- Separate runner groups per trust level.
- Patch the base image regularly and log all job activity.
Why → Ephemeral runners remove persistence, which is the main attacker advantage.
Interview tip → Mention that docker.sock mounts equal root on the host.
More on Pipeline Security Scanning
You are asked to add security to an existing CI pipeline. Where do SAST, SCA, secrets scanning and DAST each go?BeginnerGitleaks flags an AWS access key in a pull request. The developer says it is a test key. What do you do?BeginnerDevelopers fear security scans will slow the pipeline from 6 to 20 minutes. How do you roll them out?BeginnerA SAST tool reports 2,000 findings on a legacy repo the first time you run it. How do you introduce it without freezing delivery?IntermediateA developer insists a scanner finding is a false positive. What is your process?BeginnerSCA flags a critical CVE in a transitive dependency and no patched version exists. What are your options?Intermediate