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

Cilium Tetragon eBPF In-Kernel Syscall Enforcement and Breakout Prevention

Mandates deterministic, synchronous eBPF kernel-level enforcement via Cilium Tetragon TracingPolicy CRDs to intercept and neutralize container breakout and namespace pivot syscalls (setns, unshare, pivot_root) before kernel state mutations occur. Prohibits relying on passive, asynchronous userspace audit monitoring that triggers after privilege escalation has already executed.

Prohibited Anti-Pattern: Relying on Passive Userspace Audit Logs for Container Breakout Syscalls Instead of In-Kernel eBPF Sigkill Enforcement

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Cilium Tetragon eBPF In-Kernel Syscall Enforcement and Breakout Prevention - Mandates deterministic, synchronous eBPF kernel-level enforcement via Cilium Tetragon TracingPolicy CRDs to intercept and neutralize container breakout and namespace pivot syscalls (setns, unshare, pivot_root) before kernel state mutations occur. Prohibits relying on passive, asynchronous userspace audit monitoring that triggers after privilege escalation has already executed.
globs: deploy/**/*.yaml, k8s/**/*.yaml, policies/**/*.yaml, helm/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tetragon-ebpf-namespace-syscall-enforcement"
---

# Cilium Tetragon eBPF In-Kernel Syscall Enforcement and Breakout Prevention

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Relying on Passive Userspace Audit Logs for Container Breakout Syscalls Instead of In-Kernel eBPF Sigkill Enforcement

## System Constraints
You are a Principal Security Architect specializing in Linux kernel security and Cilium Tetragon eBPF instrumentation. Enforce absolute zero-trust kernel boundaries for containerized workloads by implementing deterministic TracingPolicy CRDs. Ensure namespace switching syscalls (sys_enter_setns, sys_enter_unshare, sys_enter_pivot_root) and raw capability abuse are blocked synchronously inside the kernel via 'Sigkill' actions before userspace privilege escalations can complete.

## Strict Guidelines
- Engineers MUST ALWAYS enforce synchronous kernel-level termination ('action: Sigkill') in Tetragon TracingPolicy resources for namespace transition syscalls ('sys_enter_setns', 'sys_enter_unshare', 'sys_enter_pivot_root').
- Engineers MUST NOT configure passive notify-only actions (such as 'action: Post' without an enforcement companion) for critical breakout vectors.
- Code SHOULD target sys_enter tracepoints or kprobes on syscall entry rather than return paths (kretprobe/sys_exit) to prevent the kernel from executing the privileged operation.
- Services MUST scope TracingPolicy selectors using 'matchNamespaces' or 'matchLabels' to prevent accidental SIGKILL signals to host-privileged system daemons and CNI components.
- Components NEVER permit untrusted container processes to invoke capability acquisition checks ('cap_capable') or tamper with sensitive kernel tunables in '/proc/sys/kernel'.

## Bad vs Good Implementations
### Enforcing Kernel-Level SIGKILL on Unauthorized Namespace Switching (sys_enter_setns)

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: This policy merely generates an asynchronous event log after the setns syscall begins execution. It lacks an in-kernel termination action, allowing an attacker to transition namespaces and compromise the underlying node before userspace monitoring agents can intervene.
```yaml
# INSECURE: Passive monitoring with no in-kernel pre-execution prevention
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: monitor-namespace-escapes
spec:
  kprobes:
    - call: "sys_enter_setns"
      syscall: true
      args:
        - index: 0
          type: "int"
        - index: 1
          type: "int"
      # Flaw: No action specified, defaults to userspace event notification.
      # The breakout syscall successfully completes in the kernel before alerting.
```

#### Production Standard (Correct)
> **Standard**: This policy configures Tetragon to inject an in-kernel eBPF hook directly on sys_enter_setns. When a process in the specified untrusted namespace attempts to execute the syscall, Tetragon immediately dispatches a kernel SIGKILL to terminate the offending thread before the namespace transition occurs.
```yaml
# SECURE: Synchronous in-kernel enforcement terminating container breakout attempts
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: block-namespace-breakouts
spec:
  kprobes:
    - call: "sys_enter_setns"
      syscall: true
      args:
        - index: 0
          type: "int"
        - index: 1
          type: "int"
      selectors:
        - matchNamespaces:
            - namespace: "production-workloads"
              operator: "In"
          matchArgs:
            - index: 1
              operator: "Prefix"
              values:
                - "0" # CLONE_NEWNS or generic flags
          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 In-Kernel Syscall Enforcement and Breakout Prevention

Cilium Tetragon eBPF In-Kernel Syscall Enforcement and Breakout Prevention defines an industrial-grade behavioral standard for security engineering. Mandates deterministic, synchronous eBPF kernel-level enforcement via Cilium Tetragon TracingPolicy CRDs to intercept and neutralize container breakout and namespace pivot syscalls (setns, unshare, pivot_root) before kernel state mutations occur. Prohibits relying on passive, asynchronous userspace audit monitoring that triggers after privilege escalation has already executed. 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 Passive Userspace Audit Logs for Container Breakout Syscalls Instead of In-Kernel eBPF 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 DriftRelying on Passive Userspace Audit Logs for Container Breakout Syscalls Instead of In-Kernel eBPF 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 enforce synchronous kernel-level termination ('action

Engineers MUST ALWAYS enforce synchronous kernel-level termination ('action: Sigkill') in Tetragon TracingPolicy resources for namespace transition syscalls ('sys_enter_setns', 'sys_enter_unshare', 'sys_enter_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 configure passive notify-only actions (such as 'action

Engineers MUST NOT configure passive notify-only actions (such as 'action: Post' without an enforcement companion) for critical breakout vectors.

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 target sys_enter tracepoints or kprobes on syscall entry rather than return paths (kretprobe/sys_exit) to prevent the kernel from executing the privileged operation.

Code SHOULD target sys_enter tracepoints or kprobes on syscall entry rather than return paths (kretprobe/sys_exit) to prevent the kernel from executing the privileged operation.

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 TracingPolicy selectors using 'matchNamespaces' or 'matchLabels' to prevent accidental SIGKILL signals to host-privileged system daemons and CNI components.

Services MUST scope TracingPolicy selectors using 'matchNamespaces' or 'matchLabels' to prevent accidental SIGKILL signals to host-privileged system daemons and CNI components.

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 untrusted container processes to invoke capability acquisition checks ('cap_capable') or tamper with sensitive kernel tunables in '/proc/sys/kernel'.

Components NEVER permit untrusted container processes to invoke capability acquisition checks ('cap_capable') or tamper with sensitive kernel tunables in '/proc/sys/kernel'.

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 In-Kernel Syscall Enforcement and Breakout Prevention critical for AI coding assistants?

Mandates deterministic, synchronous eBPF kernel-level enforcement via Cilium Tetragon TracingPolicy CRDs to intercept and neutralize container breakout and namespace pivot syscalls (setns, unshare, pivot_root) before kernel state mutations occur. Prohibits relying on passive, asynchronous userspace audit monitoring that triggers after privilege escalation has already executed. 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 Passive Userspace Audit Logs for Container Breakout Syscalls Instead of In-Kernel eBPF 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