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.49k stars 343 forks source link

fuzz testing of KubeArmor #1367

Open nyrahul opened 1 year ago

nyrahul commented 1 year ago

Feature Request

Short Description

KubeArmor is a security tool and thus security testing of KubeArmor itself is important/imperative.

Fuzz testing involves testing all/most combinations of external inputs to the subsystem. For example, KubeArmor policies are provided by the users and thus might have unwanted effects if the policies are incorrectly formed. The intention of the fuzz testing is to ensure that appropriate input set is derived by the test tool (Google's oss-fuzz is popular) and provided as input to KubeArmor. The execution is then profiled (either using pprof/other tools) to check for any anomalies and unwanted side effects of the execution.

Tasks:

mastersans commented 7 months ago

@DelusionalOptimist I'll more research regarding all the possible components of the project that would benefits with fuzzing and will share my findings.

DelusionalOptimist commented 7 months ago

Thanks @mastersans. Was great to know about your experience with fuzz testing in the community call. Looking forward to you findings!

nyrahul commented 7 months ago

@DelusionalOptimist I'll more research regarding all the possible components of the project that would benefits with fuzzing and will share my findings.

This would be amazing to get it done! Fuzzing is an interesting topic. One good reference is Cilium fuzzing audit report.

A good first step would be to simply use go fuzzing with KubeArmor ginkgo testsuites.

mastersans commented 6 months ago

@DelusionalOptimist I wanted to ask that the kubearmor configmap handler referred here, is it referred to THIS FUNCTION. ?

DelusionalOptimist commented 5 months ago

This function is the one where KubeArmor reads the configmap data - https://github.com/kubearmor/KubeArmor/blob/a5f584c38ee7cd674d1e95a3f7ce7842212dfe12/KubeArmor/core/kubeUpdate.go#L2361

prady0t commented 4 months ago

Here is a workflow example of how we can proceed :

We can start by finding functions whose fuzz testing can potentially find vulnerabilities. We can look at the Cilium report (mentioned above) to find such functions in the Cilium repo and look for similar (if any) functions in KubeArmor.

nyrahul commented 4 months ago

@prady0t This makes complete sense to me! Automation using OSS Fuzz can be tried later once we have a single fucntion fuzz tested. Thanks

prady0t commented 4 months ago

@prady0t This makes complete sense to me! Automation using OSS Fuzz can be tried later once we have a single fucntion fuzz tested. Thanks

Do you think the function I mentioned above is a good one to write a fuzzer for?

nyrahul commented 4 months ago

@prady0t This makes complete sense to me! Automation using OSS Fuzz can be tried later once we have a single fucntion fuzz tested. Thanks

Do you think the function I mentioned above is a good one to write a fuzzer for?

KubeArmor receives external input in following ways:

  1. Policy {ContainerPolicy, HostPolicy, GlobalPolicy}
  2. ConfigMap
  3. GRPC

It is best we start with any of these and your proposal to start with ContainerPolicy makes sense to me.

prady0t commented 4 months ago

I just opened a PR. This could be a starting point as to how we wand to test ContainerPolicy. We can add more seed values, conditions and logs for a better test.

daemon1024 commented 3 months ago

Hey Folks, Thanks for the interest in the mentorship. We have certain prerequisites which we expect to be included in your application. Please include details or reference to a document for the said prerequisite in your Cover Letter / Mail to the mentors / Submit it in the issue thread / DM Mentors in CNCF Slack by 20 August 11:59PM IST

Following are the details.

Implement Fuzz testing for KubeArmor Components - https://mentorship.lfx.linuxfoundation.org/project/91bd7201-e83f-444c-9157-f82f4c56d060 Prerequisite: Write a sample fuzzer for any of your own Go project or for KubeArmor and run it with oss-fuzz base image More Details: https://google.github.io/oss-fuzz/getting-started/new-project-guide/go-lang/

prady0t commented 2 months ago

Hey @daemon1024 . We just have to write files so that our sample fuzzer is able to get compiled with oss-fuzz right? Running it can only be done once a PR (containing these files) sent to oss-fuzz repo, gets merged.