Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

faulty kubectl verification #534

Open
A-hole-mf opened this issue Mar 22, 2023 · 0 comments · May be fixed by #543
Open

faulty kubectl verification #534

A-hole-mf opened this issue Mar 22, 2023 · 0 comments · May be fixed by #543

Comments

@A-hole-mf
Copy link

https://github.com/aquasecurity/kube-hunter/blob/a5787264956581d47e5bafae7dc6b475dc8e7e0f/kube_hunter/modules/discovery/kubectl.py

Behaves faulty, the function def get_kubectl_binary_version(self): seems to fail?
We tried the function offline on the target and noticed that it fails, even if the command "kubectl version --client" gives the expected output.

def get_kubectl_binary_version(self):
version = None
try:
# kubectl version --client does not make any connection to the cluster/internet whatsoever.
version_info = subprocess.check_output("kubectl version --client", stderr=subprocess.STDOUT)
if b"GitVersion" in version_info:
# extracting version from kubectl output
version_info = version_info.decode()
start = version_info.find("GitVersion")
version = version_info[start + len("GitVersion':"") : version_info.find('",', start)]
except Exception:
logger.debug("Could not find kubectl client")
return version

We end up in the exception, even if the expected output of the subprocess command is valid on the system?.
We think that a quick fix might be to add shell=True?

Thanks!

@sgaist sgaist linked a pull request Oct 14, 2023 that will close this issue
3 tasks
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 a pull request may close this issue.

1 participant