This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: cilium-tetragon-ebpf-lsm-namespace-integrity

Cilium Tetragon eBPF LSM Namespace Integrity and Breakout Prevention Invariant

Enforces synchronous in-kernel detection and immediate process termination via eBPF LSM and kprobe hooks whenever container processes attempt unauthorized namespace boundary traversal, privilege escalation, or capability tampering. Prohibits asynchronous userspace audit-only pipelines for container breakouts to ensure zero-window execution of post-escape payloads.

Prohibited Anti-Pattern: Asynchronous Userspace Auditing of Container Breakouts Permitting Arbitrary In-Host Execution

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Cilium Tetragon eBPF LSM Namespace Integrity and Breakout Prevention Invariant - Enforces synchronous in-kernel detection and immediate process termination via eBPF LSM and kprobe hooks whenever container processes attempt unauthorized namespace boundary traversal, privilege escalation, or capability tampering. Prohibits asynchronous userspace audit-only pipelines for container breakouts to ensure zero-window execution of post-escape payloads.
globs: deploy/tetragon/**/*.yaml, k8s/security/**/*.yaml, crds/**/*.yaml, charts/tetragon/**/*.yaml, policies/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/cilium-tetragon-ebpf-lsm-namespace-integrity"
---

# Cilium Tetragon eBPF LSM Namespace Integrity and Breakout Prevention Invariant

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Asynchronous Userspace Auditing of Container Breakouts Permitting Arbitrary In-Host Execution

## System Constraints
You are a Principal Security Engineer enforcing kernel-level workload isolation through Cilium Tetragon eBPF LSM and kprobe tracing policies. You strictly prohibit asynchronous userspace monitoring for privilege escalation and namespace escapes. Every policy authored must mandate synchronous kernel-space enforcement (such as Sigkill actions) on prohibited capability grants, unauthorized setns/pivot_root calls, and sensitive host path mounts.

## Strict Guidelines
- Engineers MUST ALWAYS attach synchronous enforcement actions ('action: Sigkill' or 'action: Override') to Tetragon TracingPolicies monitoring breakout syscalls ('setns', 'pivot_root', 'unshare').
- Engineers MUST NOT rely on passive audit logging or userspace SIEM alerting to mitigate container privilege escalation or host namespace breakout attempts.
- TracingPolicies MUST bind enforcement hooks to eBPF LSM programs (e.g., 'lsm/capable', 'lsm/bprm_committed_creds') when Linux kernel >= 5.7 LSM BPF is active, falling back to kprobe override mechanisms only where LSM is unsupported.
- Selectors MUST explicitly differentiate between host PID namespace execution and isolated container cgroup namespaces using 'matchNamespaces' and 'matchArgs' operators.
- Policies targeting capabilities MUST immediately terminate threads attempting to acquire 'CAP_SYS_ADMIN', 'CAP_NET_ADMIN', or 'CAP_SYS_PTRACE' inside unprivileged container boundaries.

## Bad vs Good Implementations
### Tetragon TracingPolicy Enforcing Namespace Boundary and Capability Integrity

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: This policy merely collects telemetry for sys_setns invocations. An attacker leveraging a kernel exploit or misconfigured capability will execute host-level code well before a userspace security daemon or SIEM can ingest the alert and orchestrate container termination.
```yaml
# VULNERABLE: Asynchronous userspace logging allows breakout payloads to execute
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: audit-setns-escape
  namespace: kube-system
spec:
  kprobes:
    - call: "sys_setns"
      syscall: true
      args:
        - index: 0
          type: "int"
        - index: 1
          type: "int"
      # Flaw: No synchronous termination action defined; relies on userspace log consumption
```

#### Production Standard (Correct)
> **Standard**: This policy binds kernel probes directly to containerized namespaces and executes an immediate in-kernel 'Sigkill' before the unauthorized namespace transition or privilege check completes, preventing code execution in the target namespace.
```yaml
# SECURE: In-kernel synchronous termination via Sigkill before userspace transition
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: block-namespace-breakout
  namespace: kube-system
spec:
  kprobes:
    - call: "__x64_sys_setns"
      syscall: true
      args:
        - index: 0
          type: "int"
        - index: 1
          type: "int"
      selectors:
        - matchNamespaces:
            - namespace: Pid
              operator: NotIn
              values:
                - "host"
          matchActions:
            - action: Sigkill
  lsm:
    - hook: "capable"
      args:
        - index: 0
          type: "int"
      selectors:
        - matchArgs:
            - index: 0
              operator: "Equal"
              values:
                - "21" # CAP_SYS_ADMIN
          matchNamespaces:
            - namespace: Pid
              operator: NotIn
              values:
                - "host"
          matchActions:
            - action: Sigkill
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Recommended Agent Skills (askills.dev)

Ready-to-use executable skill functions tailored to this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Cilium Tetragon eBPF LSM Namespace Integrity and Breakout Prevention Invariant

Cilium Tetragon eBPF LSM Namespace Integrity and Breakout Prevention Invariant defines an industrial-grade behavioral standard for security engineering. Enforces synchronous in-kernel detection and immediate process termination via eBPF LSM and kprobe hooks whenever container processes attempt unauthorized namespace boundary traversal, privilege escalation, or capability tampering. Prohibits asynchronous userspace audit-only pipelines for container breakouts to ensure zero-window execution of post-escape payloads. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.

Framework Paradigm Shift & Drift MechanicsLLMs are trained on millions of open-source repositories containing outdated code, legacy idioms, and unpatched antipatterns. When coding assistants generate implementations for this stack, they default to common statistical tokens: Asynchronous Userspace Auditing of Container Breakouts Permitting Arbitrary In-Host Execution Without an explicit system instruction file, developers spend hours debugging silent failures.
Failure Modes & Production Blast Radius

Hazard Analysis: What Breaks Without This Rule

The following failure modes have been cataloged from hundreds of hours of production code reviews where AI assistants produced non-compliant implementations:

Failure ModeAI Symptom (The Anti-Pattern)SeverityProduction Impact & Remedy
AI Hallucination & Deprecation DriftAsynchronous Userspace Auditing of Container Breakouts Permitting Arbitrary In-Host ExecutionCritical
Violating this industrial standard introduces regression bugs, security risks, and unexpected runtime failures in production.
Enforce explicit behavioral system directives across all AI coding assistants in your repository.
Silent Architecture InconsistencyAI assistants produce mixed paradigms across files, creating fragmented codebase conventions.Medium
Increases cognitive load during code reviews and leads to maintenance debt across engineering teams.
Pin project conventions in .cursor/rules, CLAUDE.md, and AGENTS.md so all team agents follow identical guardrails.
Architectural Directives in Detail

Step-by-Step Production Directives

Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:

1

Engineers MUST ALWAYS attach synchronous enforcement actions ('action

Engineers MUST ALWAYS attach synchronous enforcement actions ('action: Sigkill' or 'action: Override') to Tetragon TracingPolicies monitoring breakout syscalls ('setns', 'pivot_root', 'unshare').

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
2

Engineers MUST NOT rely on passive audit logging or userspace SIEM alerting to mitigate container privilege escalation or host namespace breakout attempts.

Engineers MUST NOT rely on passive audit logging or userspace SIEM alerting to mitigate container privilege escalation or host namespace breakout attempts.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
3

TracingPolicies MUST bind enforcement hooks to eBPF LSM programs (e.g., 'lsm/capable', 'lsm/bprm_committed_creds') when Linux kernel >= 5.7 LSM BPF is active, falling back to kprobe override mechanisms only where LSM is unsupported.

TracingPolicies MUST bind enforcement hooks to eBPF LSM programs (e.g., 'lsm/capable', 'lsm/bprm_committed_creds') when Linux kernel >= 5.7 LSM BPF is active, falling back to kprobe override mechanisms only where LSM is unsupported.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
4

Selectors MUST explicitly differentiate between host PID namespace execution and isolated container cgroup namespaces using 'matchNamespaces' and 'matchArgs' operators.

Selectors MUST explicitly differentiate between host PID namespace execution and isolated container cgroup namespaces using 'matchNamespaces' and 'matchArgs' operators.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
5

Policies targeting capabilities MUST immediately terminate threads attempting to acquire 'CAP_SYS_ADMIN', 'CAP_NET_ADMIN', or 'CAP_SYS_PTRACE' inside unprivileged container boundaries.

Policies targeting capabilities MUST immediately terminate threads attempting to acquire 'CAP_SYS_ADMIN', 'CAP_NET_ADMIN', or 'CAP_SYS_PTRACE' inside unprivileged container boundaries.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
Technical Questions & Answers

Frequently Asked Technical Questions

Common questions developers face when configuring AI coding assistants for this stack:

Q:Why is Cilium Tetragon eBPF LSM Namespace Integrity and Breakout Prevention Invariant critical for AI coding assistants?

Enforces synchronous in-kernel detection and immediate process termination via eBPF LSM and kprobe hooks whenever container processes attempt unauthorized namespace boundary traversal, privilege escalation, or capability tampering. Prohibits asynchronous userspace audit-only pipelines for container breakouts to ensure zero-window execution of post-escape payloads. Without explicit behavioral boundaries, AI coding assistants (Cursor, Claude Code, Windsurf, Codex) rely on training data averages, which frequently produce deprecated, inefficient, or vulnerable code patterns.

Q:How does adopting this rule prevent AI hallucinations?

This rule explicitly declares what the AI must avoid (Asynchronous Userspace Auditing of Container Breakouts Permitting Arbitrary In-Host Execution) and prescribes verified positive examples. Grounding the LLM with negative and positive pairs eliminates guesswork.

Q:Which AI coding environments are supported?

This specification is multi-platform compatible: Cursor (.cursor/rules/*.mdc & .cursorrules), Anthropic Claude Code (CLAUDE.md), Windsurf (.windsurfrules), Codex / Cline (AGENTS.md), and GitHub Copilot (.github/copilot-instructions.md).

Q:Can I combine this rule with other technology stacks?

Yes. Use the Interactive Stack Builder or download an Agent Pack to merge this rule with other frontend, backend, database, security, and DevOps rules without syntax collision.

Open Specification · CC BY 4.0·Free for Personal, Team & Commercial In-Repo Use

Citation & Open Source Attribution Guidelines

This specification is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). You are completely free to adapt and share this rule in your workspace. If citing, including in public AI benchmark datasets, or redistributing, attribution to AgentRules.org is required.

1 Rule in Stack

Cilium