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

Large policies are not consistently applied in whitelisting mode #1657

Open
pa-federici opened this issue Feb 29, 2024 · 5 comments
Open

Large policies are not consistently applied in whitelisting mode #1657

pa-federici opened this issue Feb 29, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@pa-federici
Copy link

General Information

  • Environment description eks 1.28
  • Kernel version Linux bash 5.10.192-183.736.amzn2.x86_64 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
  • Orchestration system version in use v1.28.1
  • Target issue riproduced on different containers, including on standard images from docker hub like ubuntu:23.04
  • Tested with kubearmor/kubearmor and kubearmor/kubearmor-init image versions v1.2.1

To Reproduce

  1. Create a simple of a pod manifest with ubuntu latest image with a small script at the start that opens a file in the container. For example:
    args:
    - |
      while true; do
        if cat /etc/ca-certificates.conf >/dev/null 2>&1; then
          echo "The file /etc/ca-certificates.conf has been successfully opened."
        else
          echo "Could not open the file /etc/ca-certificates.conf."
        fi
        sleep 0.5
      done
  1. Create a large kubearmor policy (my policy is about 500 lines) that match the pod created in the previous step and as a whitelist allows access to various files and folders in the pod including the one that is opened by the script
    test-policy.json

  2. Apply pod manifest

Expected behavior

we expect the pod to be created without problems and that the script, can have access to the file without any problem

Current behavior

very often it happens that the script fails to reach the file because it is blocked by the policy, even if the file is present in the whitelist

@pa-federici pa-federici added the bug Something isn't working label Feb 29, 2024
@nyrahul
Copy link
Contributor

nyrahul commented Mar 3, 2024

Following are some of my observations:

  1. the test-policy.json contains a lot of overlapping/duplicate rules ... For e.g. path /usr/ is recursively allowed and then there are individual/overlapping/dup rules to allow specific folders/file in /usr/.
  2. I tried to remove some duplications and was able to reduce the lines from 525 to 338 ...
  3. Just by adding /var/lib/ recursive file rule, I was further able to remove 256 lines ... so the final line count is 168.

PFA the updated policy test-policy-updated.yaml.txt

Hope this helps.

@pa-federici
Copy link
Author

pa-federici commented Mar 4, 2024

Hi @nyrahul, thank you for your response, however the policy I supplied was meant as a mere example for the purpose of reporting the issue. We're having similar problems with a different policy of about ~200 lines, without any overlap.

@bvenreply
Copy link

Hello @nyrahul, would you mind clarifying the status of this issue? Can the project spare any effort to fix this at the moment? Is this considered something to be fixed at all?

@nyrahul
Copy link
Contributor

nyrahul commented Mar 22, 2024

Hello @nyrahul, would you mind clarifying the status of this issue? Can the project spare any effort to fix this at the moment? Is this considered something to be fixed at all?

We pulled it up for triage today.
There needs to be some limitation that we need to put in place on the overall rules that can be applied on the given workload.
Would require some feedback from the community:

  1. What are the kind of policies that you are looking at? If samples can be provided that would help.
  2. Having too many inidivdual rules on individual files is going to be policy maintenace nightmare ... what is the sweet spot to work on?

It would be great to have some recommendations from folks who have ran into this problem.

@pa-federici
Copy link
Author

hello @nyrahul The policy we use is this ide-policy.json which is much smaller than the policy that we have given in the issue. Potentially we could also try to further reduce this policy but we would need to understand under what limit we must go to be sure that everything works properly. Considering that the problem does not appear every time and is not easy to reproduce

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
Status: No status
Status: Triage
Development

No branches or pull requests

3 participants