-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Potential Local Privilege Escalation In Calico Install Binary. #7981
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
Comments
@Behnam-Shobiri please take a look at this one. |
@latortuga71 I'm not entirely following - are you running the Generally that is meant to run from within a container, so the I am not sure this is a privilege escalation if in order to run this you need to have access to create and run binaries in the /opt/cni/bin directory on the host already. Perhaps I am misunderstanding something? |
@latortuga71 Any update? |
@sridhartigera we are internally following this bug. Will update this issue once everything is finalized. |
Based on our investigation, we have created CVE-2024-33522 for this issue. |
hey, folks! any ETA, when Calico 3.26.5 milestone is expected to be released, where this fix was cherry-picked? |
@zemliany the fix was picked to 3.26 branch so 3.26.5 will have the fix, as mentioned in https://www.tigera.io/security-bulletins-tta-2024-001/. I am not aware of any near future plan to release 3.26.5 (at least at this moment). However, I do strongly recommend staying on the latest patch of CVE supported release (which is n and n-1 minor version; currently, 3.27 and 3.28) we do multiple upgrades and patches in each patch version. |
@Behnam-Shobiri thanks for the update! unfortunately, we cannot update straight-forward to 3.28 or to 3.27 versions due to incompatibility with the mentioned Calico version with the current Kubernetes version and Kubernetes version on what we're going to migrate as per system requirements from Calico docs https://docs.tigera.io/calico/latest/getting-started/kubernetes/requirements but 3.26 currently fits with the Kubernetes version what we're going to migrate https://docs.tigera.io/calico/3.26/getting-started/kubernetes/requirements That's why I've asked the question here |
During a security assessment i found a potential local privilege escalation with the calico install binary in
cni-plugn/pkg/install/install.go
cnii-plugin/cmd/calico.go
The binary creates the
/host/opt/cni/bin
directories if they do not already exist. Also it sets itself to be ran as a suid binary. This can potentially be abused in the following scenario. The binaries have suid bit set to run as the root user but the /host directory does not exist on the system. The abuse stems from the fact that users can control whether files are copied via environment variables. And Control Whether a directory is created or not. Finally it executes a separate binary in a directory we potentially control.The way to abuse this to privilege escalate to the root user is as follows.
cd /opt/bin/cni
then run the install binary with the following environment variables set.
TLS_ASSESTS_DIR=/ UPDATE_CNI_BINARIES=false ./install
if the /host directory doesn't exist it will be created by root user
by setting our umask before running this we can now create the needed directory that we can place a malicious calico binary that will be executed.
we can build an example payload shown below
and copy it to the directory with the name calico
cp ./calico /host/opt/cni/bin
TLS_ASSESTS_DIR=/ UPDATE_CNI_BINARIES=false ./install
will tell it to not override our malicious calico binary but it will still execute the following line
and run our payload to get code execution as root.
This is not a high severity issue by any means but i think it was worth mentioning since it did allow for privilege escalation. In that scenario where the /host folder doesn't exist but the binaries have been built and have the suid set to run as root.
Possible Solution
Instead of executing that binary. Just check if the files exists in the directory perhaps?
Your Environment
The text was updated successfully, but these errors were encountered: