r/iOSProgramming • • 48m ago

Article What's left on a self-hosted Mac mini after a few months of CI jobs

Disclosure: I work at Bitrise, and we sell hosted Mac runners. The main points are here so you don't have to click.

If you run GitHub Actions on your own Mac minis, the runner usually keeps its disk between jobs. Over time that means certificates imported into the keychain by signing steps that never removed them, an App Store Connect API key from a TestFlight upload, cloud credentials from a deploy job, and the checkout of every repo that has built there.

In November, hijacked GitHub accounts pushed a script into thousands of repos' workflows that collected whatever credentials it could find on the runner. On a fresh VM it only finds that job's secrets. On a shared Mac it can find the release signing setup of an app that has nothing to do with the repo it came in through.

Things that help without changing your setup:

  • Delete the keychain and any key files at the end of every job that creates them
  • Keep repos with outside contributors on different Macs from your release builds, using runner groups
  • Don't attach self-hosted runners to public repos
  • Log in to one runner and look through its home folder

Making Mac runners properly ephemeral means macOS VMs (Tart or Anka) and a base image with your Xcode versions that someone keeps current. The write-up compares that with the other options: https://bitrise.io/blog/post/github-actions-self-hosted-runner-security

Anyone here actually rebuilding their Macs between jobs?

2 Upvotes

3 comments sorted by

•

u/Alcoholic_Synonymous 9m ago

Using Fastlane you can set up a temporary Keychain and clean it up after each job. Although thanks for the heads up, I’ll check some other bits.

•

u/dawedev 38m ago

On a runner that's been up for months I'd grep ~/.appstoreconnect/private_keys and the provisioning profiles folder first, altool and Transporter look there by default so keys tend to get left behind. Also fastlane setup_ci leaves its temp keychain around if the job gets killed before cleanup runs.

•

u/ToddGergey 24m ago

Good call on the altool folder. It also checks ./private_keys, ~/private_keys and ~/.private_keys, so worth grepping those too. You can also set API_PRIVATE_KEYS_DIR to $RUNNER_TEMP and write the .p8 there. GitHub empties that folder at the start and end of every job, so a key from a killed job is gone by the time the next one starts.

For the keychain, a step at the start of the job that deletes any leftover fastlane_tmp_keychain covers the case you mentioned.