Skip to content

pr_helper: don't assert primary-contact/CC status from an unverified commit email - #16521

Open
deelyy78 wants to merge 2 commits into
google:masterfrom
deelyy78:fix/pr-helper-unverified-email
Open

deelyy78 wants to merge 2 commits into
google:masterfrom
deelyy78:fix/pr-helper-unverified-email

Conversation

@deelyy78

Copy link
Copy Markdown

Problem

infra/pr_helper.py decides whether a PR author is a project's primary_contact or on its CC list using the author's email address. When the author's public profile email is empty, get_author_email() falls back to the author email of the PR's first commit. That value is raw git metadata — anyone can set it to an arbitrary address with git config user.email — and although the code reads GitHub's commit.verification.verified flag for that commit, main() printed the assertion

<author> is either the primary contact or is in the CCs list of projects/<x>

whether or not the email was verified. The flag only controlled a cosmetic (verified) suffix.

As a result, an attacker can set their first commit's author email to a project's (public) primary_contact, and the PR helper bot will vouch for them as the primary contact in its comment. Combined with any prior trivial commit by the attacker's login on that project path (which satisfies the separate history check), the PR also keeps IS_READY_FOR_MERGE=True, so the workflow applies the "Ready to merge" label — a manufactured trust signal on exactly the projects/** changes (Dockerfiles and build scripts executed by OSS-Fuzz build infrastructure) that this check exists to gate.

Fix

  • Only assert "primary contact / CC" status when the email is trustworthy, i.e. verified is true: the account-linked public profile email, or the first commit's author email with a GitHub-verified commit signature. Verified contacts keep the existing fast path (continue).
  • When a contact-list match rests only on unverified commit metadata, the comment now says so explicitly — "…matches an entry in the contact list of projects/, but it could not be verified. Commit author emails are set by the committer and are not proof of identity…" — and the match is not treated as coming from the contact.
  • The login-based history check is unchanged: it is keyed on the GitHub login, which cannot be spoofed, so legitimate past contributors are unaffected.
  • get_author_email()'s docstring now documents the trust semantics of the returned verified flag so future callers don't reintroduce the confusion.

Tests

Added MainContactVerificationTest (with a fake GithubHandler) to infra/pr_helper_test.py:

  • verified contact → asserted, ready, history check skipped;
  • unverified commit email matching primary_contact → not asserted, explicit unverified wording, not ready;
  • unverified commit email matching auto_ccs → not asserted, not ready;
  • unverified match + prior commit → ready via the history path only, with the unverified disclaimer and no contact assertion;
  • non-contact author with/without history → behaviour unchanged.

The three unverified-match tests fail against the current code (the bot asserts primary-contact status from the spoofed email) and pass with this change. Full file: 26 tests pass. infra/presubmit.py format and license pass on the changed files.

@google-cla

google-cla Bot commented Nov 12, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@hunsche hunsche 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.

Thanks for catching this. Please fix the mixed indentation in infra/pr_helper.py and infra/pr_helper_test.py (2-space indent) and verify that python3 -m unittest infra/pr_helper_test.py passes locally.

This branch has not been deployed

No deployments
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.

2 participants