fix(security): restrict GITHUB_TOKEN to contents:read on heartbeat workflow#175
Merged
saurabhjain1592 merged 1 commit intomainfrom Apr 29, 2026
Merged
Conversation
…rkflow The heartbeat-real-stack workflow lacked an explicit top-level permissions block, leaving GITHUB_TOKEN with the repository's default privileges (potentially read/write across many scopes). This violates the principle of least privilege (CWE-275: Permission Issues). The workflow only needs to checkout the repo, set up Python, install the SDK editable, and run a localhost-only E2E. None of those steps require write access to any GitHub resource. Locking the token down to contents: read at workflow scope addresses the code-scanning alert 'actions/missing-workflow-permissions'. Any job that later needs more can declare its own permissions block at job level. Resolves the open code-scanning alert on .github/workflows/heartbeat-real-stack.yml:20.
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.
Summary
Resolves an open GitHub code-scanning alert:
actions/missing-workflow-permissionson.github/workflows/heartbeat-real-stack.yml:20.The
heartbeat-real-stackworkflow had no explicit top-levelpermissions:block, soGITHUB_TOKENran with the repository default token scopes — broader than this workflow needs. This is a CWE-275 (Permission Issues) class finding: the token had write capabilities the job never exercises.Fix
Added a workflow-scoped permissions block:
contents: readis the minimum required byactions/checkout@v4to fetch the repo. The remaining steps (setup-python,pip install -e ., run a localhost-only E2E driver) need no GitHub-side write access.If a future job in this workflow needs higher privileges, it should declare them at job level rather than widening the workflow-level grant.
Verification
python3 -c "import yaml; yaml.safe_load(open('.github/workflows/heartbeat-real-stack.yml'))"returns no error.Test plan
pull_requestagainstmain, so this branch will exercise the new permissions block end-to-end).