Skip to content

refactor(reviewbot): use separate jobs to protect access to credentials#3943

Merged
rickeylev merged 1 commit into
bazel-contrib:mainfrom
rickeylev:audit-pr-review-workflow
Jul 22, 2026
Merged

refactor(reviewbot): use separate jobs to protect access to credentials#3943
rickeylev merged 1 commit into
bazel-contrib:mainfrom
rickeylev:audit-pr-review-workflow

Conversation

@rickeylev

Copy link
Copy Markdown
Collaborator

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.

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.
@rickeylev
rickeylev requested a review from aignas as a code owner July 22, 2026 02:14
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@rickeylev
rickeylev merged commit 8cb7d1c into bazel-contrib:main Jul 22, 2026
4 of 6 checks passed
@rickeylev
rickeylev deleted the audit-pr-review-workflow branch July 22, 2026 17:08
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.

1 participant