refactor(reviewbot): use separate jobs to protect access to credentials#3943
Merged
Merged
Conversation
automated_pr_review.yaml previously checked out untrusted pull request code into the workflow root and ran uv run directly from that directory while exposing GEMINI_API_KEY. Because uv run by default searches $PWD for project build files (pyproject.toml, setup.py), an untrusted PR could trigger arbitrary code execution during workflow runs. To fix: - Split the workflow into two separate jobs: `prepare_diff` (runs in an unprivileged context without access to secrets to safely extract the git diff from untrusted PR code) and `review` (runs in the trusted base branch context with secrets, consuming only the text diff artifact without checking out untrusted PR head onto disk). - Check out the untrusted PR branch into a dedicated `untrusted_pr_head` subdirectory in `prepare_diff` so it is treated strictly as input data. - Run `uv` with `--no-project --directory .` inside `working-directory: reviewbot` to prevent `uv` from searching `$PWD` or discovering untrusted project configuration files.
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
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.
automated_pr_review.yaml previously checked out untrusted pull request code into the workflow root and ran uv run directly from that directory while exposing GEMINI_API_KEY. Because uv run by default searches $PWD for project build files (pyproject.toml, setup.py), an untrusted PR could trigger arbitrary code execution during workflow runs.
To fix:
prepare_diff(runs in an unprivileged context without access to secrets to safely extract the git diff from untrusted PR code) andreview(runs in the trusted base branch context with secrets, consuming only the text diff artifact without checking out untrusted PR head onto disk).untrusted_pr_headsubdirectory inprepare_diffso it is treated strictly as input data.uvwith--no-project --directory .insideworking-directory: reviewbotto preventuvfrom searching$PWDor discovering untrusted project configuration files.