Skip to content

gce: verify MIG membership in the TPM verifier - #18583

Open
hakman wants to merge 10 commits into
kubernetes:masterfrom
hakman:gce-tpm-verifier-mig-check
Open

gce: verify MIG membership in the TPM verifier#18583
hakman wants to merge 10 commits into
kubernetes:masterfrom
hakman:gce-tpm-verifier-mig-check

Conversation

@hakman

@hakman hakman commented Jul 12, 2026

Copy link
Copy Markdown
Member

The GCE TPM verifier read cluster-name and kops-k8s-io-instance-group-name from live instance metadata, which is set by whoever creates the VM. The TPM signature only proves control of some Shielded VM in the project, so anyone with compute.instances.create could bootstrap a rogue node into the cluster.

Do what the node identifier in pkg/nodeidentity/gce already does: confirm the instance is actually managed by the MIG named in its created-by metadata and read the cluster name and instance group name from the MIG's instance template, which cannot be changed without GCE API access. The logic is extracted into a shared helper used by both.

Also: CAPI Machines are now matched only from the given cluster, the TPM signature is checked before any other API calls, and a redundant InstanceGroupManagers.Get call is dropped. No new IAM permissions; kops-controller already makes these calls when identifying nodes.

/cc @rifelpet @justinsb

hakman added 5 commits July 12, 2026 08:54
Pure refactor: move the created-by / MIG membership / instance template
resolution out of the node identifier into GetInstanceTemplateForMIGMember,
so it can be reused by the GCE TPM verifier. No behavior change.
ListManagedInstances only needs the MIG name and zone, which are already
known at the call site, so the Get was a wasted API round-trip.
FindMachineByProviderID listed Machines cluster-wide, so a Machine from
another CAPI cluster in the same management cluster could match. Filter
by spec.clusterName; both GCE callers pass the escaped cluster name.
Reject requests with an invalid signature before fetching the instance,
so unauthenticated requests cost a single API call. Also drop a %w verb
that always formatted a nil error.
The TPM signature proves control of a Shielded VM in the project, but the
cluster and instance group were read from instance metadata, which is
settable by whoever creates a VM, so it cannot prove cluster membership.
Verify that the instance is managed by a MIG and read the cluster name
and instance group name from its instance template, as the node
identifier already does.
@kubernetes-prow
kubernetes-prow Bot requested review from justinsb and rifelpet July 12, 2026 06:24
@kubernetes-prow kubernetes-prow Bot added area/provider/gcp Issues or PRs related to gcp provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 12, 2026
@hakman

hakman commented Aug 14, 2026

Copy link
Copy Markdown
Member Author

/assign @justinsb

@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from justinsb. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow

Copy link
Copy Markdown
Contributor

@hakman: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kops-e2e-k8s-aws-amazonvpc 4590b0e link true /test pull-kops-e2e-k8s-aws-amazonvpc

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/provider/gcp Issues or PRs related to gcp provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants