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

Control 0075 - Image pull policy on latest tag triggers randomly #351

Open
gnd opened this issue Mar 22, 2023 · 10 comments
Open

Control 0075 - Image pull policy on latest tag triggers randomly #351

gnd opened this issue Mar 22, 2023 · 10 comments
Labels
bug Something isn't working

Comments

@gnd
Copy link

gnd commented Mar 22, 2023

Description

The C-0075 control treats all tags without numbers as latest. This is specified in the description of the control: https://hub.armosec.io/docs/c-0075:

Note as well that some vendors don't use the word latest in the tag. Some other word may also behave like the latest. For example, Redis uses redis:alpine to signify the latest. Therefore, this control treats any word that does not contain digits as the latest. 

Sometimes it happens that the hash function assigning tags at build (eg. $CI_COMMIT_SHORT_SHA) returns a hash without any numbers. This control then triggers a false positive. We would prefer if this check would only scan for lates tag and not do any magical assumptions about the nature of tag with or without numbers.

Environment

OS: Ubuntu 22.04 LTS
Version: built latest master

Steps To Reproduce

  1. Deploy a deployment tagged with only letters such as befacaad which is an actual hash.
  2. Scan with Kubescape

Expected behavior

Kubescape should not return this as a failed control.

Actual Behavior

Kubescape does return a failed control C-0075 for image tags which don't contain numbers. This can happen randomly. We can disable this control, but then we would loose the possibility to check for actual latest tags. It would be best if the "only letters" rule would be deactivated as it will trigger random false positives/

Additional context

@gnd gnd added the bug Something isn't working label Mar 22, 2023
@craigbox craigbox transferred this issue from kubescape/kubescape Mar 27, 2023
@craigbox
Copy link
Contributor

Thanks for the bug report @gnd; I've transferred it to the repo for the controls library.

@gnd
Copy link
Author

gnd commented May 23, 2023

Hello, any news on this ?

@alegrey91
Copy link
Contributor

Hi @gnd, thanks for the bug report, and sorry for the late reply.
I just provided a fix for this rule so that you can scan it properly now.

@gnd
Copy link
Author

gnd commented May 23, 2023

Hello @alegrey91

thank you for the quick fix !

from what version of Kubescape can we expect this to be resolved ? We use latest master only to test some things, but run https://raw.githubusercontent.com/kubescape/kubescape/master/install.sh to install it in prod

@alegrey91
Copy link
Contributor

Hello @alegrey91

thank you for the quick fix !

from what version of Kubescape can we expect this to be resolved ? We use latest master only to test some things, but run https://raw.githubusercontent.com/kubescape/kubescape/master/install.sh to install it in prod

Hi, I think I've been a bit hasty with this fix. I apologize for that.
We are basically allowing only latest tags to be considered as the latest.
Since other words may also behave like the latest, we should take this into account.
So, that said, let's see what does think other maintainers about this, and let's solve this issue.
cc @YiscahLevySilas1
Alternatively, is there a way to configure this control to avoid this behavior? Maybe we can solve the issue using the --controls-config flag in kubescape? @YiscahLevySilas1 WDYT?

@YiscahLevySilas1
Copy link
Collaborator

YiscahLevySilas1 commented May 24, 2023

Hi @gnd Thanks for reporting this issue.
I understand the inconvienence of these false positives..
However, to check only latest tags as you suggested will lead to false negatives (like the redis example) which might be problematic. A solution we have in place is to "ignore" these failed images (either from the ARMO platform if you are using it, or by using the --exceptions flag), or to develop the ability to configure this control to use an allow list with the --controls-config flag like @alegrey91 suggested, but both of these would require approving each image separately. Would that be a solution that suits you?
@alegrey91 - Alternatively, maybe we could configure a boolean value (with the --controls-config like you suggested) that defines the behaviour of this control to one of the 2 ways mentioned, where the default behaviour is as it is today. WDYT?

@gnd
Copy link
Author

gnd commented May 25, 2023

Hi @YiscahLevySilas1 ,

thanks for looking into this.

Currently we can only disable the control for all namespaces. I think having it check for latest and sometimes triggering some specific images as false positives which then can be excepted is a much better approach.

I can only guess what the redis example is, since i dont see it here.

@alegrey91
Copy link
Contributor

@alegrey91 - Alternatively, maybe we could configure a boolean value (with the --controls-config like you suggested) that defines the behaviour of this control to one of the 2 ways mentioned, where the default behaviour is as it is today. WDYT?

The best way to solve this issue is to allow the user to configure its own exceptions based on the images. Are we enabled to do this through the regolibrary framework?

@craigbox
Copy link
Contributor

(Bug triage: not sure who that question was to Alessio. Was it to Yiscah?)

@XDRAGON2002
Copy link

Shouldn't it be possible to create a simple mapping as passed in the controls-inputs which a user could simply go ahead and modify to suit their exact image tags they are using? By default we would enable a bunch of commonly used latest tags and have the user make the choice as to what they want to disable?

This I believe would be a much cleaner method keeping in lieu with how some other cases have also been implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants