Initial self hosted runner provision script, to be tested#543
Open
lukhsaankumar wants to merge 4 commits intomainfrom
Open
Initial self hosted runner provision script, to be tested#543lukhsaankumar wants to merge 4 commits intomainfrom
lukhsaankumar wants to merge 4 commits intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Provisioning Script for Self-Hosted GitHub Actions Runner (Ubuntu)
Purpose
Install and configure a hardened, idempotent GitHub Actions runner for SIL testing, with optional SocketCAN support.
Relates to #307
Key Features
GH_RUNNER_TOKENgithub-runner(no sudo)ufw,fail2ban,apparmor,auditd,unattended-upgradesCAN_TYPE=virtual→ createsvcan0CAN_TYPE=physical→ installscan-utils, serial CAN toolspython-can,cantoolsNote: To be tested on a Linux Based OS that supports SocketCAN
SIL Self-Hosted Runner & Workflow Setup
This section explains:
1. GitHub Repo & Branch Protection Setup
1.1 Protected branches
In Settings → Branches → Branch protection rules, add a rule for your main integration branch (e.g.
main):Branch name pattern
main(orrelease/*etc. as needed)Require a pull request before merging
Require status checks to pass before merging
SIL check(prevents merging if new commits land on main before the PR is re-tested)
Restrict who can push to matching branches
This guarantees that no one can push directly to
mainand that SIL must pass on the PR before merge.1.2 Labels & CI gate (ci:run-sil)
We gate the expensive / sensitive SIL job behind a label.
In your repo, go to Issues → Labels and create:
ci:run-silWho can use it:
Recommended process:
ci:run-sil.Effect on workflow:
workflow_dispatch, ORci:run-sil.1.3 Status checks on PRs
Once the workflow has run at least once, GitHub will start displaying:
SIL checkas a status on pull requests.For each PR to a protected branch:
ci:run-sillabel:SIL check→ state: skippedci:run-sillabel:SIL checkruns on the self-hosted runner.2. Workflow Overview
Current workflow:
Current SIL Dummy Script:
run_sil_dummy.shKey points:
self-hosted, linux, sil, socketcan→ ensures only your hardened SIL runner picks this job up.contents: readonly.timeout-minutes: 2to stop long-running or stuck SIL jobs.3. Runner Provisioning Overview
The self-hosted runner is created by a provisioning script (run once on a fresh Ubuntu VM):
Creates a dedicated user:
github-runnerInstalls:
/opt/actions-runnerRegisters the runner:
self-hosted, linux, sil, socketcanWorks as a systemd service:
actions.runner.<owner>-<repo>.sil-runner-01.serviceSets up virtual SocketCAN if
CAN_TYPE=virtual:vcan0interface viavcan0.servicecan, can_raw, vcan, can_devApplies system hardening:
/etc/security/limits.d/github-runner.conf.4. Threats Mitigated by This Design
4.1 Untrusted PRs compromising the runner
Threat:
A random contributor (or fork) opens a PR with malicious code in scripts that the SIL job runs.
Mitigations:
ci:run-silby a maintainer, ORworkflow_dispatch).GITHUB_TOKENhas read-only permissions.4.2 Secret exfiltration from GitHub / runner
Threat:
Malicious workflow steps or PR code attempt to steal:
GITHUB_TOKENwith excessive permissionsMitigations:
contents: readonly.secrets.*in the SIL workflow = nothing sensitive exported by design.sudo -l -U github-runnershows no commands allowed./etc/shadow/etc/sudoers*/root/**4.3 File system boundary and privilege escalation
Threat:
Malicious job attempts:
tee /root/pwnedcat /etc/shadow/etcor/bootMitigations:
github-runner, not root.github-runner./etc/shadow/etc/sudoers*/root/**/etc/**,/boot/**,/sys/**.ProtectSystem=strictProtectHome=yesReadWritePaths=/opt/actions-runner/_work /opt/actions-runner/_diag/opt/actions-runneris owned bygithub-runner, with only_work/_diagwritable.Result: Scripts can only meaningfully write inside the runner's
_work/_diagdirectories, not the OS.4.4 Denial-of-service (DoS) via runaway jobs
Threat:
Mitigations:
timeout-minutes: 2→ GitHub forcibly cancels jobs taking too long.CPUQuota=150%MemoryMax=2GTasksMax=256LimitNPROC=512LimitNOFILE=4096TimeoutStopSec=30/etc/security/limits.d/github-runner.conf:soft nproc 256, hard nproc 512soft cpu 60, hard cpu 120/opt/actions-runner/_work.Result: Malicious SIL code can waste some resources temporarily, but it cannot permanently exhaust the VM, fill the disk indefinitely, or fork-bomb the host.
4.5 Brute-force attacks or external SSH probing
Threat:
Internet-wide scanning or bots trying to brute-force SSH into the VM.
Mitigations:
ufw limit 22/tcp: rate-limits SSH attempts.4.6 Silent long-term compromise / tampering
Threat:
An attacker gets code execution on the runner and tries to persist or hide.
Mitigations:
/opt/actions-runner/for write activity (-w /opt/actions-runner -p wa -k runner_changes).execvesyscalls run by uid ofgithub-runner(runner_execkey).This doesn't guarantee no compromise, but makes persistence and stealth significantly harder.
4.7 CAN / SIL environment isolation
Threat:
Malicious SIL code reconfigures CAN interfaces in a way that affects other services or future runs.
Mitigations:
CAN_TYPE=virtual:vcan0is brought up byvcan0.service./sys/class/net/vcan0/**via AppArmor for read only.vcan0) is safe for testing logic without touching physical hardware.5. Operational Checklist
When onboarding a new maintainer or setting up a new SIL runner, they should know:
self-hosted, linux, sil, socketcanci:run-sillabel to PRs when they're ready for SIL.SIL checkpasses before merging.github-runnerhas no sudo.vcan0exists and is up for virtual CAN SIL tests.