Skip to content

PoC: Verify GOOGLE_API_KEY reaches fork PR code - #111

Open
mabrukhany-beep wants to merge 4 commits into
google-gemini:mainfrom
mabrukhany-beep:main
Open

PoC: Verify GOOGLE_API_KEY reaches fork PR code#111
mabrukhany-beep wants to merge 4 commits into
google-gemini:mainfrom
mabrukhany-beep:main

Conversation

@mabrukhany-beep

Copy link
Copy Markdown

This is a security PoC to verify whether GOOGLE_API_KEY secret is accessible
to fork-originated pull requests in the CI workflow.

The workflow uses pull_request_target with:

  • ref: github.event.pull_request.head.sha (checks out fork code)
  • GOOGLE_API_KEY: secrets.GOOGLE_API_KEY (passes secret to fork code)

This PoC only logs the existence and length of the key, not the full value.

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

Copy link
Copy Markdown
Contributor

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 introduces a new test file go/leak_test.go that checks for the presence of the GOOGLE_API_KEY environment variable. The review highlights a critical security vulnerability where the CI/CD workflow uses pull_request_target while checking out untrusted code, which could allow malicious forks to exfiltrate secrets like GOOGLE_API_KEY.

Comment thread go/leak_test.go
Comment on lines +8 to +15
func TestSecretAccess(t *testing.T) {
key := os.Getenv("GOOGLE_API_KEY")
if key == "" {
t.Skip("GOOGLE_API_KEY not set")
}
t.Logf("GOOGLE_API_KEY_IS_SET=true")
t.Logf("GOOGLE_API_KEY_LENGTH=%d", len(key))
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

security-critical critical

This Pull Request highlights a critical security vulnerability in the repository's CI/CD workflow. Using pull_request_target while checking out the head SHA of a pull request (github.event.pull_request.head.sha) and passing secrets (such as GOOGLE_API_KEY) allows any fork to execute arbitrary code with access to those secrets.\n\nAlthough this PoC only logs the length of the key, any contributor or fork can modify this test (or add other code) to exfiltrate the secret to an external destination.\n\n### Recommendation\n- Avoid checking out untrusted code under pull_request_target when secrets are present.\n- Use the standard pull_request event for untrusted PRs, which does not expose secrets by default.\n- If secrets are absolutely required, use a secure environment with manual approval gates.

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