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 →
- Set the default workflow permission to read-only in repo or org settings.
- Declare permissions per workflow or job:
permissions:
contents: read
jobs:
release:
permissions:
contents: write
id-token: write
- 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.
More on Secrets, Signing and Security
A developer pushed an AWS access key to a public repo 10 minutes ago. What is your first move?BeginnerAfter rotating the leaked key, you must purge it from repository history. How?AdvancedA push is rejected: "GH013: Repository rule violations found ... Push cannot contain secrets". What do you do?IntermediateSecret scanning alerts have piled up, and many look like false positives or old test credentials.IntermediateYou must set up signed commits on your laptop. Which method do you pick?BeginnerYour GPG signing key expires next week. What is the correct way to handle it?Intermediate