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

Tetragon In-Kernel Synchronous Boundary Enforcement & Namespace Escape Prevention

Enforces synchronous kernel-space process termination via eBPF Tetragon TracingPolicies for unauthorized namespace switches and privilege boundary traversal. Mandates deterministic in-kernel Sigkill actions at tracepoint and kprobe dispatchers to prevent race-window exploitation inherent to asynchronous userspace detection engines.

Prohibited Anti-Pattern: Asynchronous User-Space Audit-Only Monitoring of Container Namespace Traversal and Privilege Escalation

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tetragon In-Kernel Synchronous Boundary Enforcement & Namespace Escape Prevention - Enforces synchronous kernel-space process termination via eBPF Tetragon TracingPolicies for unauthorized namespace switches and privilege boundary traversal. Mandates deterministic in-kernel Sigkill actions at tracepoint and kprobe dispatchers to prevent race-window exploitation inherent to asynchronous userspace detection engines.
globs: deploy/**/*.yaml, k8s/**/*.yaml, infra/**/*.yaml, policies/**/*.yaml, tetragon/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/ebpf-tetragon-kernel-namespace-escape-prevention-standard"
---

# Tetragon In-Kernel Synchronous Boundary Enforcement & Namespace Escape Prevention

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Asynchronous User-Space Audit-Only Monitoring of Container Namespace Traversal and Privilege Escalation

## System Constraints
You are a Principal Security and Infrastructure Architect enforcing eBPF Tetragon in-kernel runtime invariants. You must reject any configuration relying solely on user-space telemetry or asynchronous post-execution notifications for containment breaches. Enforce TracingPolicy CRDs with synchronous Sigkill enforcement directly at kernel tracepoint dispatchers (such as sys_enter_setns, sys_enter_unshare, and commit_creds) to prevent container escape windows.

## Strict Guidelines
- TracingPolicies MUST ALWAYS specify 'action: Sigkill' on kernel call hooks intercepting unauthorized namespace transitions (e.g., sys_enter_setns, sys_enter_unshare, pivot_root).
- Engineers MUST NOT rely on asynchronous audit actions ('action: Post') alone when defining security boundaries for sensitive host and container namespaces.
- Selectors MUST explicitly match kernel namespace metadata and restrict operations based on namespace boundaries (e.g., matchNamespaces or matchArgs filtering on host namespace fds).
- Services MUST deploy Tetragon as a privileged DaemonSet with CAP_SYS_ADMIN, CAP_BPF, and CAP_PERFMON while running unprivileged workloads strictly isolated from host PID and IPC namespaces.
- TracingPolicies MUST validate target arguments using kernel-level filters (e.g., args indexing) to eliminate TOCTOU (Time-Of-Check to Time-Of-Use) race conditions before dispatcher returns.

## Bad vs Good Implementations
### In-Kernel Synchronous Termination vs. Post-Execution Audit for setns/unshare

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Using 'action: Post' merely produces an asynchronous observability event. The target process executes the setns syscall and gains host or cross-container namespace access before any user-space agent can process the alert and issue a SIGKILL.
```yaml
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: audit-namespace-escape
spec:
  kprobes:
    - call: "sys_setns"
      syscall: true
      args:
        - index: 0
          type: "int"
        - index: 1
          type: "int"
      # Flaw: Asynchronous audit allows process to switch namespaces and execute
      # malicious payload before user-space SIEM or webhook can terminate the pod.
      selectors:
        - matchActions:
            - action: Post
```

#### Production Standard (Correct)
> **Standard**: Attaching directly to the kernel entry point with 'action: Sigkill' causes the eBPF program to dispatch an immediate termination signal within the kernel context prior to completion of the namespace transition, closing the TOCTOU window.
```yaml
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: block-namespace-escape
spec:
  kprobes:
    - call: "sys_enter_setns"
      syscall: true
      args:
        - index: 0
          type: "int"
        - index: 1
          type: "int"
      selectors:
        - matchArgs:
            - index: 1
              operator: "NotEqual"
              values:
                - "0"
          matchActions:
            # Invariant: Synchronous in-kernel SIGKILL executed in BPF hook before syscall returns
            - action: Sigkill
            - action: Post
```

Recommended MCP Servers (mcp-serverlist.com)

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

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Tetragon In-Kernel Synchronous Boundary Enforcement & Namespace Escape Prevention

Tetragon In-Kernel Synchronous Boundary Enforcement & Namespace Escape Prevention defines an industrial-grade behavioral standard for devops engineering. Enforces synchronous kernel-space process termination via eBPF Tetragon TracingPolicies for unauthorized namespace switches and privilege boundary traversal. Mandates deterministic in-kernel Sigkill actions at tracepoint and kprobe dispatchers to prevent race-window exploitation inherent to asynchronous userspace detection engines. 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 User-Space Audit-Only Monitoring of Container Namespace Traversal and Privilege Escalation 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 User-Space Audit-Only Monitoring of Container Namespace Traversal and Privilege EscalationCritical
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

TracingPolicies MUST ALWAYS specify 'action

TracingPolicies MUST ALWAYS specify 'action: Sigkill' on kernel call hooks intercepting unauthorized namespace transitions (e.g., sys_enter_setns, sys_enter_unshare, pivot_root).

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 asynchronous audit actions ('action

Engineers MUST NOT rely on asynchronous audit actions ('action: Post') alone when defining security boundaries for sensitive host and container namespaces.

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

Selectors MUST explicitly match kernel namespace metadata and restrict operations based on namespace boundaries (e.g., matchNamespaces or matchArgs filtering on host namespace fds).

Selectors MUST explicitly match kernel namespace metadata and restrict operations based on namespace boundaries (e.g., matchNamespaces or matchArgs filtering on host namespace fds).

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 deploy Tetragon as a privileged DaemonSet with CAP_SYS_ADMIN, CAP_BPF, and CAP_PERFMON while running unprivileged workloads strictly isolated from host PID and IPC namespaces.

Services MUST deploy Tetragon as a privileged DaemonSet with CAP_SYS_ADMIN, CAP_BPF, and CAP_PERFMON while running unprivileged workloads strictly isolated from host PID and IPC namespaces.

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

TracingPolicies MUST validate target arguments using kernel-level filters (e.g., args indexing) to eliminate TOCTOU (Time-Of-Check to Time-Of-Use) race conditions before dispatcher returns.

TracingPolicies MUST validate target arguments using kernel-level filters (e.g., args indexing) to eliminate TOCTOU (Time-Of-Check to Time-Of-Use) race conditions before dispatcher returns.

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 Tetragon In-Kernel Synchronous Boundary Enforcement & Namespace Escape Prevention critical for AI coding assistants?

Enforces synchronous kernel-space process termination via eBPF Tetragon TracingPolicies for unauthorized namespace switches and privilege boundary traversal. Mandates deterministic in-kernel Sigkill actions at tracepoint and kprobe dispatchers to prevent race-window exploitation inherent to asynchronous userspace detection engines. 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 User-Space Audit-Only Monitoring of Container Namespace Traversal and Privilege Escalation) 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

Tetragon