Skip to content

cluster: Fix kubevirtci clone storm#601

Merged
kubevirt-bot merged 1 commit intok8snetworkplumbingwg:mainfrom
oshoval:cluster-up-fix
Mar 11, 2026
Merged

cluster: Fix kubevirtci clone storm#601
kubevirt-bot merged 1 commit intok8snetworkplumbingwg:mainfrom
oshoval:cluster-up-fix

Conversation

@oshoval
Copy link
Copy Markdown
Member

@oshoval oshoval commented Mar 10, 2026

What this PR does / why we need it:

cluster::install checks whether the existing kubevirtci clone matches the requested one by comparing both the remote URL and the tag.
The remote URL check fails when the clone was done via SSH (git@github.com:...) because the stored KUBEVIRTCI_REPO uses HTTPS (https://github.com/...).
The mismatch causes kubevirtci to be deleted and re-cloned on every invocation, wiping the cluster kubeconfig and breaking the dev workflow.

Remove the remote URL check and keep only the tag comparison.

Derived from: kubevirt/cluster-network-addons-operator#2619

Special notes for your reviewer:

Release note:

NONE

@oshoval
Copy link
Copy Markdown
Member Author

oshoval commented Mar 10, 2026

cc @ormergi

@oshoval
Copy link
Copy Markdown
Member Author

oshoval commented Mar 10, 2026

/retest

cluster::install checks whether the existing kubevirtci clone matches
the requested one by comparing both the remote URL and the tag.

The remote URL check fails when the clone was done via SSH
(git@github.com:...) because the stored KUBEVIRTCI_REPO uses HTTPS
(https://github.com/...). The mismatch causes kubevirtci to be deleted
and re-cloned on every invocation, wiping the cluster kubeconfig and
breaking the dev workflow.

Remove the remote URL check and keep only the tag comparison.
Drop the now-unused KUBEVIRTCI_REPO variable.

Derived from: kubevirt/cluster-network-addons-operator#2619
Assisted-by: Cursor (claude-4.6-sonnet-medium-thinking)
Signed-off-by: Or Shoval <oshoval@redhat.com>
@oshoval
Copy link
Copy Markdown
Member Author

oshoval commented Mar 10, 2026

/retest

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical issue causing a 'clone storm' for the kubevirtci repository during cluster installation. Previously, a mismatch in how the remote URL was identified (HTTPS vs. SSH) led to kubevirtci being repeatedly deleted and re-cloned, wiping kubeconfigs and hindering development. The changes streamline the update mechanism by removing the faulty remote URL check, ensuring kubevirtci is only re-cloned when its version tag genuinely differs, thereby stabilizing the development environment.

Highlights

  • Prevent unnecessary kubevirtci re-clones: The pull request resolves an issue where the kubevirtci repository was unnecessarily deleted and re-cloned during cluster installation, disrupting the development workflow.
  • Refined kubevirtci update logic: The logic for checking if an existing kubevirtci clone matches the requested version has been updated to only compare the repository tag, removing the problematic remote URL comparison.
  • Removed redundant remote URL check: The comparison of the remote URL, which caused false positives when kubevirtci was cloned via SSH, has been entirely removed from the cluster::install function.
Activity
  • No specific activity (comments, reviews, progress) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

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

Choose a reason for hiding this comment

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

Code Review

The pull request modifies cluster/cluster.sh by removing the cluster::_get_repo function and simplifying the cluster::install logic to only check the KUBEVIRTCI_TAG when deciding whether to remove an existing _kubevirtci directory. This change introduces a shell pattern injection vulnerability due to the unquoted use of ${KUBEVIRTCI_TAG} in the comparison, which could be exploited to bypass the version check. Additionally, removing the repository URL verification creates a security regression, as the script now trusts any repository in CLUSTER_PATH if its tag matches, potentially allowing an attacker to use a malicious repository.

Comment thread cluster/cluster.sh
if [ -d ${CLUSTER_PATH} ]; then
if [ $(cluster::_get_repo) != ${KUBEVIRTCI_REPO} -o $(cluster::_get_tag) != ${KUBEVIRTCI_TAG} ]; then
if [[ $(cluster::_get_tag) != ${KUBEVIRTCI_TAG} ]]; then
rm -rf ${CLUSTER_PATH}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

security-medium medium

The variable ${KUBEVIRTCI_TAG} is used unquoted on the right-hand side of a comparison within [[ ... ]]. In bash, this causes the right-hand side to be treated as a shell pattern (glob) rather than a literal string. If an attacker can control the value of KUBEVIRTCI_TAG (e.g., via environment variables), they could provide a pattern like * to bypass the version check, potentially leading to the use of an incorrect or malicious version of the kubevirtci repository.

Suggested change
rm -rf ${CLUSTER_PATH}
if [[ $(cluster::_get_tag) != "${KUBEVIRTCI_TAG}" ]]; then

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

interesting, but since it is just for development + from what i know [[ ]] doesn't need quotes (but not sure if in this specific case they do), its non issue here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it's for development, we don't need it to be shell-check attacker proof

Comment thread cluster/cluster.sh
if [ -d ${CLUSTER_PATH} ]; then
if [ $(cluster::_get_repo) != ${KUBEVIRTCI_REPO} -o $(cluster::_get_tag) != ${KUBEVIRTCI_TAG} ]; then
if [[ $(cluster::_get_tag) != ${KUBEVIRTCI_TAG} ]]; then
rm -rf ${CLUSTER_PATH}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

security-medium medium

The pull request removes the check that verifies the remote URL of the repository at ${CLUSTER_PATH} matches the expected KUBEVIRTCI_REPO. While this was done to support SSH clones, it introduces a security regression where the script will now trust any repository already present in ${CLUSTER_PATH} as long as it has a matching tag. This could allow an attacker to 'poison' the ${CLUSTER_PATH} directory with a malicious repository in shared environments. Consider normalizing the URLs or checking if the remote URL ends with kubevirt/kubevirtci.git to support both HTTPS and SSH while maintaining origin verification.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

its for development only so fine

@ormergi
Copy link
Copy Markdown
Collaborator

ormergi commented Mar 10, 2026

/lgtm

Copy link
Copy Markdown
Member

@RamLavi RamLavi left a comment

Choose a reason for hiding this comment

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

/approve

@kubevirt-bot
Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RamLavi

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

The pull request process is described 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

@kubevirt-bot kubevirt-bot merged commit 0a04ee1 into k8snetworkplumbingwg:main Mar 11, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants