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

KubeArmor is not blocking the process as expected #1839

Open
myugan opened this issue Aug 14, 2024 · 6 comments
Open

KubeArmor is not blocking the process as expected #1839

myugan opened this issue Aug 14, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@myugan
Copy link

myugan commented Aug 14, 2024

Bug Report

General Information

  • Environment description (GKE, VM-Kubeadm, vagrant-dev-env, minikube, microk8s, ...): kubeadm
  • Kernel version (run uname -a): 6.5.0-1020-aws
  • Orchestration system version in use (e.g. kubectl version, ...): v1.29.5
  • Link to relevant artifacts (policies, deployments scripts, ...)
  • Target containers/pods

To Reproduce

  1. Install KubeArmor using the Helm chart
  2. Apply the policy below to block the sleep command. Verify that the policy is successfully applied to the respective pod using karmor probe.
cat > ksp-ubuntu-proc-block.yaml <<EOL
apiVersion: security.kubearmor.com/v1
kind: KubeArmorPolicy
metadata:
  name: ksp-ubuntu-proc-block
  namespace: default
spec:
  message: "block /usr/bin/sleep"
  selector:
    matchLabels:
      os: ubuntu
  process:
    matchPaths:
    - path: /usr/bin/sleep
  action:
    Block
EOL

Expected behavior

KubeArmor must block any activities according to the created policy.

Screenshots

image
@myugan myugan added the bug Something isn't working label Aug 14, 2024
@daemon1024
Copy link
Member

Hey @myugan, Can you share how are trying to violate it and what's the output you see?
The configuration looks good to me.

Additionally can you run which sleep in the ubuntu pod and check what's the binary name?

@myugan
Copy link
Author

myugan commented Aug 14, 2024

Hello @daemon1024, I have verified that the binary of sleep appears to be correct, and I even attempted to replace it with another binary file, but it did not block either. Is there a method to display the complete debug message in order to understand why it is not blocking the action according to the policy? Additionally, the output is not appearing in the karmor logs

@daemon1024
Copy link
Member

Can we check if the Pod has apparmor annotation? Can you share the Pod/Deployment spec?

@myugan
Copy link
Author

myugan commented Aug 23, 2024

There is no annotation in the pod. Here is the manifest file.

apiVersion: v1
kind: Pod
metadata:
  name: ubuntu
  labels:
    os: ubuntu
spec:
  containers:
  - image: ubuntu
    command:
      - "sleep"
      - "604800"
    imagePullPolicy: IfNotPresent
    name: ubuntu
  restartPolicy: Always

I have checked the Pod annotation, and it says the policy is enabled as well.

...[SNIP]...
    cni.projectcalico.org/containerID: 08d1ca3a983909decb7b3a73c041105a48b6fbc70fdc69311acca739be8033ba
    cni.projectcalico.org/podIP: 192.168.94.9/32
    cni.projectcalico.org/podIPs: 192.168.94.9/32
    kubearmor-policy: enabled
    kubearmor-visibility: process,file,network,capabilities

@sh1nnyboy
Copy link

sh1nnyboy commented Sep 11, 2024

Got the same issue, any idea @daemon1024 ?

apiVersion: security.kubearmor.com/v1
kind: KubeArmorPolicy
metadata:
  name: ksp-ubuntu-net-icmp-block
  namespace: default
spec:
  selector:
    matchLabels:
      os: ubuntu-util
  network:
    matchProtocols:
    - protocol: icmp
  action:
    Block

@TheWeak3stLink
Copy link

TheWeak3stLink commented Oct 30, 2024

It seems like you have kubearmor in audit mode, not block. I'm my case I'm having the same issue, but I configured the policy in block mode using annotations:

image

Policy definiton:

apiVersion: security.kubearmor.com/v1
kind: KubeArmorPolicy
metadata:
  name: ksp-mysql-block
  namespace: default
spec:
  message: "Block /var/lib/mysql/"
  severity: 5
  selector:
    matchLabels:
      name: mysql-pod
  file:
    matchDirectories:
    - dir: /var/lib/mysql/
      recursive: true
  action:
    Block

Karmor probe output:

image

But I'm able to create files under /var/lib/mysql/ without being blocked.

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

No branches or pull requests

4 participants