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

eBPF LSM Tetragon Synchronous Kernel-Space Namespace Escape Containment

Enforces in-kernel synchronous interception and termination of unauthorized container namespace crossings, capability gains, and privilege escalations using Cilium Tetragon and eBPF LSM hooks. Mandates proactive SIGKILL enforcement at the kernel level to eliminate asynchronous userspace audit bypasses and race conditions during container escapes.

Prohibited Anti-Pattern: Relying on Asynchronous Userspace Audit Logs and Post-Facto SIEM Alerts for Container Namespace Escapes

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: eBPF LSM Tetragon Synchronous Kernel-Space Namespace Escape Containment - Enforces in-kernel synchronous interception and termination of unauthorized container namespace crossings, capability gains, and privilege escalations using Cilium Tetragon and eBPF LSM hooks. Mandates proactive SIGKILL enforcement at the kernel level to eliminate asynchronous userspace audit bypasses and race conditions during container escapes.
globs: k8s/**/*.yaml, deploy/**/*.yaml, security/tetragon/**/*.yaml, helm/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/ebpf-lsm-tetragon-namespace-escape-containment"
---

# eBPF LSM Tetragon Synchronous Kernel-Space Namespace Escape Containment

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Relying on Asynchronous Userspace Audit Logs and Post-Facto SIEM Alerts for Container Namespace Escapes

## System Constraints
You are a Principal Security Architect enforcing real-time, synchronous kernel-level containment using eBPF LSM and Cilium Tetragon. Never permit audit-only or post-execution monitoring solutions for namespace boundary transitions, mount namespace tampering, setns, or unshare operations in production container environments.

## Strict Guidelines
- Engineers MUST ALWAYS enforce synchronous in-kernel Sigkill terminations via Tetragon TracingPolicy CRDs targeting kernel LSM hooks (`security_bprm_creds_for_exec`, `security_file_open`) and syscall probes.
- Engineers MUST NOT configure namespace transition detection as passive audit-only alerts (`action: Post`) when sensitive syscalls like `setns` or `unshare` are executed outside baseline workloads.
- Code SHOULD explicitly isolate untrusted pod binaries by specifying PID, MNT, and USER namespace invariant checks inside Tetragon `matchNamespaces` and `matchArgs` selectors.
- Services MUST bind Tetragon policies to LSM bpf probe types (`kprobe` fallback only when LSM kernel compile flags `CONFIG_BPF_LSM` are unavailable) to eliminate Time-of-Check to Time-of-Use (TOCTOU) races.
- Components NEVER permit execution of binaries acquiring effective `CAP_SYS_ADMIN`, `CAP_SYS_PTRACE`, or `CAP_DAC_OVERRIDE` unless declared in a statically pinned, cryptographically verified allowlist.

## Bad vs Good Implementations
### Enforce In-Kernel Sigkill on Unauthorized setns Syscall Execution

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Passive auditing using action: Post defers processing to userspace. An attacker executing setns or unshare can pivot into the root host namespace, wipe audit logs, or kill the user daemon before detection triggers.
```yaml
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: audit-setns-escape
spec:
  kprobes:
    - call: "sys_setns"
      syscall: true
      args:
        - index: 0
          type: "int"
        - index: 1
          type: "int"
      # Flaw: Only logs event asynchronously to stdout/userspace agent; container has already escaped
      selectors:
        - matchActions:
            - action: Post
```

#### Production Standard (Correct)
> **Standard**: By specifying `action: Sigkill` on the `sys_setns` probe with a namespace check, the kernel eBPF program dispatches a terminating signal directly within the kernel context before execution resumes in userspace, preempting any boundary traversal.
```yaml
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: block-namespace-escape
spec:
  kprobes:
    - call: "sys_setns"
      syscall: true
      args:
        - index: 0
          type: "int"
        - index: 1
          type: "int"
      selectors:
        - matchNamespaces:
            - namespace: Pid
              operator: NotIn
              values: ["host"]
          matchActions:
            # Synchronous in-kernel termination stops execution instantly
            - action: Sigkill
```

Recommended Agent Skills (askills.dev)

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

Architectural Specification & Invariant Rationale

Architectural Invariant Design: eBPF LSM Tetragon Synchronous Kernel-Space Namespace Escape Containment

eBPF LSM Tetragon Synchronous Kernel-Space Namespace Escape Containment defines an industrial-grade behavioral standard for security engineering. Enforces in-kernel synchronous interception and termination of unauthorized container namespace crossings, capability gains, and privilege escalations using Cilium Tetragon and eBPF LSM hooks. Mandates proactive SIGKILL enforcement at the kernel level to eliminate asynchronous userspace audit bypasses and race conditions during container escapes. 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: Relying on Asynchronous Userspace Audit Logs and Post-Facto SIEM Alerts for Container Namespace Escapes 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 DriftRelying on Asynchronous Userspace Audit Logs and Post-Facto SIEM Alerts for Container Namespace EscapesCritical
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 enforce synchronous in-kernel Sigkill terminations via Tetragon TracingPolicy CRDs targeting kernel LSM hooks (`security_bprm_creds_for_exec`, `security_file_open`) and syscall probes.

Engineers MUST ALWAYS enforce synchronous in-kernel Sigkill terminations via Tetragon TracingPolicy CRDs targeting kernel LSM hooks (`security_bprm_creds_for_exec`, `security_file_open`) and syscall probes.

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 configure namespace transition detection as passive audit-only alerts (`action

Engineers MUST NOT configure namespace transition detection as passive audit-only alerts (`action: Post`) when sensitive syscalls like `setns` or `unshare` are executed outside baseline workloads.

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

Code SHOULD explicitly isolate untrusted pod binaries by specifying PID, MNT, and USER namespace invariant checks inside Tetragon `matchNamespaces` and `matchArgs` selectors.

Code SHOULD explicitly isolate untrusted pod binaries by specifying PID, MNT, and USER namespace invariant checks inside Tetragon `matchNamespaces` and `matchArgs` selectors.

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

Services MUST bind Tetragon policies to LSM bpf probe types (`kprobe` fallback only when LSM kernel compile flags `CONFIG_BPF_LSM` are unavailable) to eliminate Time-of-Check to Time-of-Use (TOCTOU) races.

Services MUST bind Tetragon policies to LSM bpf probe types (`kprobe` fallback only when LSM kernel compile flags `CONFIG_BPF_LSM` are unavailable) to eliminate Time-of-Check to Time-of-Use (TOCTOU) races.

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

Components NEVER permit execution of binaries acquiring effective `CAP_SYS_ADMIN`, `CAP_SYS_PTRACE`, or `CAP_DAC_OVERRIDE` unless declared in a statically pinned, cryptographically verified allowlist.

Components NEVER permit execution of binaries acquiring effective `CAP_SYS_ADMIN`, `CAP_SYS_PTRACE`, or `CAP_DAC_OVERRIDE` unless declared in a statically pinned, cryptographically verified allowlist.

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 eBPF LSM Tetragon Synchronous Kernel-Space Namespace Escape Containment critical for AI coding assistants?

Enforces in-kernel synchronous interception and termination of unauthorized container namespace crossings, capability gains, and privilege escalations using Cilium Tetragon and eBPF LSM hooks. Mandates proactive SIGKILL enforcement at the kernel level to eliminate asynchronous userspace audit bypasses and race conditions during container escapes. 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 (Relying on Asynchronous Userspace Audit Logs and Post-Facto SIEM Alerts for Container Namespace Escapes) 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

eBPF