Interview Prep/Git & GitHub/Secrets, Signing and Security

A workflow can write to the repo by default. How do you limit the damage of a compromised job?

IntermediateScenarioSecrets, Signing and Security
Answer

Situation read → The GITHUB_TOKEN may have broad rights depending on repository settings.

What I'd do →

  1. Set the default workflow permission to read-only in repo or org settings.
  2. Declare permissions per workflow or job:
permissions:
  contents: read
jobs:
  release:
    permissions:
      contents: write
      id-token: write
  1. Only the jobs that need write get it.

Why → A compromised step can then do only what its job was granted.

Interview tip → "Least privilege for the token" is a fast, high-value hardening.

All Git & GitHub questions Roadmap: Git & GitHub

More on Secrets, Signing and Security