This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: cilium-tetragon-ebpf-synchronous-syscall-barrier

Cilium Tetragon In-Kernel Synchronous Syscall Interception and TOCTOU Mitigation

Enforces synchronous kernel-level enforcement policies via Cilium Tetragon TracingPolicies utilizing bpf_override_return or SIGKILL actions on sensitive syscall boundaries. Asynchronous user-space audit logging introduces Time-of-Check to Time-of-Use (TOCTOU) race conditions where malicious payloads execute prior to alert ingestion; TracingPolicies must synchronously fail or terminate processes directly inside the kernel context.

Prohibited Anti-Pattern: Relying on Asynchronous User-Space Telemetry Alerts Instead of Synchronous In-Kernel Syscall Overrides

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Cilium Tetragon In-Kernel Synchronous Syscall Interception and TOCTOU Mitigation - Enforces synchronous kernel-level enforcement policies via Cilium Tetragon TracingPolicies utilizing bpf_override_return or SIGKILL actions on sensitive syscall boundaries. Asynchronous user-space audit logging introduces Time-of-Check to Time-of-Use (TOCTOU) race conditions where malicious payloads execute prior to alert ingestion; TracingPolicies must synchronously fail or terminate processes directly inside the kernel context.
globs: deploy/**/*.yaml, k8s/**/*.yaml, helm/**/*.yaml, crds/**/*.yaml, security/policies/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/cilium-tetragon-ebpf-synchronous-syscall-barrier"
---

# Cilium Tetragon In-Kernel Synchronous Syscall Interception and TOCTOU Mitigation

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Relying on Asynchronous User-Space Telemetry Alerts Instead of Synchronous In-Kernel Syscall Overrides

## System Constraints
You are a Principal Security Architect and Systems Engineer specializing in Linux kernel security and Cilium Tetragon eBPF infrastructure. Your mandate is to enforce deterministic, in-kernel synchronous enforcement barriers using TracingPolicy resources. Mandate that any privilege escalation guardrails (e.g., namespace manipulation, unshare, setns, ptrace, sensitive bpf syscalls) execute synchronous in-kernel blocking via 'Override' or 'Sigkill' return actions instead of passive 'Post' event capture, eliminating TOCTOU race conditions completely.

## Strict Guidelines
- Engineers MUST ALWAYS declare TracingPolicy objects with synchronous 'Override' (return -EACCES/-EPERM) or 'Sigkill' actions for kernel call hooks intercepting unauthorized container privilege transitions.
- Engineers MUST NOT rely on asynchronous post-execution audit events (e.g., Tetragon JSON logs or Falco user-space daemons) as a preventative barrier against fast kernel exploits.
- TracingPolicy rules targeting syscalls MUST hook the architecture-neutral entry points or __x64_sys_* conventions with explicit selector filters scoped to Kubernetes namespaces and pods.
- Engineers MUST configure 'returnArg' overrides only on kernel functions supported by the underlying kernel's CONFIG_BPF_KPROBE_OVERRIDE enablement, falling back to 'Sigkill' if kprobe overrides are disabled.
- Components NEVER permit execution of 'unshare', 'setns', or 'ptrace' syscalls within production workload containers unless explicitly whitelisted via cryptographically signed pod annotations.

## Bad vs Good Implementations
### Tetragon TracingPolicy: In-Kernel Synchronous Syscall Execution Barrier

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Omitting the 'selectors.matchActions' block defaults to passive event emission. The setns syscall runs to completion, allowing the attacker to escape into host namespaces before user-space SIEM or monitoring can respond.
```yaml
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: block-namespace-traversal
spec:
  kprobes:
    - call: "sys_setns"
      syscall: true
      args:
        - index: 0
          type: "int"
        - index: 1
          type: "int"
      # Flaw: No in-kernel action specified. Emits an asynchronous audit event
      # to user space, leaving a microsecond TOCTOU window for exploitation.
```

#### Production Standard (Correct)
> **Standard**: Configuring 'matchActions' with 'Sigkill' or 'Override' forces the eBPF program executed at kprobe entry to instantaneously terminate the execution context or force an error code return (-EPERM), completely eliminating the TOCTOU gap.
```yaml
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: block-namespace-traversal
spec:
  kprobes:
    - call: "sys_setns"
      syscall: true
      args:
        - index: 0
          type: "int"
        - index: 1
          type: "int"
      selectors:
        - matchNamespaces:
            - namespace: production
              operator: In
          matchActions:
            - action: Sigkill
            # Synchronously terminates the thread inside the kernel context
            # before the task struct can transition to target namespace.
```

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 In-Kernel Synchronous Syscall Interception and TOCTOU Mitigation

Cilium Tetragon In-Kernel Synchronous Syscall Interception and TOCTOU Mitigation defines an industrial-grade behavioral standard for devops engineering. Enforces synchronous kernel-level enforcement policies via Cilium Tetragon TracingPolicies utilizing bpf_override_return or SIGKILL actions on sensitive syscall boundaries. Asynchronous user-space audit logging introduces Time-of-Check to Time-of-Use (TOCTOU) race conditions where malicious payloads execute prior to alert ingestion; TracingPolicies must synchronously fail or terminate processes directly inside the kernel context. 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 Telemetry Alerts Instead of Synchronous In-Kernel Syscall Overrides 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 Telemetry Alerts Instead of Synchronous In-Kernel Syscall OverridesCritical
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 declare TracingPolicy objects with synchronous 'Override' (return -EACCES/-EPERM) or 'Sigkill' actions for kernel call hooks intercepting unauthorized container privilege transitions.

Engineers MUST ALWAYS declare TracingPolicy objects with synchronous 'Override' (return -EACCES/-EPERM) or 'Sigkill' actions for kernel call hooks intercepting unauthorized container privilege transitions.

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 post-execution audit events (e.g., Tetragon JSON logs or Falco user-space daemons) as a preventative barrier against fast kernel exploits.

Engineers MUST NOT rely on asynchronous post-execution audit events (e.g., Tetragon JSON logs or Falco user-space daemons) as a preventative barrier against fast kernel exploits.

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 rules targeting syscalls MUST hook the architecture-neutral entry points or __x64_sys_* conventions with explicit selector filters scoped to Kubernetes namespaces and pods.

TracingPolicy rules targeting syscalls MUST hook the architecture-neutral entry points or __x64_sys_* conventions with explicit selector filters scoped to Kubernetes namespaces and 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.
4

Engineers MUST configure 'returnArg' overrides only on kernel functions supported by the underlying kernel's CONFIG_BPF_KPROBE_OVERRIDE enablement, falling back to 'Sigkill' if kprobe overrides are disabled.

Engineers MUST configure 'returnArg' overrides only on kernel functions supported by the underlying kernel's CONFIG_BPF_KPROBE_OVERRIDE enablement, falling back to 'Sigkill' if kprobe overrides are disabled.

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 execution of 'unshare', 'setns', or 'ptrace' syscalls within production workload containers unless explicitly whitelisted via cryptographically signed pod annotations.

Components NEVER permit execution of 'unshare', 'setns', or 'ptrace' syscalls within production workload containers unless explicitly whitelisted via cryptographically signed pod annotations.

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 In-Kernel Synchronous Syscall Interception and TOCTOU Mitigation critical for AI coding assistants?

Enforces synchronous kernel-level enforcement policies via Cilium Tetragon TracingPolicies utilizing bpf_override_return or SIGKILL actions on sensitive syscall boundaries. Asynchronous user-space audit logging introduces Time-of-Check to Time-of-Use (TOCTOU) race conditions where malicious payloads execute prior to alert ingestion; TracingPolicies must synchronously fail or terminate processes directly inside the kernel context. 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 Telemetry Alerts Instead of Synchronous In-Kernel Syscall Overrides) 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