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

Zero-Latency eBPF Namespace Transition Quarantine via Tetragon TracingPolicy

Mandates in-kernel synchronous SIGKILL enforcement via Cilium Tetragon TracingPolicies on unauthorized setns and unshare syscall transitions. Eliminates user-space detection latency by terminating unauthorized PID and mount namespace boundary escapes directly within the eBPF probe context before syscall completion.

Prohibited Anti-Pattern: Asynchronous User-Space Auditing or Non-Blocking Telemetry for Container Namespace Escapes

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Zero-Latency eBPF Namespace Transition Quarantine via Tetragon TracingPolicy - Mandates in-kernel synchronous SIGKILL enforcement via Cilium Tetragon TracingPolicies on unauthorized setns and unshare syscall transitions. Eliminates user-space detection latency by terminating unauthorized PID and mount namespace boundary escapes directly within the eBPF probe context before syscall completion.
globs: deploy/**/*.yaml, k8s/**/*.yaml, policies/**/*.yaml, charts/**/templates/*.yaml, infra/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tetragon-ebpf-namespace-transition-quarantine"
---

# Zero-Latency eBPF Namespace Transition Quarantine via Tetragon TracingPolicy

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Asynchronous User-Space Auditing or Non-Blocking Telemetry for Container Namespace Escapes

## System Constraints
You are a Principal Security Architect specializing in Linux kernel security and Cilium Tetragon eBPF enforcement. Mandate zero-latency in-kernel quarantine for unauthorized namespace transitions. Ensure all Kubernetes Tetragon TracingPolicies intercept sys_setns and sys_unshare entry points, enforce synchronous Sigkill actions on containerized processes attempting PID, user, or mount namespace breakouts, and avoid relying on vulnerable post-execution user-space alerting loops.

## Strict Guidelines
- Engineers MUST ALWAYS declare 'action: Sigkill' directly in the Tetragon TracingPolicy hook to guarantee synchronous kernel-level process termination prior to syscall execution.
- Engineers MUST NOT configure namespace transition policies with purely passive 'action: Post' telemetry when protecting untrusted multi-tenant container workloads.
- TracingPolicies MUST bind explicitly to kernel symbols '__x64_sys_setns' and '__x64_sys_unshare' (or architecture-appropriate equivalents such as '__arm64_sys_setns') targeting mount (CLONE_NEWNS), PID (CLONE_NEWPID), and user (CLONE_NEWUSER) flags.
- Policies SHOULD match against container metadata using 'matchNamespaces' or 'matchArgs' selectors to exempt authorized host-level system daemons (e.g., CRI runtimes, kubelet) while strictly isolating application workloads.
- Security definitions MUST NEVER permit execution continuation if an eBPF map lookup fails; fail-closed enforcement semantics must be guaranteed.

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

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Configuring 'action: Post' merely produces an asynchronous audit event in Tetragon's JSON log stream. The attacker process executes setns/unshare synchronously in the kernel, successfully escaping the container sandbox before user-space detection tools can trigger remediation.
```yaml
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: audit-namespace-transitions
spec:
  kprobes:
    - call: "sys_setns"
      syscall: true
      args:
        - index: 0
          type: "int"
        - index: 1
          type: "int"
      # Flaw: Passive post-event emission allows container escape execution before alerting finishes
      selectors:
        - matchActions:
            - action: Post
```

#### Production Standard (Correct)
> **Standard**: Intercepts kernel entry points for setns and unshare syscalls, evaluates bitmasks for mount, PID, and user namespace transitions, and invokes 'action: Sigkill' synchronously in eBPF. The violating task is terminated instantly in kernel space before the namespace boundary is crossed.
```yaml
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: block-namespace-transitions
  annotations:
    security.policy.cilium.io/enforcement: "kernel-synchronous-sigkill"
spec:
  kprobes:
    - call: "__x64_sys_setns"
      syscall: true
      args:
        - index: 0
          type: "int"
        - index: 1
          type: "int"
      selectors:
        - matchArgs:
            - index: 1
              operator: "Mask"
              values:
                - "0x00020000" # CLONE_NEWNS (Mount namespace)
                - "0x20000000" # CLONE_NEWPID (PID namespace)
                - "0x10000000" # CLONE_NEWUSER (User namespace)
          matchActions:
            - action: Sigkill
    - call: "__x64_sys_unshare"
      syscall: true
      args:
        - index: 0
          type: "int"
      selectors:
        - matchArgs:
            - index: 0
              operator: "Mask"
              values:
                - "0x00020000" # CLONE_NEWNS
                - "0x20000000" # CLONE_NEWPID
                - "0x10000000" # CLONE_NEWUSER
          matchActions:
            - action: Sigkill
```

Recommended MCP Servers (mcp-serverlist.com)

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

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Zero-Latency eBPF Namespace Transition Quarantine via Tetragon TracingPolicy

Zero-Latency eBPF Namespace Transition Quarantine via Tetragon TracingPolicy defines an industrial-grade behavioral standard for security engineering. Mandates in-kernel synchronous SIGKILL enforcement via Cilium Tetragon TracingPolicies on unauthorized setns and unshare syscall transitions. Eliminates user-space detection latency by terminating unauthorized PID and mount namespace boundary escapes directly within the eBPF probe context before syscall completion. 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 Auditing or Non-Blocking Telemetry 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 DriftAsynchronous User-Space Auditing or Non-Blocking Telemetry 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 declare 'action

Engineers MUST ALWAYS declare 'action: Sigkill' directly in the Tetragon TracingPolicy hook to guarantee synchronous kernel-level process termination prior to syscall execution.

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 policies with purely passive 'action

Engineers MUST NOT configure namespace transition policies with purely passive 'action: Post' telemetry when protecting untrusted multi-tenant container 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

TracingPolicies MUST bind explicitly to kernel symbols '__x64_sys_setns' and '__x64_sys_unshare' (or architecture-appropriate equivalents such as '__arm64_sys_setns') targeting mount (CLONE_NEWNS), PID (CLONE_NEWPID), and user (CLONE_NEWUSER) flags.

TracingPolicies MUST bind explicitly to kernel symbols '__x64_sys_setns' and '__x64_sys_unshare' (or architecture-appropriate equivalents such as '__arm64_sys_setns') targeting mount (CLONE_NEWNS), PID (CLONE_NEWPID), and user (CLONE_NEWUSER) flags.

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 container metadata using 'matchNamespaces' or 'matchArgs' selectors to exempt authorized host-level system daemons (e.g., CRI runtimes, kubelet) while strictly isolating application workloads.

Policies SHOULD match against container metadata using 'matchNamespaces' or 'matchArgs' selectors to exempt authorized host-level system daemons (e.g., CRI runtimes, kubelet) while strictly isolating application 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 definitions MUST NEVER permit execution continuation if an eBPF map lookup fails

Security definitions MUST NEVER permit execution continuation if an eBPF map lookup fails; fail-closed enforcement semantics must be guaranteed.

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 Zero-Latency eBPF Namespace Transition Quarantine via Tetragon TracingPolicy critical for AI coding assistants?

Mandates in-kernel synchronous SIGKILL enforcement via Cilium Tetragon TracingPolicies on unauthorized setns and unshare syscall transitions. Eliminates user-space detection latency by terminating unauthorized PID and mount namespace boundary escapes directly within the eBPF probe context before syscall completion. 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 Auditing or Non-Blocking Telemetry 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

Zero-Latency