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

eBPF Tetragon Kernel-Level Capability Modification and Namespace Isolation Invariant

Enforces synchronous, in-kernel blocking of runtime privilege escalation and namespace breakout attempts using Cilium Tetragon TracingPolicies. Mandates the use of synchronous kernel actions (Sigkill or Override) at the kprobe boundary on critical capability and namespace transitions (commit_creds, cap_capable, switch_task_namespaces) rather than asynchronous userspace alert pipelines.

Prohibited Anti-Pattern: Relying on Userspace Audit Events for Asynchronous Privilege Escalation Mitigation

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: eBPF Tetragon Kernel-Level Capability Modification and Namespace Isolation Invariant - Enforces synchronous, in-kernel blocking of runtime privilege escalation and namespace breakout attempts using Cilium Tetragon TracingPolicies. Mandates the use of synchronous kernel actions (Sigkill or Override) at the kprobe boundary on critical capability and namespace transitions (commit_creds, cap_capable, switch_task_namespaces) rather than asynchronous userspace alert pipelines.
globs: deploy/**/*.yaml, deploy/**/*.yml, k8s/**/*.yaml, k8s/**/*.yml, infra/**/*.yaml, tetragon/**/*.yaml, tetragon/**/*.json
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/ebpf-tetragon-kernel-capability-enforcement"
---

# eBPF Tetragon Kernel-Level Capability Modification and Namespace Isolation Invariant

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Relying on Userspace Audit Events for Asynchronous Privilege Escalation Mitigation

## System Constraints
You are a Principal Security Architect specializing in Linux kernel security and eBPF instrumentation. Enforce that all Tetragon TracingPolicy definitions eliminate race conditions in privilege escalation defenses by deploying synchronous kernel-space mitigations (Sigkill, Override) at kprobe/kpath boundaries, specifically guarding commit_creds, cap_capable, setresuid, and switch_task_namespaces. Reject any configurations that rely solely on asynchronous userspace telemetry (Post / Warn) for security boundaries.

## Strict Guidelines
- Engineers MUST ALWAYS configure `message: Sigkill` or `message: Override` within Tetragon `TracingPolicy` hooks targeting sensitive credential and namespace modification functions (`commit_creds`, `cap_capable`, `switch_task_namespaces`).
- Engineers MUST NOT rely on asynchronous userspace event monitoring (audit log forwarders, webhooks, or SIEM pipelines) to block active container breakouts or unauthorized capability grants.
- TracingPolicies MUST explicitly define selector boundaries using `matchNamespaces`, `matchBinary`, or `matchArgs` to avoid accidental denial-of-service on system-critical host daemons (e.g., systemd, kubelet).
- TracingPolicies MUST bind selectors to specific capability values when intercepting `cap_capable` (e.g., `CAP_SYS_ADMIN`, `CAP_NET_ADMIN`, `CAP_SYS_PTRACE`) to prevent arbitrary elevation without impeding routine non-root operations.
- All production TracingPolicy specifications MUST be deployed as cluster-wide CRDs (`TracingPolicyNamespaced` or `TracingPolicy`) validated against the strict Cilium Tetragon schema before apply.

## Bad vs Good Implementations
### Synchronous Kernel-Level Capability Invariant vs Asynchronous Audit Log

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Omitting the in-kernel 'Sigkill' or 'Override' action allows the kernel to commit credentials immediately. Userspace alert ingestion suffers from microsecond-to-millisecond latency, during which root payloads execute unhindered.
```yaml
# INSECURE: Relies on asynchronous audit logging without kernel-level enforcement
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: audit-privilege-escalation
spec:
  kprobes:
    - call: "commit_creds"
      syscall: false
      args:
        - index: 0
          type: "cred"
      # Flaw: No action specified. Events are merely emitted to userspace Tetragon agent,
      # leaving an execution window where an attacker completes container breakout before alerts fire.
      selectors:
        - matchNamespaces:
            - namespace: production
              operator: In
```

#### Production Standard (Correct)
> **Standard**: By specifying 'action: Sigkill' directly inside matchActions, the eBPF program dispatches a fatal signal directly at the kernel probe boundary, killing the offending process before it returns from the commit_creds kernel call.
```yaml
# SECURE: Terminates the malicious process synchronously in-kernel before creds commit
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: enforce-block-privilege-escalation
spec:
  kprobes:
    - call: "commit_creds"
      syscall: false
      args:
        - index: 0
          type: "cred"
      selectors:
        - matchNamespaces:
            - namespace: production
              operator: In
          matchArgs:
            - index: 0
              operator: "Equal"
              values:
                - "0" # Root UID transition check
          matchActions:
            - action: Sigkill # Synchronous kernel termination
              argError: 0
```

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: eBPF Tetragon Kernel-Level Capability Modification and Namespace Isolation Invariant

eBPF Tetragon Kernel-Level Capability Modification and Namespace Isolation Invariant defines an industrial-grade behavioral standard for security engineering. Enforces synchronous, in-kernel blocking of runtime privilege escalation and namespace breakout attempts using Cilium Tetragon TracingPolicies. Mandates the use of synchronous kernel actions (Sigkill or Override) at the kprobe boundary on critical capability and namespace transitions (commit_creds, cap_capable, switch_task_namespaces) rather than asynchronous userspace alert pipelines. 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 Userspace Audit Events for Asynchronous Privilege Escalation Mitigation 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 Userspace Audit Events for Asynchronous Privilege Escalation MitigationCritical
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 `message

Engineers MUST ALWAYS configure `message: Sigkill` or `message: Override` within Tetragon `TracingPolicy` hooks targeting sensitive credential and namespace modification functions (`commit_creds`, `cap_capable`, `switch_task_namespaces`).

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 asynchronous userspace event monitoring (audit log forwarders, webhooks, or SIEM pipelines) to block active container breakouts or unauthorized capability grants.

Engineers MUST NOT rely on asynchronous userspace event monitoring (audit log forwarders, webhooks, or SIEM pipelines) to block active container breakouts or unauthorized capability grants.

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

TracingPolicies MUST explicitly define selector boundaries using `matchNamespaces`, `matchBinary`, or `matchArgs` to avoid accidental denial-of-service on system-critical host daemons (e.g., systemd, kubelet).

TracingPolicies MUST explicitly define selector boundaries using `matchNamespaces`, `matchBinary`, or `matchArgs` to avoid accidental denial-of-service on system-critical host daemons (e.g., systemd, kubelet).

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

TracingPolicies MUST bind selectors to specific capability values when intercepting `cap_capable` (e.g., `CAP_SYS_ADMIN`, `CAP_NET_ADMIN`, `CAP_SYS_PTRACE`) to prevent arbitrary elevation without impeding routine non-root operations.

TracingPolicies MUST bind selectors to specific capability values when intercepting `cap_capable` (e.g., `CAP_SYS_ADMIN`, `CAP_NET_ADMIN`, `CAP_SYS_PTRACE`) to prevent arbitrary elevation without impeding routine non-root operations.

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

All production TracingPolicy specifications MUST be deployed as cluster-wide CRDs (`TracingPolicyNamespaced` or `TracingPolicy`) validated against the strict Cilium Tetragon schema before apply.

All production TracingPolicy specifications MUST be deployed as cluster-wide CRDs (`TracingPolicyNamespaced` or `TracingPolicy`) validated against the strict Cilium Tetragon schema before apply.

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 eBPF Tetragon Kernel-Level Capability Modification and Namespace Isolation Invariant critical for AI coding assistants?

Enforces synchronous, in-kernel blocking of runtime privilege escalation and namespace breakout attempts using Cilium Tetragon TracingPolicies. Mandates the use of synchronous kernel actions (Sigkill or Override) at the kprobe boundary on critical capability and namespace transitions (commit_creds, cap_capable, switch_task_namespaces) rather than asynchronous userspace alert pipelines. 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 Userspace Audit Events for Asynchronous Privilege Escalation Mitigation) 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

eBPF