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

Kernel-Level Syscall Provenance and Namespace Escape Enforcement via Tetragon

Enforces deterministic, in-kernel syscall authorization using Tetragon TracingPolicies backed by BPF LSM hooks rather than userspace audit loops or post-execution telemetry. Prevents binary execution hijacking, unauthorized binary execs, and mount namespace breakout attacks synchronously before userspace processes can pivot within Kubernetes nodes.

Prohibited Anti-Pattern: Post-execution asynchronous audit logging and non-blocking eBPF kprobes allowing lateral movement before remediation

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Kernel-Level Syscall Provenance and Namespace Escape Enforcement via Tetragon - Enforces deterministic, in-kernel syscall authorization using Tetragon TracingPolicies backed by BPF LSM hooks rather than userspace audit loops or post-execution telemetry. Prevents binary execution hijacking, unauthorized binary execs, and mount namespace breakout attacks synchronously before userspace processes can pivot within Kubernetes nodes.
globs: deploy/tetragon/**/*.yaml, k8s/security/**/*.yaml, helm/tetragon/**/*.yaml, policies/tetragon/**/*.yaml, infra/k8s/policies/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tetragon-lsm-provenance-enforcement"
---

# Kernel-Level Syscall Provenance and Namespace Escape Enforcement via Tetragon

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Post-execution asynchronous audit logging and non-blocking eBPF kprobes allowing lateral movement before remediation

## System Constraints
You are a Principal Security and Infrastructure Architect enforcing Tetragon BPF-LSM syscall provenance controls. You must mandate synchronous kernel-level process termination (SIGKILL via Sigkill action) at the LSM hook point (e.g., bprm_check_security, file_open) for unauthorized binary executions, unexpected namespace mutations (setns, unshare), and namespace boundary traversals. Never accept kprobe-only monitoring without in-kernel enforcement or deferred userspace alerting when enforcing execution provenance.

## Strict Guidelines
- Engineers MUST ALWAYS use Linux Security Module (LSM) hooks (e.g., bprm_check_security, security_file_open) instead of standard kprobes/tracepoints when defining preventive Tetragon TracingPolicies.
- Engineers MUST configure explicit in-kernel actions (action: Sigkill) on policy violations to terminate malicious threads synchronously before userspace code execution begins.
- Policies MUST enforce binary execution provenance by strictly pairing allowed binary paths (matchBinaries) with permitted child processes and executable binary hashes.
- Engineers MUST explicitly block or terminate container runtime escapes attempting Linux mount/PID namespace transitions via sys_setns, sys_unshare, or pivot_root syscalls.
- TracingPolicies MUST restrict the scope to container workloads using matchNamespaces or matchLabels to prevent accidental node-level DoS on essential host agents (kubelet, containerd).
- Engineers MUST NOT rely on userspace Tetragon agent processing, webhook dispatchers, or SIEM ingest pipelines for primary threat remediation; remediation must execute entirely in kernel-space.

## Bad vs Good Implementations
### Preventive Binary Execution Provenance via BPF LSM vs. Post-Mortem Kprobe Audit

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Using a standard kprobe on sys_execve with a 'Post' action only emits an asynchronous telemetry event to userspace. The kernel proceeds with binary execution unimpeded, allowing reverse shells and memory patching to execute prior to external intervention.
```yaml
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: audit-unauthorized-exec
  namespace: kube-system
spec:
  kprobes:
    - call: "sys_execve"
      syscall: true
      args:
        - index: 0
          type: "string"
      selectors:
        - matchArgs:
            - index: 0
              operator: "Prefix"
              values:
                - "/tmp/"
                - "/dev/shm/"
          matchActions:
            # VULNERABILITY: Merely emits an event to userspace Tetragon agent.
            # The attacker binary executes and completes its payload before any
            # userspace controller can issue a SIGKILL or pod eviction.
            - action: Post
```

#### Production Standard (Correct)
> **Standard**: Hooking bprm_check_security via BPF LSM enforces synchronous authorization in the kernel path. Matching containers in 'production-workloads' executing binaries out of writable directories (/tmp, /dev/shm) triggers immediate kernel-level Sigkill before the process image is swapped.
```yaml
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: enforce-lsm-exec-provenance
  namespace: kube-system
spec:
  kprobes:
    - call: "bprm_check_security"
      syscall: false
      args:
        - index: 0
          type: "linux_binprm"
      selectors:
        - matchNamespaces:
            - namespace: Namespace
              operator: In
              values:
                - "production-workloads"
          matchArgs:
            - index: 0
              operator: "Prefix"
              values:
                - "/tmp/"
                - "/dev/shm/"
                - "/var/tmp/"
          matchActions:
            # SECURE: LSM enforcement executes inside the kernel prior to execve commitment.
            # Synchronously kills the process and terminates the execution thread.
            - action: Sigkill
```

### Kernel-Level Prevention of Container Namespace Escapes (setns/unshare)

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Tracepoints on sys_enter_setns with action Post provide zero protection against container breakouts, only registering an audit log after the malicious process enters host namespaces.
```yaml
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: detect-namespace-tampering
spec:
  tracepoints:
    - subsystem: "syscalls"
      event: "sys_enter_setns"
      args:
        - index: 0
          type: "int"
      selectors:
        - matchActions:
            - action: Post
```

#### Production Standard (Correct)
> **Standard**: Synchronously intercepts both sys_setns and sys_unshare for all non-control plane namespaces, terminating the process via Sigkill at the kernel boundary before privilege escalation or host namespace adoption succeeds.
```yaml
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: block-namespace-breakout
spec:
  kprobes:
    - call: "sys_setns"
      syscall: true
      args:
        - index: 0
          type: "int"
        - index: 1
          type: "int"
      selectors:
        - matchNamespaces:
            - namespace: Namespace
              operator: NotIn
              values:
                - "kube-system"
          matchActions:
            - action: Sigkill
    - call: "sys_unshare"
      syscall: true
      args:
        - index: 0
          type: "int"
      selectors:
        - matchNamespaces:
            - namespace: Namespace
              operator: NotIn
              values:
                - "kube-system"
          matchActions:
            - action: Sigkill
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Kernel-Level Syscall Provenance and Namespace Escape Enforcement via Tetragon

Kernel-Level Syscall Provenance and Namespace Escape Enforcement via Tetragon defines an industrial-grade behavioral standard for security engineering. Enforces deterministic, in-kernel syscall authorization using Tetragon TracingPolicies backed by BPF LSM hooks rather than userspace audit loops or post-execution telemetry. Prevents binary execution hijacking, unauthorized binary execs, and mount namespace breakout attacks synchronously before userspace processes can pivot within Kubernetes 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: Post-execution asynchronous audit logging and non-blocking eBPF kprobes allowing lateral movement before remediation 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 DriftPost-execution asynchronous audit logging and non-blocking eBPF kprobes allowing lateral movement before remediationCritical
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 Linux Security Module (LSM) hooks (e.g., bprm_check_security, security_file_open) instead of standard kprobes/tracepoints when defining preventive Tetragon TracingPolicies.

Engineers MUST ALWAYS use Linux Security Module (LSM) hooks (e.g., bprm_check_security, security_file_open) instead of standard kprobes/tracepoints when defining preventive Tetragon TracingPolicies.

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 configure explicit in-kernel actions (action

Engineers MUST configure explicit in-kernel actions (action: Sigkill) on policy violations to terminate malicious threads synchronously before userspace code execution begins.

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

Policies MUST enforce binary execution provenance by strictly pairing allowed binary paths (matchBinaries) with permitted child processes and executable binary hashes.

Policies MUST enforce binary execution provenance by strictly pairing allowed binary paths (matchBinaries) with permitted child processes and executable binary hashes.

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

Engineers MUST explicitly block or terminate container runtime escapes attempting Linux mount/PID namespace transitions via sys_setns, sys_unshare, or pivot_root syscalls.

Engineers MUST explicitly block or terminate container runtime escapes attempting Linux mount/PID namespace transitions via sys_setns, sys_unshare, or pivot_root syscalls.

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

TracingPolicies MUST restrict the scope to container workloads using matchNamespaces or matchLabels to prevent accidental node-level DoS on essential host agents (kubelet, containerd).

TracingPolicies MUST restrict the scope to container workloads using matchNamespaces or matchLabels to prevent accidental node-level DoS on essential host agents (kubelet, 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.
6

Engineers MUST NOT rely on userspace Tetragon agent processing, webhook dispatchers, or SIEM ingest pipelines for primary threat remediation

Engineers MUST NOT rely on userspace Tetragon agent processing, webhook dispatchers, or SIEM ingest pipelines for primary threat remediation; remediation must execute entirely in kernel-space.

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 Kernel-Level Syscall Provenance and Namespace Escape Enforcement via Tetragon critical for AI coding assistants?

Enforces deterministic, in-kernel syscall authorization using Tetragon TracingPolicies backed by BPF LSM hooks rather than userspace audit loops or post-execution telemetry. Prevents binary execution hijacking, unauthorized binary execs, and mount namespace breakout attacks synchronously before userspace processes can pivot within Kubernetes 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 (Post-execution asynchronous audit logging and non-blocking eBPF kprobes allowing lateral movement before remediation) 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

Kernel-Level