Skip to content

Conversation

@cinderellasecure
Copy link
Contributor

@cinderellasecure cinderellasecure commented Oct 30, 2025

As part of the organization's transition to default read-only permissions for the GITHUB_TOKEN, this pull request addresses a missing permission in the workflow that triggered a code scanning alert.

This PR explicitly adds the required read permissions to align with the default read only permission and is part of a larger effort for this OKR https://github.com/github/security-services/issues/455

Potential fixes for 2 code scanning alerts from the Copilot AutoFix: Missing Permissions in Workflows security campaign:

  • https://github.com/github/check-all/security/code-scanning/4
    The best way to fix the problem is to explicitly set the minimal required permissions for the workflow (or job), limiting the GITHUB_TOKEN privileges according to the principle of least privilege. In this workflow, the job is publishing to npm and interacting with release info, but no actions here modify repository contents or interact with pull requests. The safest and least privilege starting point is contents: read, which is sufficient for checking out code and reading repository files but does not grant write access to contents. To implement the fix, add a permissions: block to either the root level (above jobs:) or specifically to the publish-npm job (below runs-on:). The standard approach is to add it at the root level so it applies globally (unless jobs require something different).

    Changes needed:

    • Insert a block:
    permissions:
      contents: read
    • Place the block after the workflow name and before the on: clause (as per GitHub Actions docs).

    No additional imports or definitions are needed.


  • https://github.com/github/check-all/security/code-scanning/3
    To address the issue, explicitly set the appropriate permissions at the job or workflow level. In this workflow, since the steps only checkout code and perform build/test actions (no issue, pull request, or release modifications), it is sufficient to grant read access to repository contents. The minimal best practice change is to add permissions: contents: read at the root of the workflow (above jobs:) or inside the build: job itself. In this case, we will add it at the root for clarity and to cover any future jobs. No additional methods, imports, or dependencies are needed; simply insert the necessary YAML block.


Suggested fixes powered by Copilot Autofix. Review carefully before merging.

cinderellasecure and others added 2 commits October 30, 2025 12:17
…n permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…n permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@cinderellasecure cinderellasecure self-assigned this Oct 30, 2025
@cinderellasecure cinderellasecure marked this pull request as ready for review October 30, 2025 18:17
@cinderellasecure cinderellasecure requested a review from a team as a code owner October 30, 2025 18:17
Copilot AI review requested due to automatic review settings October 30, 2025 18:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances security by adding explicit permission restrictions to GitHub Actions workflows, implementing the principle of least privilege by limiting workflows to read-only access to repository contents.

  • Added permissions: contents: read to workflow files to restrict access scope
  • Applied the change consistently across multiple workflow files

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
.github/workflows/publish.yml Added read-only contents permission after the workflow name
.github/workflows/nodejs.yml Added read-only contents permission before the jobs section

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -1,4 +1,6 @@
name: Publish
permissions:
contents: read
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The publish workflow likely requires write permissions to publish packages. Setting permissions: contents: read may prevent the workflow from successfully publishing releases. Consider adding packages: write or contents: write permissions depending on the publish target (npm, GitHub Packages, etc.).

Suggested change
contents: read
contents: write

Copilot uses AI. Check for mistakes.
@TylerJDev TylerJDev merged commit 89b177f into main Oct 31, 2025
11 of 12 checks passed
@TylerJDev TylerJDev deleted the campaign-fix-4-3 branch October 31, 2025 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants