Skip to content

ci: harden lint workflows against credential exposure in fork PRs#586

Open
KevinZhao wants to merge 1 commit intogoogleapis:mainfrom
KevinZhao:fix/ci-harden-lint-workflows
Open

ci: harden lint workflows against credential exposure in fork PRs#586
KevinZhao wants to merge 1 commit intogoogleapis:mainfrom
KevinZhao:fix/ci-harden-lint-workflows

Conversation

@KevinZhao
Copy link
Copy Markdown

Summary

The four lint workflows (lint-toolbox-core, lint-toolbox-adk, lint-toolbox-langchain, lint-toolbox-llamaindex) currently run the label-removal step and the lint steps in a single job. This means the lint steps — which check out and execute fork PR code (pip install -r requirements.txt, pip install .[test]) — run with pull-requests: write and issues: write permissions that are only needed by the label-removal step.

This PR splits each workflow into two jobs:

  • remove-label: has write permissions, does NOT check out or execute any PR code
  • lint: checks out and runs PR code, but only has contents: read permission

Also adds persist-credentials: false to the checkout step so the GITHUB_TOKEN is not stored in ~/.git-credentials where subsequent steps could read it.

This follows the same hardening pattern applied to googleapis/genai-toolbox in commits 949e8242 and 3f83c497.

Reference

@KevinZhao KevinZhao requested a review from a team as a code owner March 13, 2026 15:15
@anubhav756 anubhav756 force-pushed the fix/ci-harden-lint-workflows branch from 9ca4fac to 70ee55f Compare March 16, 2026 12:18
Copy link
Copy Markdown
Contributor

@anubhav756 anubhav756 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

@anubhav756 anubhav756 force-pushed the fix/ci-harden-lint-workflows branch 3 times, most recently from f40418b to 2a6d843 Compare March 25, 2026 06:50
@anubhav756 anubhav756 added the priority: p2 Moderately-important priority. Fix may not be included in next release. label Mar 31, 2026
Split the single lint job into two separate jobs to follow the
principle of least privilege:

- remove-label: runs with write permissions but does NOT check out
  or execute any PR code
- lint: checks out and executes PR code but only has read permissions

Also add persist-credentials: false to the checkout step to prevent
the GITHUB_TOKEN from being stored in git credentials where it could
be read by subsequent steps.

This follows the same pattern applied to googleapis/genai-toolbox in
commits 949e8242 and 3f83c497.

Reference: https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
@anubhav756 anubhav756 force-pushed the fix/ci-harden-lint-workflows branch from 2a6d843 to f3da408 Compare March 31, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: p2 Moderately-important priority. Fix may not be included in next release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants