kubearmor / KubeArmor

Runtime Security Enforcement System. Workload hardening/sandboxing and implementing least-permissive policies made easy leveraging LSMs (BPF-LSM, AppArmor).
https://kubearmor.io/
Apache License 2.0
1.34k stars 333 forks source link

bug(syscalls): not receiving events for audited syscalls #1269

Open DelusionalOptimist opened 1 year ago

DelusionalOptimist commented 1 year ago

NOTE: This bug is also causing frequent failures in ginkgo tests for docker.

Bug Report

General Information

To Reproduce

  1. Deploy kubearmor using https://github.com/kubearmor/KubeArmor/blob/main/KubeArmor/build/kubearmor-test-docker.yaml - the kubearmor args in this are a possible cause.
  2. Try to generate some events. Generally running ksp test suite should be fine.
    cd tests/
    ginkgo --flake-attempts=5 ksp/ syscalls/
  3. In the above, syscall test suite might fail. If it doesn't, run karmor logs --gRPC=:32767 --operation=syscall --logFilter=all, try to exec into one of the multiubuntu pods created by the above and run:
    cp `which unlink` /unlink
    touch /dummy
    unlink /dummy
  4. You won't get a log for syscall=SYS_UNLINK. However, other syscall logs like SETUID, SETGID would be working fine.

Expected behavior

Should receive logs for audited syscalls.

rksharma95 commented 1 year ago

syscall test suit is passing in ci for k3s+docker env. https://github.com/kubearmor/KubeArmor/actions/runs/5320142460/jobs/9633972722

DelusionalOptimist commented 1 year ago

@rksharma95 yes, they don't fail all the time. However they fail a lot. See the attempts for this commit for example - https://github.com/kubearmor/KubeArmor/actions/runs/5241501424. Also checkout the ginkgo test runs for main branch, you'll notice that they mostly fail while running the syscalls suite - https://github.com/kubearmor/KubeArmor/actions/workflows/ci-test-ginkgo.yml?query=branch%3Amain I've also been able to reproduce it locally. Wasn't getting any logs for the SYS_UNLINK syscall. However one needs to generate some events before it happens.

daemon1024 commented 1 year ago

Keeping it open, since it's not properly fixed