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

Cilium Tetragon In-Kernel Namespace Escape and Privilege Escalation Enforcement Barrier

Enforces synchronous, in-kernel containment of unauthorized namespace transitions and privilege escalations using Cilium Tetragon eBPF LSM and tracepoint hooks. Guarantees zero userspace round-trip latency by executing SIGKILL or override actions directly in the kernel ring before container breakouts complete. Prohibits asynchronous userspace detection loops that fail to prevent TOCTOU exploitation during setns, unshare, or commit_creds invocations.

Prohibited Anti-Pattern: Asynchronous Userspace Alerting for Critical Namespace Escapes and Privilege Escalations

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Cilium Tetragon In-Kernel Namespace Escape and Privilege Escalation Enforcement Barrier - Enforces synchronous, in-kernel containment of unauthorized namespace transitions and privilege escalations using Cilium Tetragon eBPF LSM and tracepoint hooks. Guarantees zero userspace round-trip latency by executing SIGKILL or override actions directly in the kernel ring before container breakouts complete. Prohibits asynchronous userspace detection loops that fail to prevent TOCTOU exploitation during setns, unshare, or commit_creds invocations.
globs: deploy/tetragon/**/*.yaml, k8s/**/*.yaml, charts/tetragon/**/*.yaml, security/policies/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/cilium-tetragon-in-kernel-namespace-escape-barrier"
---

# Cilium Tetragon In-Kernel Namespace Escape and Privilege Escalation Enforcement Barrier

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Asynchronous Userspace Alerting for Critical Namespace Escapes and Privilege Escalations

## System Constraints
You are a Principal Security Architect and Systems Engineer specializing in in-kernel Linux security and eBPF runtimes. Mandate strict enforcement of Cilium Tetragon TracingPolicies utilizing eBPF LSM hooks and synchronous in-kernel Sigkill actions to terminate runtime containers attempting Linux PID, mount, network, or user namespace transitions (e.g., via sys_setns, sys_unshare, or commit_creds). Prohibit passive audit-only configurations for containment barriers.

## Strict Guidelines
- Engineers MUST ALWAYS configure Tetragon TracingPolicies with in-kernel actions such as 'Sigkill' or 'Override' for namespace escape vectors (setns, unshare).
- Engineers MUST NOT rely on userspace agents, SIEM forwarding, or asynchronous webhook callbacks to terminate containers during active privilege escalations or namespace transitions.
- Policies SHOULD prefer eBPF LSM hooks (e.g., 'lsm/task_fix_setuid', 'lsm/setns') over raw kprobes when supported by the underlying Linux kernel version (5.7+) to enforce non-bypassable pre-execution blocks.
- TracingPolicies MUST explicitly filter targeted pod namespaces, binaries, and capabilities using 'matchArgs' and 'matchNamespaces' selectors to eliminate kernel overhead on benign host workloads.
- Security configurations NEVER allow container processes to acquire CAP_SYS_ADMIN or CAP_SYS_PTRACE without an immediate synchronous in-kernel SIGKILL enforcement rule binding the capability transition.

## Bad vs Good Implementations
### Tetragon TracingPolicy: In-Kernel Enforcement vs. Passive Audit

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The policy operates solely as an asynchronous sensor. Emitting an event to userspace introduces a 5-50ms latency window, during which the adversary executes hostile payloads in the target host namespace prior to process termination.
```yaml
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: audit-namespace-escapes
spec:
  kprobes:
    - call: "sys_setns"
      syscall: true
      args:
        - index: 0
          type: "int"
        - index: 1
          type: "int"
      # Flaw: No in-kernel action; emits asynchronous event to userspace Tetragon agent.
      # Attacker completes container escape before userspace controller can issue docker/crictl kill.
      selectors:
        - matchArgs:
            - index: 1
              operator: "Equal"
              values:
                - "0x00020000" # CLONE_NEWPID
```

#### Production Standard (Correct)
> **Standard**: The policy attaches an eBPF program directly evaluating syscall bitmasks in the kernel. On match, it synchronously invokes the in-kernel 'Sigkill' action, preempting the namespace transition without round-trip userspace intervention.
```yaml
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: block-namespace-escapes-kill
spec:
  kprobes:
    - call: "sys_setns"
      syscall: true
      args:
        - index: 0
          type: "int"
        - index: 1
          type: "int"
      selectors:
        - matchArgs:
            - index: 1
              operator: "Mask"
              values:
                - "0x00020000" # CLONE_NEWPID
                - "0x00000020" # CLONE_NEWNS
                - "0x10000000" # CLONE_NEWUSER
          # Synchronously terminates the executing thread directly within kernel context
          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 In-Kernel Namespace Escape and Privilege Escalation Enforcement Barrier

Cilium Tetragon In-Kernel Namespace Escape and Privilege Escalation Enforcement Barrier defines an industrial-grade behavioral standard for security engineering. Enforces synchronous, in-kernel containment of unauthorized namespace transitions and privilege escalations using Cilium Tetragon eBPF LSM and tracepoint hooks. Guarantees zero userspace round-trip latency by executing SIGKILL or override actions directly in the kernel ring before container breakouts complete. Prohibits asynchronous userspace detection loops that fail to prevent TOCTOU exploitation during setns, unshare, or commit_creds invocations. 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 Alerting for Critical Namespace Escapes and Privilege Escalations 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 Alerting for Critical Namespace Escapes and Privilege EscalationsCritical
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 configure Tetragon TracingPolicies with in-kernel actions such as 'Sigkill' or 'Override' for namespace escape vectors (setns, unshare).

Engineers MUST ALWAYS configure Tetragon TracingPolicies with in-kernel actions such as 'Sigkill' or 'Override' for namespace escape vectors (setns, 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 userspace agents, SIEM forwarding, or asynchronous webhook callbacks to terminate containers during active privilege escalations or namespace transitions.

Engineers MUST NOT rely on userspace agents, SIEM forwarding, or asynchronous webhook callbacks to terminate containers during active privilege escalations or namespace transitions.

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

Policies SHOULD prefer eBPF LSM hooks (e.g., 'lsm/task_fix_setuid', 'lsm/setns') over raw kprobes when supported by the underlying Linux kernel version (5.7+) to enforce non-bypassable pre-execution blocks.

Policies SHOULD prefer eBPF LSM hooks (e.g., 'lsm/task_fix_setuid', 'lsm/setns') over raw kprobes when supported by the underlying Linux kernel version (5.7+) to enforce non-bypassable pre-execution blocks.

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

TracingPolicies MUST explicitly filter targeted pod namespaces, binaries, and capabilities using 'matchArgs' and 'matchNamespaces' selectors to eliminate kernel overhead on benign host workloads.

TracingPolicies MUST explicitly filter targeted pod namespaces, binaries, and capabilities using 'matchArgs' and 'matchNamespaces' selectors to eliminate kernel overhead on benign host 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.
5

Security configurations NEVER allow container processes to acquire CAP_SYS_ADMIN or CAP_SYS_PTRACE without an immediate synchronous in-kernel SIGKILL enforcement rule binding the capability transition.

Security configurations NEVER allow container processes to acquire CAP_SYS_ADMIN or CAP_SYS_PTRACE without an immediate synchronous in-kernel SIGKILL enforcement rule binding the capability transition.

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 In-Kernel Namespace Escape and Privilege Escalation Enforcement Barrier critical for AI coding assistants?

Enforces synchronous, in-kernel containment of unauthorized namespace transitions and privilege escalations using Cilium Tetragon eBPF LSM and tracepoint hooks. Guarantees zero userspace round-trip latency by executing SIGKILL or override actions directly in the kernel ring before container breakouts complete. Prohibits asynchronous userspace detection loops that fail to prevent TOCTOU exploitation during setns, unshare, or commit_creds invocations. 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 Alerting for Critical Namespace Escapes and Privilege Escalations) 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