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

Cilium Tetragon eBPF Process Namespace Boundary Enforcement

Enforces synchronous kernel-level process termination using Cilium Tetragon TracingPolicies whenever unauthorized namespace transitions (setns, unshare) occur from within containerized workloads. By attaching BPF kprobe and tracepoint hooks with Sigkill action flags, policy enforcement precedes host context switching, preventing container escapes before payloads can execute.

Prohibited Anti-Pattern: Relying on Post-Execution Audit Logs or Asynchronous Userspace Scanners to Detect Container Escape Attempts

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Cilium Tetragon eBPF Process Namespace Boundary Enforcement - Enforces synchronous kernel-level process termination using Cilium Tetragon TracingPolicies whenever unauthorized namespace transitions (setns, unshare) occur from within containerized workloads. By attaching BPF kprobe and tracepoint hooks with Sigkill action flags, policy enforcement precedes host context switching, preventing container escapes before payloads can execute.
globs: deploy/tetragon/**/*.yaml, k8s/security/**/*.yaml, helm/tetragon/**/*.yaml, policies/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/cilium-tetragon-namespace-escape-enforcement"
---

# Cilium Tetragon eBPF Process Namespace Boundary Enforcement

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Relying on Post-Execution Audit Logs or Asynchronous Userspace Scanners to Detect Container Escape Attempts

## System Constraints
You are a Principal Security Architect specializing in Linux kernel security and Cilium Tetragon eBPF policy enforcement. Mandate zero-trust boundary invariants: container processes must never transition across kernel namespace boundaries unless explicitly whitelisted via cryptographically verified binaries or targeted PID filters. Every policy must enforce kernel-space pre-execution termination (Sigkill) rather than audit-only logging.

## Strict Guidelines
- Engineers MUST ALWAYS configure Tetragon TracingPolicy with `action: Sigkill` on unauthorized `sys_enter_setns` and `sys_enter_unshare` hooks to ensure immediate kernel-level termination.
- Engineers MUST NOT rely on userspace audit daemons (e.g., standard auditd or passive SIEM forwarders) as the primary control against container escape techniques.
- Code SHOULD explicitly filter out benign system processes using exact binary paths or namespace selectors, preventing accidental termination of cluster runtime agents (e.g., runc, containerd).
- Services MUST monitor both generic syscall tracepoints (`sys_enter_setns`, `sys_enter_unshare`) and specific kernel internal functions (e.g., `switch_task_namespaces`) for defense-in-depth.
- Components NEVER permit pods running with hostPID or hostIPC privileges to bypass Tetragon namespace transition guards without a scoped, auditable exception.

## Bad vs Good Implementations
### Enforce Sigkill on Unauthorized setns Syscall via Tetragon TracingPolicy

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The policy operates in passive audit mode without specifying a terminating action. An adversary exploiting CVEs or misconfigured capabilities (e.g., CAP_SYS_ADMIN) will successfully switch to the host PID or mount namespace and execute arbitrary host payloads before any alerting system can intervene.
```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 action specified, defaults to passive audit log
      # Attacker executes setns payload before SecOps alerts are reviewed
```

#### Production Standard (Correct)
> **Standard**: The policy attaches a BPF hook directly to the `__x64_sys_setns` entrypoint and checks for dangerous namespace flags (CLONE_NEWPID, CLONE_NEWNS). Upon matching within container workloads, the Tetragon BPF probe emits a kernel-level SIGKILL directly to the task, preempting namespace re-association and preventing container escape.
```yaml
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: block-namespace-escape
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_NEWPID
                - "0x00000020" # CLONE_NEWNS
          matchNamespaces:
            - namespace: "default"
              operator: "In"
          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 eBPF Process Namespace Boundary Enforcement

Cilium Tetragon eBPF Process Namespace Boundary Enforcement defines an industrial-grade behavioral standard for security engineering. Enforces synchronous kernel-level process termination using Cilium Tetragon TracingPolicies whenever unauthorized namespace transitions (setns, unshare) occur from within containerized workloads. By attaching BPF kprobe and tracepoint hooks with Sigkill action flags, policy enforcement precedes host context switching, preventing container escapes before payloads can execute. 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: Relying on Post-Execution Audit Logs or Asynchronous Userspace Scanners to Detect Container Escape Attempts 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 DriftRelying on Post-Execution Audit Logs or Asynchronous Userspace Scanners to Detect Container Escape AttemptsCritical
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 with `action

Engineers MUST ALWAYS configure Tetragon TracingPolicy with `action: Sigkill` on unauthorized `sys_enter_setns` and `sys_enter_unshare` hooks to ensure immediate kernel-level termination.

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 audit daemons (e.g., standard auditd or passive SIEM forwarders) as the primary control against container escape techniques.

Engineers MUST NOT rely on userspace audit daemons (e.g., standard auditd or passive SIEM forwarders) as the primary control against container escape techniques.

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

Code SHOULD explicitly filter out benign system processes using exact binary paths or namespace selectors, preventing accidental termination of cluster runtime agents (e.g., runc, containerd).

Code SHOULD explicitly filter out benign system processes using exact binary paths or namespace selectors, preventing accidental termination of cluster runtime agents (e.g., runc, containerd).

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 monitor both generic syscall tracepoints (`sys_enter_setns`, `sys_enter_unshare`) and specific kernel internal functions (e.g., `switch_task_namespaces`) for defense-in-depth.

Services MUST monitor both generic syscall tracepoints (`sys_enter_setns`, `sys_enter_unshare`) and specific kernel internal functions (e.g., `switch_task_namespaces`) for defense-in-depth.

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 pods running with hostPID or hostIPC privileges to bypass Tetragon namespace transition guards without a scoped, auditable exception.

Components NEVER permit pods running with hostPID or hostIPC privileges to bypass Tetragon namespace transition guards without a scoped, auditable exception.

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 Process Namespace Boundary Enforcement critical for AI coding assistants?

Enforces synchronous kernel-level process termination using Cilium Tetragon TracingPolicies whenever unauthorized namespace transitions (setns, unshare) occur from within containerized workloads. By attaching BPF kprobe and tracepoint hooks with Sigkill action flags, policy enforcement precedes host context switching, preventing container escapes before payloads can execute. 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 (Relying on Post-Execution Audit Logs or Asynchronous Userspace Scanners to Detect Container Escape Attempts) 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