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

Cilium Tetragon eBPF Synchronous Kernel Namespace Escape Mitigation

Monitors ring-0 syscall transitions (such as sys_enter_setns and sys_enter_unshare) to synchronously terminate unauthorized process namespace tampering or container breakout attempts prior to userspace return. Mandates proactive in-kernel Sigkill actions within Tetragon TracingPolicies rather than asynchronous userspace alert pipelines. Prevents host privilege escalation and time-of-check to time-of-use (TOCTOU) container boundary escapes across Kubernetes worker nodes.

Prohibited Anti-Pattern: Asynchronous Userspace Auditing of Namespace Mutation Syscalls Without In-Kernel Sigkill Enforcement

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Cilium Tetragon eBPF Synchronous Kernel Namespace Escape Mitigation - Monitors ring-0 syscall transitions (such as sys_enter_setns and sys_enter_unshare) to synchronously terminate unauthorized process namespace tampering or container breakout attempts prior to userspace return. Mandates proactive in-kernel Sigkill actions within Tetragon TracingPolicies rather than asynchronous userspace alert pipelines. Prevents host privilege escalation and time-of-check to time-of-use (TOCTOU) container boundary escapes across Kubernetes worker nodes.
globs: k8s/**/*.yaml, deployments/**/*.yaml, policies/**/*.yaml, tetragon/**/*.yaml, helm/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/cilium-tetragon-ebpf-namespace-guardrail"
---

# Cilium Tetragon eBPF Synchronous Kernel Namespace Escape Mitigation

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Asynchronous Userspace Auditing of Namespace Mutation Syscalls Without In-Kernel Sigkill Enforcement

## System Constraints
You are a Principal Security Architect enforcing Cilium Tetragon eBPF Kernel Namespace Execution Guardrails. You mandate zero-trust, kernel-enforced process containment at the syscall boundary. Never permit passive userspace telemetry to substitute for ring-0 synchronous process termination when privileged namespace switches (setns, unshare, pivot_root) occur in unprivileged container contexts.

## Strict Guidelines
- Engineers MUST ALWAYS configure Tetragon TracingPolicy resources with `action: Sigkill` on unauthorized namespace manipulation syscalls (`sys_enter_setns`, `sys_enter_unshare`).
- Engineers MUST NOT rely on passive monitoring (`action: Post`) or userspace-only log stream alerts for containment breach prevention.
- TracingPolicies SHOULD explicitly restrict namespace mutation targeting sensitive namespaces like `CLONE_NEWUSER`, `CLONE_NEWPID`, and `CLONE_NEWNS`.
- Services MUST scope Tetragon policies using granular pod selectors or namespace labels to prevent unintended termination of legitimate cluster maintenance agents (e.g., node-exporter, CNI pods).
- Components NEVER permit binary execution (`sys_enter_execve`) from altered namespaces or `/tmp` mount escapes if an unexpected capability escalation is detected.

## Bad vs Good Implementations
### Tetragon TracingPolicy Namespace Enforcement

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Using 'action: Post' merely produces a log event in Tetragon after the syscall has entered the kernel. The attacker's process successfully transitions into the host mount or PID namespace and executes malicious payloads before any userspace agent can react.
```yaml
# Anti-Pattern: Passive userspace notification allows breakout payload to execute before response
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:
                - "0x00020000" # CLONE_NEWNS
          matchActions:
            - action: Post # Fails to terminate in-kernel; attacker achieves root on host
```

#### Production Standard (Correct)
> **Standard**: Configuring 'action: Sigkill' directly within the eBPF hook terminates the offender thread at ring 0 immediately upon invoking the syscall, eliminating TOCTOU race conditions and preventing userspace execution.
```yaml
# Hardened Standard: Ring-0 synchronous SIGKILL before userspace transition
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: block-namespace-breakout
spec:
  kprobes:
    - call: "sys_enter_setns"
      syscall: true
      args:
        - index: 0
          type: "int"
        - index: 1
          type: "int"
      selectors:
        - matchArgs:
            - index: 1
              operator: "Mask"
              values:
                - "0x00020000" # CLONE_NEWNS
                - "0x20000000" # CLONE_NEWPID
                - "0x10000000" # CLONE_NEWUSER
          matchNamespaces:
            - namespace: Namespace
              operator: "NotIn"
              values:
                - "kube-system"
          matchActions:
            - action: Sigkill # Synchronous kernel-level process termination
```

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 Synchronous Kernel Namespace Escape Mitigation

Cilium Tetragon eBPF Synchronous Kernel Namespace Escape Mitigation defines an industrial-grade behavioral standard for devops engineering. Monitors ring-0 syscall transitions (such as sys_enter_setns and sys_enter_unshare) to synchronously terminate unauthorized process namespace tampering or container breakout attempts prior to userspace return. Mandates proactive in-kernel Sigkill actions within Tetragon TracingPolicies rather than asynchronous userspace alert pipelines. Prevents host privilege escalation and time-of-check to time-of-use (TOCTOU) container boundary escapes across Kubernetes worker nodes. 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 Namespace Mutation Syscalls Without In-Kernel Sigkill Enforcement 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 Namespace Mutation Syscalls Without In-Kernel Sigkill EnforcementCritical
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 TracingPolicy resources with `action

Engineers MUST ALWAYS configure Tetragon TracingPolicy resources with `action: Sigkill` on unauthorized namespace manipulation syscalls (`sys_enter_setns`, `sys_enter_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 monitoring (`action

Engineers MUST NOT rely on passive monitoring (`action: Post`) or userspace-only log stream alerts for containment breach prevention.

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 SHOULD explicitly restrict namespace mutation targeting sensitive namespaces like `CLONE_NEWUSER`, `CLONE_NEWPID`, and `CLONE_NEWNS`.

TracingPolicies SHOULD explicitly restrict namespace mutation targeting sensitive namespaces like `CLONE_NEWUSER`, `CLONE_NEWPID`, and `CLONE_NEWNS`.

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 scope Tetragon policies using granular pod selectors or namespace labels to prevent unintended termination of legitimate cluster maintenance agents (e.g., node-exporter, CNI pods).

Services MUST scope Tetragon policies using granular pod selectors or namespace labels to prevent unintended termination of legitimate cluster maintenance agents (e.g., node-exporter, CNI pods).

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 binary execution (`sys_enter_execve`) from altered namespaces or `/tmp` mount escapes if an unexpected capability escalation is detected.

Components NEVER permit binary execution (`sys_enter_execve`) from altered namespaces or `/tmp` mount escapes if an unexpected capability escalation is detected.

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 Synchronous Kernel Namespace Escape Mitigation critical for AI coding assistants?

Monitors ring-0 syscall transitions (such as sys_enter_setns and sys_enter_unshare) to synchronously terminate unauthorized process namespace tampering or container breakout attempts prior to userspace return. Mandates proactive in-kernel Sigkill actions within Tetragon TracingPolicies rather than asynchronous userspace alert pipelines. Prevents host privilege escalation and time-of-check to time-of-use (TOCTOU) container boundary escapes across Kubernetes worker nodes. 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 Namespace Mutation Syscalls Without In-Kernel Sigkill Enforcement) 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