This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: tetragon-execve-lineage-namespace-isolation-standard

Tetragon In-Kernel Execve Lineage & Namespace Escape Prevention

Enforces deterministic, in-kernel synchronous termination (SIGKILL) of unauthorized process lineages and container namespace breakouts via Cilium Tetragon TracingPolicies. Prevents post-compromise lateral movement and container escape payloads by intercepting syscalls at kernel entry prior to binary execution rather than relying on reactive user-space audit logging.

Prohibited Anti-Pattern: Relying on Asynchronous Audit Logging or sys_exit Probes that Allow Malicious Binaries to Execute Before User-Space Intervention

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tetragon In-Kernel Execve Lineage & Namespace Escape Prevention - Enforces deterministic, in-kernel synchronous termination (SIGKILL) of unauthorized process lineages and container namespace breakouts via Cilium Tetragon TracingPolicies. Prevents post-compromise lateral movement and container escape payloads by intercepting syscalls at kernel entry prior to binary execution rather than relying on reactive user-space audit logging.
globs: deploy/**/*.yaml, k8s/**/*.yaml, charts/**/*.yaml, security/**/*.yaml, tetragon/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tetragon-execve-lineage-namespace-isolation-standard"
---

# Tetragon In-Kernel Execve Lineage & Namespace Escape Prevention

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Relying on Asynchronous Audit Logging or sys_exit Probes that Allow Malicious Binaries to Execute Before User-Space Intervention

## System Constraints
You are a Principal Security Architect specializing in eBPF kernel enforcement and runtime container isolation with Cilium Tetragon. You enforce strict synchronous kernel-level process lineage gating and namespace boundary lockdown. Every runtime security policy must reject post-execution audit traps in favor of synchronous Sigkill actions at sys_enter hook points (specifically sys_enter_execve, sys_enter_setns, and sys_enter_unshare) to terminate privilege escalation and container breakouts instantly.

## Strict Guidelines
- Engineers MUST ALWAYS use synchronous in-kernel enforcement (`action: Sigkill`) rather than passive user-space notifications when defining Tetragon TracingPolicy rules for high-risk binaries.
- Tracing policies MUST intercept process execution at kernel entry (`sys_enter_execve` or `__x64_sys_execve`) rather than `sys_exit_execve` so that untrusted payloads are terminated prior to memory mapping and execution.
- Engineers MUST NOT permit unauthorized interactive shells (`/bin/sh`, `/bin/bash`, `/bin/zsh`, `/usr/bin/dash`) or network reconnaissance utilities (`nc`, `curl`, `wget`, `nmap`) in parent process lineages spawned by application runtime processes.
- Services MUST monitor and explicitly terminate namespace transition attempts (`setns`, `unshare`) executed from within unprivileged application containers using `sys_enter_setns` probes.
- TracingPolicy resources SHOULD leverage `matchNamespaces` and `matchArgs` selectors to isolate enforcement to production application namespaces while preventing disruption of standard node-level administrative tooling.

## Bad vs Good Implementations
### Tetragon TracingPolicy for Namespace Breakout and Execve Lineage Enforcement

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Attaching to sys_exit_execve without an action merely emits an audit log after the binary has already spawned and initialized in memory. An attacker executing setns or a reverse shell executes fully before any user-space daemon can alert an administrator.
```yaml
# VULNERABLE: Asynchronous post-execution notification without active kernel kill.
# Allows weaponized payloads and namespace escapes to complete before alerts are processed.
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: audit-container-shell
spec:
  kprobes:
    - call: "sys_exit_execve"
      syscall: true
      args:
        - index: 0
          type: "string"
      selectors:
        - matchArgs:
            - index: 0
              operator: "Prefix"
              values:
                - "/bin/sh"
                - "/bin/bash"
          # Flaw: No action specified, defaults to passive audit event generation.
          # The attacker retains an active interactive shell session.
```

#### Production Standard (Correct)
> **Standard**: Hooks execution at kernel entry (__x64_sys_execve and __x64_sys_setns) for any non-host PID namespace. The in-kernel Tetragon BPF verifier enforces an immediate Sigkill action, aborting the syscall and terminating the thread before the ELF binary is loaded or the namespace barrier is breached.
```yaml
# SECURE: In-kernel synchronous Sigkill interception on sys_enter_execve and sys_enter_setns.
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: block-exec-lineage-and-setns-escape
  labels:
    security.enforcement: "ebpf-kernel-sigkill"
spec:
  kprobes:
    - call: "__x64_sys_execve"
      syscall: true
      args:
        - index: 0
          type: "string"
      selectors:
        - matchNamespaces:
            - namespace: Pid
              operator: NotIn
              values: ["host"]
          matchArgs:
            - index: 0
              operator: "InMap"
              values:
                - "/bin/sh"
                - "/bin/bash"
                - "/usr/bin/sh"
                - "/usr/bin/bash"
          matchActions:
            - action: Sigkill
    - call: "__x64_sys_setns"
      syscall: true
      args:
        - index: 0
          type: "int"
        - index: 1
          type: "int"
      selectors:
        - matchNamespaces:
            - namespace: Pid
              operator: NotIn
              values: ["host"]
          matchActions:
            - action: Sigkill
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Tetragon In-Kernel Execve Lineage & Namespace Escape Prevention

Tetragon In-Kernel Execve Lineage & Namespace Escape Prevention defines an industrial-grade behavioral standard for security engineering. Enforces deterministic, in-kernel synchronous termination (SIGKILL) of unauthorized process lineages and container namespace breakouts via Cilium Tetragon TracingPolicies. Prevents post-compromise lateral movement and container escape payloads by intercepting syscalls at kernel entry prior to binary execution rather than relying on reactive user-space audit logging. 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 Asynchronous Audit Logging or sys_exit Probes that Allow Malicious Binaries to Execute Before User-Space Intervention 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 Asynchronous Audit Logging or sys_exit Probes that Allow Malicious Binaries to Execute Before User-Space InterventionCritical
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 use synchronous in-kernel enforcement (`action

Engineers MUST ALWAYS use synchronous in-kernel enforcement (`action: Sigkill`) rather than passive user-space notifications when defining Tetragon TracingPolicy rules for high-risk binaries.

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

Tracing policies MUST intercept process execution at kernel entry (`sys_enter_execve` or `__x64_sys_execve`) rather than `sys_exit_execve` so that untrusted payloads are terminated prior to memory mapping and execution.

Tracing policies MUST intercept process execution at kernel entry (`sys_enter_execve` or `__x64_sys_execve`) rather than `sys_exit_execve` so that untrusted payloads are terminated prior to memory mapping and 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.
3

Engineers MUST NOT permit unauthorized interactive shells (`/bin/sh`, `/bin/bash`, `/bin/zsh`, `/usr/bin/dash`) or network reconnaissance utilities (`nc`, `curl`, `wget`, `nmap`) in parent process lineages spawned by application runtime processes.

Engineers MUST NOT permit unauthorized interactive shells (`/bin/sh`, `/bin/bash`, `/bin/zsh`, `/usr/bin/dash`) or network reconnaissance utilities (`nc`, `curl`, `wget`, `nmap`) in parent process lineages spawned by application runtime processes.

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 and explicitly terminate namespace transition attempts (`setns`, `unshare`) executed from within unprivileged application containers using `sys_enter_setns` probes.

Services MUST monitor and explicitly terminate namespace transition attempts (`setns`, `unshare`) executed from within unprivileged application containers using `sys_enter_setns` probes.

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

TracingPolicy resources SHOULD leverage `matchNamespaces` and `matchArgs` selectors to isolate enforcement to production application namespaces while preventing disruption of standard node-level administrative tooling.

TracingPolicy resources SHOULD leverage `matchNamespaces` and `matchArgs` selectors to isolate enforcement to production application namespaces while preventing disruption of standard node-level administrative tooling.

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 Tetragon In-Kernel Execve Lineage & Namespace Escape Prevention critical for AI coding assistants?

Enforces deterministic, in-kernel synchronous termination (SIGKILL) of unauthorized process lineages and container namespace breakouts via Cilium Tetragon TracingPolicies. Prevents post-compromise lateral movement and container escape payloads by intercepting syscalls at kernel entry prior to binary execution rather than relying on reactive user-space audit logging. 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 Asynchronous Audit Logging or sys_exit Probes that Allow Malicious Binaries to Execute Before User-Space Intervention) 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

Tetragon