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

Deterministic Kernel-Level TracingPolicy Enforcement with In-Kernel Tetragon Kill Actions

Enforces sub-millisecond container runtime quarantine through Tetragon TracingPolicy definitions by mandating synchronous in-kernel Sigkill actions rather than asynchronous post-execution alerting. Eliminates time-of-check to time-of-use (TOCTOU) exploitation windows by pinning enforcement hooks to tracepoints or kprobes targeting binary executions, sensitive kernel namespace traversal, and privilege escalation primitives.

Prohibited Anti-Pattern: Relying on Asynchronous User-Space Audit Logging or Post-Execution Webhook Signals for Malicious Container Quarantine

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Deterministic Kernel-Level TracingPolicy Enforcement with In-Kernel Tetragon Kill Actions - Enforces sub-millisecond container runtime quarantine through Tetragon TracingPolicy definitions by mandating synchronous in-kernel Sigkill actions rather than asynchronous post-execution alerting. Eliminates time-of-check to time-of-use (TOCTOU) exploitation windows by pinning enforcement hooks to tracepoints or kprobes targeting binary executions, sensitive kernel namespace traversal, and privilege escalation primitives.
globs: deployments/**/*.yaml, k8s/**/*.yaml, infra/**/*.yaml, tetragon/**/*.yaml, policies/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/ebpf-tetragon-kernel-enforcement-guardrail"
---

# Deterministic Kernel-Level TracingPolicy Enforcement with In-Kernel Tetragon Kill Actions

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Relying on Asynchronous User-Space Audit Logging or Post-Execution Webhook Signals for Malicious Container Quarantine

## System Constraints
You are a Principal Security Architect specializing in eBPF and Tetragon runtime enforcement. Mandate deterministic, zero-latency in-kernel blocking invariants for untrusted workloads. Ensure that runtime security policies declare direct 'Sigkill' actions on high-risk system call hooks, bind strictly to scoped namespace and binary selectors, and never rely on user-space telemetry loops for containment.

## Strict Guidelines
- Engineers MUST ALWAYS configure `action: Sigkill` on high-risk kernel hooks (`sys_execve`, `security_file_open`, `commit_creds`) to enforce synchronous termination within kernel context before userspace execution completes.
- Engineers MUST NOT configure audit-only (`action: Post`) hooks without matching synchronous blocking rules for critical attack vectors (e.g., privilege escalation, unexpected shell spawns in production pods).
- TracingPolicy resources MUST explicitly scope binary execution paths using `matchBinaries` or pod selectors via `matchNamespaces` / `matchLabels` to prevent kernel verifier bloat and unintended system daemon crashes.
- TracingPolicy arguments MUST strictly define index matching and value matching operators (`Operator: Equal` or `Prefix`) on file paths and command arguments rather than unbounded wildcard tracing.
- Policies MUST NEVER allow container escape primitives, specifically namespace modifications (`setns`, `unshare`) and mount operations (`sys_mount`), without deterministic kill filters applied to unprivileged workloads.

## Bad vs Good Implementations
### Synchronous Sigkill on Unauthorized Binary Execution vs Asynchronous Notification

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Using 'action: Post' merely dispatches an event to the userspace Tetragon agent (JSON/gRPC stream). Malicious binaries running out of /tmp/ will successfully execute, extract secrets, or establish reverse shells before an external orchestrator can react.
```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"
      # Flaw: Post action merely produces an alert in JSON logs while the payload runs to completion.
      selectors:
        - matchArgs:
            - index: 0
              operator: "Prefix"
              values:
                - "/tmp/"
          matchActions:
            - action: Post
```

#### Production Standard (Correct)
> **Standard**: The 'Sigkill' action executes directly inside the eBPF kernel hook before sys_execve returns control to user-space. This eliminates the race condition entirely and terminates the attacking process instantaneously while simultaneously logging via 'Post'.
```yaml
apiVersion: cilium.io/v1alpha1
kind: TracingPolicyNamespaced
metadata:
  name: block-tmp-execution
  namespace: payment-workloads
spec:
  kprobes:
    - call: "sys_execve"
      syscall: true
      args:
        - index: 0
          type: "string"
      selectors:
        - matchArgs:
            - index: 0
              operator: "Prefix"
              values:
                - "/tmp/"
                - "/dev/shm/"
          matchActions:
            # Invariant: Directly abort the system call in-kernel and terminate the PID synchronously.
            - action: Sigkill
            - action: Post
```

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: Deterministic Kernel-Level TracingPolicy Enforcement with In-Kernel Tetragon Kill Actions

Deterministic Kernel-Level TracingPolicy Enforcement with In-Kernel Tetragon Kill Actions defines an industrial-grade behavioral standard for devops engineering. Enforces sub-millisecond container runtime quarantine through Tetragon TracingPolicy definitions by mandating synchronous in-kernel Sigkill actions rather than asynchronous post-execution alerting. Eliminates time-of-check to time-of-use (TOCTOU) exploitation windows by pinning enforcement hooks to tracepoints or kprobes targeting binary executions, sensitive kernel namespace traversal, and privilege escalation primitives. 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 User-Space Audit Logging or Post-Execution Webhook Signals for Malicious Container Quarantine 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 User-Space Audit Logging or Post-Execution Webhook Signals for Malicious Container QuarantineCritical
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 `action

Engineers MUST ALWAYS configure `action: Sigkill` on high-risk kernel hooks (`sys_execve`, `security_file_open`, `commit_creds`) to enforce synchronous termination within kernel context before userspace execution completes.

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 audit-only (`action

Engineers MUST NOT configure audit-only (`action: Post`) hooks without matching synchronous blocking rules for critical attack vectors (e.g., privilege escalation, unexpected shell spawns in production pods).

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

TracingPolicy resources MUST explicitly scope binary execution paths using `matchBinaries` or pod selectors via `matchNamespaces` / `matchLabels` to prevent kernel verifier bloat and unintended system daemon crashes.

TracingPolicy resources MUST explicitly scope binary execution paths using `matchBinaries` or pod selectors via `matchNamespaces` / `matchLabels` to prevent kernel verifier bloat and unintended system daemon crashes.

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

TracingPolicy arguments MUST strictly define index matching and value matching operators (`Operator

TracingPolicy arguments MUST strictly define index matching and value matching operators (`Operator: Equal` or `Prefix`) on file paths and command arguments rather than unbounded wildcard tracing.

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

Policies MUST NEVER allow container escape primitives, specifically namespace modifications (`setns`, `unshare`) and mount operations (`sys_mount`), without deterministic kill filters applied to unprivileged workloads.

Policies MUST NEVER allow container escape primitives, specifically namespace modifications (`setns`, `unshare`) and mount operations (`sys_mount`), without deterministic kill filters applied to unprivileged 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.
Technical Questions & Answers

Frequently Asked Technical Questions

Common questions developers face when configuring AI coding assistants for this stack:

Q:Why is Deterministic Kernel-Level TracingPolicy Enforcement with In-Kernel Tetragon Kill Actions critical for AI coding assistants?

Enforces sub-millisecond container runtime quarantine through Tetragon TracingPolicy definitions by mandating synchronous in-kernel Sigkill actions rather than asynchronous post-execution alerting. Eliminates time-of-check to time-of-use (TOCTOU) exploitation windows by pinning enforcement hooks to tracepoints or kprobes targeting binary executions, sensitive kernel namespace traversal, and privilege escalation primitives. 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 User-Space Audit Logging or Post-Execution Webhook Signals for Malicious Container Quarantine) 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

Deterministic