Skip to main content

3 posts tagged with "performance"

View All Tags

· 6 min read
Atharva Shah

We're excited to announce a powerful new security capability in KubeArmor: USB Device Audit and Enforcement, now available in KubeArmor Host Policies. This feature, introduced in PR #2194 and tracking Issue #2165, significantly extends KubeArmor's runtime security scope, moving beyond processes, files, and networks to secure the physical hardware layer of your nodes and VMs.

Want to see it in action? Check out this demo video:

How USBs are a Physical Attack Vector

In any secure environment, physical access is a critical threat vector. USB devices, while ubiquitous, introduce substantial risks:

  • Data Exfiltration: Unauthorized USB mass storage devices can be used to easily copy and steal sensitive data.
  • Malicious Peripherals: Devices posing as keyboards (like "BadUSBs") can execute key-logging attacks or inject malicious commands.
  • Firmware-Based Attacks: Sophisticated attacks can target the device firmware itself.

Controlling which devices can be attached to a host is a critical part of a defense-in-depth strategy and a common requirement for regulatory compliance.

The Solution - The KubeArmor USB Device Handler

The new USB Device Handler gives you granular, policy-based control over USB devices at the host level. You can now create KubeArmor Host Policies to audit (log) or block (deauthorize) specific devices or entire classes of devices based on their attributes.

alt text

How It Works Under the Hood

To provide robust, low-level control, the USB Device Handler operates by directly interacting with the Linux kernel:

  1. Monitoring Kernel U-events: The handler listens to kernel U-events via a Netlink socket. The kernel emits these events whenever a USB device is attached or removed.
  2. Device Enumeration: When a device is attached, the kernel enumerates it, reading its descriptors to identify its class, subClass, protocol, and other attributes. This information is included in the U-event.
  3. Policy Matching: The USB Device Handler receives this U-event and matches the device's attributes against all applied KubeArmorHostPolicy resources.
  4. sysfs Enforcement: Based on the policy's action (Audit or Block), the handler enforces control using sysfs-based authorization.
    • It writes a 1 (authorize) or 0 (deauthorize) to the device's authorized file within the sysfs pseudo-file system (e.g., /sys/bus/usb/devices/.../authorized).
    • Writing 0 instantly deauthorizes the device, unbinding its drivers and making it unusable by the system, effectively blocking it.

This mechanism ensures that even if a device is physically plugged in, it cannot be accessed or used by the host operating system if a "Block" policy is in place.

Configuration and Setting Up the USB Device Handler

To enable this feature, you need to update your KubeArmor configuration.

  1. Enable the Handler: You must set two flags to true:

    • enableKubeArmorHostPolicy: true
    • enableUSBDeviceHandler: true

    If you are running KubeArmor in Kubernetes, you will need to patch the DaemonSet. For systemd (non-Kubernetes) mode, you will add these flags to your configuration file.

  2. Set the Default Posture: A new flag, hostDefaultDevicePosture, is also available. This flag (which defaults to audit) determines the action KubeArmor will take on devices that do not match any policy when running in allow-list mode (when there is at least one allow-based policy applied).

    • audit (Default): Unmatched devices are audited.
    • block: Unmatched devices are automatically blocked.

Monitoring Device Events

You can easily monitor USB device alerts and logs using the karmor CLI:

# Listen for device-specific operations (both logs and alerts)
karmor log --operation device --log-filter all

alt text

Policy in Action - Use Cases

A new device block is now available in the KubeArmorHostPolicy spec. You can match devices based on class, subClass, protocol, and level (attachment level).

Example 1: Audit All Mass Storage Devices

This policy creates an Audit alert every time a USB mass storage device is attached. This is perfect for gaining visibility and meeting compliance requirements without being disruptive.

apiVersion: security.kubearmor.com/v1
kind: KubeArmorHostPolicy
metadata:
name: hsp-device-mass-storage-audit
spec:
nodeSelector:
matchLabels:
kubernetes.io/hostname: your-node-name # Target a specific node
severity: 5
device:
matchDevice:
# Class can be a string (e.g., "MASS-STORAGE")
# or its numeric ID (e.g., 8)
- class: MASS-STORAGE
action: Audit # Logs the event

Example 2: Block All Mass Storage Devices

To prevent data exfiltration, you can simply change the action to Block.

apiVersion: security.kubearmor.com/v1
kind: KubeArmorHostPolicy
metadata:
name: hsp-device-mass-storage-block
spec:
nodeSelector:
matchLabels:
kubernetes.io/hostname: your-node-name
severity: 8 # Higher severity for a block
device:
matchDevice:
- class: MASS-STORAGE
action: Block # Blocks the device

Example 3: Block Specific Malicious-Type Devices (e.g., Keyboards)

This policy demonstrates how to use more granular fields to block devices that identify as a keyboard (a common vector for BadUSB attacks).

apiVersion: security.kubearmor.com/v1
kind: KubeArmorHostPolicy
metadata:
name: hsp-device-hid-keyboard-block
spec:
nodeSelector:
matchLabels:
kubernetes.io/hostname: your-node-name
severity: 10
device:
matchDevice:
- class: HID # Human Interface Device
subClass: 1 # Boot Interface Sub-class
protocol: 1 # Keyboard
action: Block

Policy Specificity Matters

The USB Device Handler respects policy priority: the most specifically defined policy wins.

For example, if you have two policies:

  1. Block class: MASS-STORAGE
  2. Allow class: MASS-STORAGE, subClass: 6, protocol: 80

The handler will allow a device that matches the second, more specific policy (a mass storage device with subclass 6 and protocol 80), while still blocking all other mass storage devices. This allows you to create fine-grained allow-lists for specific, approved corporate devices.

Policy In Action - Exact Match, Match All, Allow Based Examples

You can create policies using exact matches, match-all conditions, and allow-based approaches.

Exact Match Example - Audit a Specific USB Device:

apiVersion: security.kubearmor.com/v1
kind: KubeArmorHostPolicy
metadata:
name: hsp-kubearmor-dev-dvc-audit
spec:
nodeSelector:
matchLabels:
kubernetes.io/hostname: aryan
severity: 5
device:
matchDevice:
- class: MASS-STORAGE
action: Audit

Logs (after attaching a USB drive and 2 other USB devices): alt text

Match All Example - Block All USB Devices:

apiVersion: security.kubearmor.com/v1
kind: KubeArmorHostPolicy
metadata:
name: hsp-kubearmor-dev-dvc-audit
spec:
nodeSelector:
matchLabels:
kubernetes.io/hostname: aryan
severity: 5
device:
matchDevice:
- class: ALL
action: Audit

Logs (after attaching 3 different USB devices): alt text

Allow Based Example

apiVersion: security.kubearmor.com/v1
kind: KubeArmorHostPolicy
metadata:
name: hsp-kubearmor-dev-dvc-audit
spec:
nodeSelector:
matchLabels:
kubernetes.io/hostname: aryan
severity: 5
device:
matchDevice:
- class: ALL
action: Allow

alt text

When No Policy is Set:

alt text

For non-k8s mode:

apiVersion: security.kubearmor.com/v1
kind: KubeArmorHostPolicy
metadata:
name: hsp-kubearmor-dev-dvc-audit
spec:
nodeSelector:
matchLabels:
kubearmor.io/hostname: aryan
severity: 5
device:
matchDevice:
- class: ALL
action: Audit

alt text

Conclusion

The new USB Device Enforcement feature brings critical, hardware-level runtime security to your KubeArmor-protected hosts. You can now gain full visibility into device events, prevent unauthorized USB access, and build a more resilient security posture against physical threats.

A special thanks to AryanBakliwal for contributing this major feature.

· 3 min read
Rishabh Soni

cover

Why OCI Hooks Matter in Modern Cloud Workloads

What are OCI Hooks?

OCI (Open Container Initiative) hooks are standard, custom binaries that the container runtime executes at specific points in a container’s lifecycle.

Lifecycle of a Container with OCI Hooks

In practice, when a container runtime (like CRI-O or containerd) launches a container, it consults the OCI configuration (or NRI plugin) and executes any configured hooks at the appropriate stages.

  • Create runtime: After the runtime unpacks the container image and sets up namespaces, it runs the create runtime hook. For example, this could be used to register the container with monitoring tools.

  • Poststop: When the container process exits, the poststop hook is run. For example, this function can log the shutdown or trigger cleanup.

The OCI spec mandates hooks be executed in order, and the container’s state is passed via stdin, allowing the hook to identify the container (by ID, metadata, etc.).

⚠️ Note: A hook execution failure can abort container creation.

Why KubeArmor Introduced OCI Hooks Support

Before OCI hooks, KubeArmor obtained container events by mounting the container runtime’s Unix socket inside its pod and polling it.

  • This has serious security drawbacks:
    • Access to the CRI socket allows creating/deleting containers
    • Breaks container isolation
    • Is considered a security flaw

OCI hooks eliminate this dependency by giving KubeArmor event-driven access to container lifecycle data—securely.

old-arch new-arch

How KubeArmor Integrates with OCI Hooks

  • KubeArmor is typically deployed as a DaemonSet on each node.
  • It uses eBPF programs attached to LSM hooks (AppArmor/SELinux) to monitor syscalls.
  • For OCI hook support:
    • A hook binary is placed on the host by the KubeArmor Operator.
    • Its path is configured in the runtime’s hook JSON.
    • On a container lifecycle event, the runtime invokes the hook binary.
    • This binary collects container info (PID, namespace IDs, AppArmor profile) from /proc.
    • It sends the info to the KubeArmor daemon over a Unix socket (ka.sock).
    • KubeArmor then registers/unregisters the container in real time.

✅ All without mounting or polling any CRI runtime socket.

block-diagram

Use Cases Enabled by OCI Hooks

  • Eliminate Socket Privileges: No need for privileged access to CRI sockets → drastically improved security.

  • Richer Context: Hook runs on host → accesses container configuration directly (AppArmor/SELinux, namespaces, image layers).

  • Broader Environment Coverage: Works even in environments where CRI sockets aren’t accessible (as long as OCI hooks are supported).

Roadmap: What’s Next for OCI Hooks in KubeArmor

OCI hooks support is currently experimental. Future plans include:

  • Auto Deploy NRI Injector

    • Automate deployment via KubeArmor Operator
    • Eliminate manual installation of NRI on every node
  • Broader Runtime Support

    • Add Podman support using OCI hooks
    • Use hooks as a default integration pattern for new runtimes

References & Resources

· 8 min read
Rudraksh Pareek

Benchmarking data

Config

  • Node: 4
  • Platform - AKS
  • Workload -> Sock-shop
  • replica: 1
  • Tool -> Apache-bench (request at front-end service)
  • Vm: DS_v2
VMCPURamData disksTemp Storage
DS2_v227 GiB814 GiB

Without Kubearmor

Average

ScenarioRequestsConcurrent RequestsKubearmor CPU (m)Kubearmor Memory (Mi)Throughput (req/s)Average time per req. (ms)# Failed requestsMicro-service CPU (m)Micro-service Memory (Mi)
no kubearmor500005000--2205.5020.45340401.1287.3333333
Readings
ScenarioRequestsConcurrent RequestsKubearmor CPU (m)Kubearmor Memory (Mi)Throughput (req/s)Average time per req. (ms)# Failed requestsMicro-service CPU (m)Micro-service Memory (Mi)
no kubearmor500005000--2246.790.4450380239
--------------------
no kubearmor500005000--2187.220.4570378358
no kubearmor500005000--2244.160.4460451258
no kubearmor500005000--2213.370.4520351304
no kubearmor500005000--2131.190.4690380251
no kubearmor500005000--2215.890.4510400326
no kubearmor500005000--2172.190.460428332
no kubearmor500005000--2195.730.4550444240
no kubearmor500005000--2206.410.4530385278
no kubearmor500005000--2242.070.4460414318
Average2205.5020.45340401.1287.3333333

Kubearmor with discovered Policy Applied

Average

ScenarioRequestsConcurrent RequestsKubearmor CPU (m)Kubearmor Memory (Mi)Throughput (req/s)Average time per req. (ms)# Failed requestsMicro-service CPU (m)Micro-service Memory (Mi)
no kubearmor500005000141.2111.92169.3580.46090438.2435.1
Readings
ScenarioRequestsConcurrent RequestsKubearmor CPU (m)Kubearmor Memory (Mi)Throughput (req/s)Average time per req. (ms)# Failed requestsMicro-service CPU (m)Micro-service Memory (Mi)
with Policy5000050001311132162.860.4620542446
with Policy5000050001391112190.720.4560457458
with Policy5000050001451122103.460.4750445395
with Policy5000050001491082155.550.4640440454
with Policy5000050001291132177.680.4590395394
with Policy5000050001601222198.530.4550435503
with Policy5000050001561172179.890.4590391451
with Policy5000050001341192196.780.4550408429
with Policy5000050001291142178.070.4590424435
with Policy5000050001401122150.040.4650445386
Average141.2111.92169.3580.46090438.2435.1

BPF LSM benchmarking data

ScenarioConfigKubeArmorMicroservices
RequestsConcurrent RequestsCPU (m)Memory (Mi)Throughput (req/s)Average time per req. (ms)# Failed requestsCPU (m)Memory (Mi)
with kubearmor500005000130991889.810.5290407324
with kubearmor5000050001201041955.260.5110446423
with kubearmor5000050001221011952.940.5120433448
with kubearmor5000050001521041931.710.5180474405
with kubearmor5000050001421081896.010.5270564413
with kubearmor5000050001101071896.950.5270416375
with kubearmor5000050001151061868.770.5350354383
with kubearmor5000050001141091877.290.5330461355
with kubearmor5000050001301051962.810.5090552380
with kubearmor5000050001021101966.190.5090351297
Average123.7105.31919.7740.5210445.8380.3
ScenarioConfigKubeArmorMicroservices
RequestsConcurrent RequestsCPU (m)Memory (Mi)Throughput (req/s)Average time per req. (ms)# Failed requestsCPU (m)Memory (Mi)
with policy5000050001031101806.060.5290431330
with policy5000050001221111836.040.5110432348
with policy5000050001231081871.020.5120505393
with policy5000050001181111915.070.5180599331
with policy5000050001211101896.340.5270405310
with policy5000050001261131896.70.5270450430
with policy5000050001171101915.790.5350408382
with policy5000050001281111885.770.5330482321
with policy5000050001221141900.960.5090433359
with policy5000050001241041887.870.5090448393
Average120.4110.21881.1620.53180459.3359.7