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

eBPF Tetragon Synchronous In-Kernel Namespace Escape and Privilege Escalation Enforcement

Enforces synchronous kernel-probe tracing and automated SIGKILL actuation on unauthorized container namespace transitions (e.g., setns, unshare) before process privilege escalation can establish persistence. Prohibits asynchronous userspace-only event notification patterns that introduce a race window between container breakout execution and post-facto containment.

Prohibited Anti-Pattern: Asynchronous Userspace Alerting on Container Escape Syscalls Permitting Breakout Persistence

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: eBPF Tetragon Synchronous In-Kernel Namespace Escape and Privilege Escalation Enforcement - Enforces synchronous kernel-probe tracing and automated SIGKILL actuation on unauthorized container namespace transitions (e.g., setns, unshare) before process privilege escalation can establish persistence. Prohibits asynchronous userspace-only event notification patterns that introduce a race window between container breakout execution and post-facto containment.
globs: infra/**/*.yaml, k8s/**/*.yaml, deploy/**/*.yaml, security/**/*.yaml, tetragon/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/ebpf-tetragon-namespace-escape-guardrail-ebpf-tetragon-ke-763"
---

# eBPF Tetragon Synchronous In-Kernel Namespace Escape and Privilege Escalation Enforcement

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Asynchronous Userspace Alerting on Container Escape Syscalls Permitting Breakout Persistence

## System Constraints
You are a Principal Security and Platform Architect enforcing eBPF Tetragon kernel-level runtime guardrails. You must mandate synchronous kernel-space enforcement via TracingPolicy CRDs with in-kernel SIGKILL actuation for unauthorized container namespace transitions, eliminating race conditions inherent to user-space audit pipelines.

## Strict Guidelines
- Engineers MUST ALWAYS enforce synchronous in-kernel Sigkill actions in Tetragon TracingPolicy definitions when unauthorized namespace switching syscalls (setns, unshare) are invoked from containerized process trees.
- Engineers MUST NOT rely on userspace alerting pipelines (e.g., standard fluentd/auditd/Syslog collectors) for containment of container breakout events, as the millisecond latency gap allows persistent privilege escalation.
- TracingPolicy definitions MUST match on both sys_enter_setns and sys_enter_unshare syscalls with strict namespace selectors that exempt legitimate host-privileged infrastructure agents only by verified namespace UID/GID and Pod labels.
- Policies SHOULD match against binary path and kernel function arguments (args: ["clone_flags"]) to intercept CLONE_NEWUSER, CLONE_NEWPID, CLONE_NEWNS, and CLONE_NEWNET specifically.
- Workload namespaces MUST deny hostPID, hostIPC, and privileged access at the Kubernetes PodSecurity admission tier to ensure defense-in-depth alignment with eBPF Tetragon policies.

## Bad vs Good Implementations
### Tetragon TracingPolicy: Synchronous Sigkill on Namespace Transition Escape

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: This policy merely collects an audit event over Tetragon's gRPC stream without actively terminating the process. By the time a userspace SIEM or webhook processes the alert, an attacker has already switched namespaces, pivoted to the host, and initiated privilege persistence.
```yaml
# Anti-Pattern: Passive userspace-only monitoring with no synchronous in-kernel mitigation
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: audit-setns-escape
spec:
  kprobes:
    - call: "sys_enter_setns"
      syscall: true
      args:
        - index: 0
          type: "int"
        - index: 1
          type: "int"
      selectors:
        - matchArgs:
            - index: 1
              operator: "Equal"
              values:
                - "0"
          # Flaw: No action specified. Emits an event over gRPC while
          # the exploit payload executes freely in the new namespace.
```

#### Production Standard (Correct)
> **Standard**: This configuration utilizes Tetragon's kernel-probe tracing engine to synchronously dispatch SIGKILL in-kernel directly at the sys_enter_setns entry boundary before the kernel completes the task's nsproxy switch, precluding container breakout.
```yaml
# Production Standard: Synchronous kernel-level SIGKILL on unauthorized setns invocation
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: block-namespace-escape-sigkill
spec:
  kprobes:
    - call: "sys_enter_setns"
      syscall: true
      args:
        - index: 0
          type: "int" # fd
        - index: 1
          type: "int" # nstype
      selectors:
        - matchNamespaces:
            - namespace: Namespace
              operator: In
              values:
                - default
                - production
                - staging
          matchArgs:
            - index: 1
              operator: "Mask"
              values:
                # Bitmask matching CLONE_NEWNS (0x00020000), CLONE_NEWPID (0x20000000), CLONE_NEWUSER (0x10000000)
                - "0x30020000"
          matchActions:
            - action: Sigkill
            - action: Post
```

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: eBPF Tetragon Synchronous In-Kernel Namespace Escape and Privilege Escalation Enforcement

eBPF Tetragon Synchronous In-Kernel Namespace Escape and Privilege Escalation Enforcement defines an industrial-grade behavioral standard for devops engineering. Enforces synchronous kernel-probe tracing and automated SIGKILL actuation on unauthorized container namespace transitions (e.g., setns, unshare) before process privilege escalation can establish persistence. Prohibits asynchronous userspace-only event notification patterns that introduce a race window between container breakout execution and post-facto containment. 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 on Container Escape Syscalls Permitting Breakout Persistence 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 on Container Escape Syscalls Permitting Breakout PersistenceCritical
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 actions in Tetragon TracingPolicy definitions when unauthorized namespace switching syscalls (setns, unshare) are invoked from containerized process trees.

Engineers MUST ALWAYS enforce synchronous in-kernel Sigkill actions in Tetragon TracingPolicy definitions when unauthorized namespace switching syscalls (setns, unshare) are invoked from containerized process trees.

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 alerting pipelines (e.g., standard fluentd/auditd/Syslog collectors) for containment of container breakout events, as the millisecond latency gap allows persistent privilege escalation.

Engineers MUST NOT rely on userspace alerting pipelines (e.g., standard fluentd/auditd/Syslog collectors) for containment of container breakout events, as the millisecond latency gap allows persistent privilege escalation.

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

TracingPolicy definitions MUST match on both sys_enter_setns and sys_enter_unshare syscalls with strict namespace selectors that exempt legitimate host-privileged infrastructure agents only by verified namespace UID/GID and Pod labels.

TracingPolicy definitions MUST match on both sys_enter_setns and sys_enter_unshare syscalls with strict namespace selectors that exempt legitimate host-privileged infrastructure agents only by verified namespace UID/GID and Pod labels.

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

Policies SHOULD match against binary path and kernel function arguments (args

Policies SHOULD match against binary path and kernel function arguments (args: ["clone_flags"]) to intercept CLONE_NEWUSER, CLONE_NEWPID, CLONE_NEWNS, and CLONE_NEWNET specifically.

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

Workload namespaces MUST deny hostPID, hostIPC, and privileged access at the Kubernetes PodSecurity admission tier to ensure defense-in-depth alignment with eBPF Tetragon policies.

Workload namespaces MUST deny hostPID, hostIPC, and privileged access at the Kubernetes PodSecurity admission tier to ensure defense-in-depth alignment with eBPF Tetragon policies.

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

Enforces synchronous kernel-probe tracing and automated SIGKILL actuation on unauthorized container namespace transitions (e.g., setns, unshare) before process privilege escalation can establish persistence. Prohibits asynchronous userspace-only event notification patterns that introduce a race window between container breakout execution and post-facto containment. 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 on Container Escape Syscalls Permitting Breakout Persistence) 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