Skip to content

Conversation

@BakerNet
Copy link
Collaborator

@BakerNet BakerNet commented Oct 30, 2025

Related Issue(s)

closes: #74

Summary / Background

Update docs to use base_ref for actions/checkout to prevent PR authors from removing required reviews in their PR

@pooyaw
Copy link

pooyaw commented Oct 30, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@gemini-code-assist
Copy link

Summary of Changes

Hello @BakerNet, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the security posture of recommended GitHub Actions workflows by modifying the actions/checkout configuration. The update ensures that the workflow operates on the target branch of a pull request, thereby mitigating a potential vector for pull request authors to circumvent established review processes and maintain the integrity of code merges.

Highlights

  • GitHub Actions Workflow Security: The actions/checkout step in the example GitHub Actions workflow has been updated to explicitly use ref: ${{ github.base_ref }}. This change ensures that the workflow checks out the base branch of the pull request, rather than the head branch, to prevent potential bypasses of required reviews by PR authors.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/codeowners.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions bot requested a review from zbedforrest October 30, 2025 23:15
@github-actions
Copy link

github-actions bot commented Oct 30, 2025

Codeowners approval required for this PR:

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the documentation to recommend checking out github.base_ref in the example GitHub Actions workflow. The goal is to enhance security by preventing pull request authors from modifying .codeowners files to bypass reviews. While this is a positive change, I've pointed out in a comment that it doesn't fully mitigate the security risk, as the workflow file itself can still be modified by the PR author when using the pull_request trigger. For a more secure setup, I've recommended using the pull_request_target trigger instead.

README.md Outdated
- name: 'Checkout Code Repository'
uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }} # use the base_ref to prevent bypass by PR author

Choose a reason for hiding this comment

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

high

While using ref: ${{ github.base_ref }} is a good step to prevent using potentially malicious .codeowners files from the pull request branch, this setup is still vulnerable. Because the workflow is triggered by pull_request, the workflow file itself is sourced from the pull request branch. A malicious actor could simply remove this ref line in their PR to bypass the protection.

For robust security, you should use the pull_request_target trigger instead of pull_request. Workflows triggered by pull_request_target run using the workflow file from the base branch, which prevents malicious modifications to the workflow itself. When using pull_request_target, actions/checkout defaults to checking out the base ref, making your action secure against this type of bypass.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Using pull_request_target is NOT the right answer here. But the issue is worth paying attention to. Will switch to base ref in Codeowners Plus itself

@BakerNet BakerNet changed the title Update docs to use base_ref instead of head for actions/checkout Read config and .codeowners from base ref instead of head Oct 31, 2025
@BakerNet BakerNet marked this pull request as draft October 31, 2025 00:38
@BakerNet BakerNet marked this pull request as ready for review October 31, 2025 01:22
@BakerNet BakerNet merged commit ed620ad into main Oct 31, 2025
11 of 13 checks passed
@BakerNet BakerNet deleted the checkout-base-ref branch October 31, 2025 17:22
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.

User can self approved by removing entries in .codeowner

4 participants