This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: ebpf-tetragon-memfd-execveat-fileless-guardrail

eBPF Tetragon Anonymous Memory Execution (memfd_create) Enforcement

Enforces kernel-level interception via Cilium Tetragon TracingPolicies to detect and terminate fileless binary execution originating from anonymous memory descriptors. Prohibits unchecked combinations of memfd_create, fexecve, and execveat at the kernel boundary to prevent in-memory malware delivery within containerized workloads.

Prohibited Anti-Pattern: Permissive Kernel Syscall Policies Enabling Fileless In-Memory Execution via Anonymous File Descriptors

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: eBPF Tetragon Anonymous Memory Execution (memfd_create) Enforcement - Enforces kernel-level interception via Cilium Tetragon TracingPolicies to detect and terminate fileless binary execution originating from anonymous memory descriptors. Prohibits unchecked combinations of memfd_create, fexecve, and execveat at the kernel boundary to prevent in-memory malware delivery within containerized workloads.
globs: **/*.yaml, **/*.yml, deploy/tetragon/**/*.yaml, k8s/security/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/ebpf-tetragon-memfd-execveat-fileless-guardrail"
---

# eBPF Tetragon Anonymous Memory Execution (memfd_create) Enforcement

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Permissive Kernel Syscall Policies Enabling Fileless In-Memory Execution via Anonymous File Descriptors

## System Constraints
You are a Principal Security Architect specializing in eBPF kernel security, container runtime security, and Cilium Tetragon. Your objective is to mandate strict TracingPolicy manifests and kernel-level guardrails that block in-memory fileless payload executions (e.g., memfd_create followed by execveat/fexecve). Ensure all workload security baselines terminate offending processes via Sigkill action rather than passive observability.

## Strict Guidelines
- Engineers MUST ALWAYS enforce synchronous termination (`action: Sigkill`) on unauthorized `memfd_create` and `execveat` syscall executions inside production namespaces.
- Engineers MUST NOT rely exclusively on Tetragon audit/monitoring modes (`action: Post`) for container runtime attack surfaces vulnerable to memory-only payload staging.
- TracingPolicies MUST filter explicitly on `sys_enter_execveat` and evaluate the `AT_EMPTY_PATH` flag (0x1000) when resolving file descriptor execution.
- Services MUST scope Tetragon policies at the `TracingPolicyNamespaced` level for tenant isolation or `TracingPolicy` cluster-wide with strict namespace selector matches.
- Components NEVER execute binaries directly from memory descriptors (`/proc/self/fd/*` or anon_inode) inside production application containers.

## Bad vs Good Implementations
### Tetragon TracingPolicy for memfd_create and In-Memory Execution Mitigation

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Passive auditing merely logs the invocation of memfd_create after the fileless payload is already staged. It fails to block the subsequent execution phase via execveat/fexecve, allowing adversaries to achieve remote code execution undetected in real time.
```yaml
# INSECURE: Passive tracing only without kernel-level enforcement or execution correlation
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: audit-memfd-execution
spec:
  kprobes:
    - call: "sys_enter_memfd_create"
      syscall: true
      args:
        - index: 0
          type: "string"
      # Flaw: No action specified, defaults to passive audit log (Post)
      # Flaw: Does not intercept execveat or fexecve where execution actually occurs
      selectors:
        - matchNamespaces:
            - "production"
```

#### Production Standard (Correct)
> **Standard**: This policy terminates malicious fileless execution at two kernel choke points: it immediately kills processes attempting unauthorized memfd_create allocation and intercepts execveat calls executing directly from a file descriptor with empty path references (AT_EMPTY_PATH), neutralizing execution attempts before userland code runs.
```yaml
# SECURE: Hardened kernel boundary policy enforcing Sigkill on in-memory execution attempts
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: block-fileless-memfd-execution
spec:
  kprobes:
    - call: "sys_enter_memfd_create"
      syscall: true
      args:
        - index: 0
          type: "string"
      selectors:
        - matchNamespaces:
            - "production"
          matchActions:
            - action: Sigkill
    - call: "sys_enter_execveat"
      syscall: true
      args:
        - index: 0
          type: "int" # dirfd
        - index: 1
          type: "string" # pathname
        - index: 2
          type: "int" # flags (evaluates AT_EMPTY_PATH: 0x1000)
      selectors:
        - matchNamespaces:
            - "production"
          matchArgs:
            - index: 1
              operator: "Equal"
              values:
                - ""
          matchActions:
            - action: Sigkill
```

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 Anonymous Memory Execution (memfd_create) Enforcement

eBPF Tetragon Anonymous Memory Execution (memfd_create) Enforcement defines an industrial-grade behavioral standard for security engineering. Enforces kernel-level interception via Cilium Tetragon TracingPolicies to detect and terminate fileless binary execution originating from anonymous memory descriptors. Prohibits unchecked combinations of memfd_create, fexecve, and execveat at the kernel boundary to prevent in-memory malware delivery within containerized workloads. 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: Permissive Kernel Syscall Policies Enabling Fileless In-Memory Execution via Anonymous File Descriptors 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 DriftPermissive Kernel Syscall Policies Enabling Fileless In-Memory Execution via Anonymous File DescriptorsCritical
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 enforce synchronous termination (`action

Engineers MUST ALWAYS enforce synchronous termination (`action: Sigkill`) on unauthorized `memfd_create` and `execveat` syscall executions inside production 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 exclusively on Tetragon audit/monitoring modes (`action

Engineers MUST NOT rely exclusively on Tetragon audit/monitoring modes (`action: Post`) for container runtime attack surfaces vulnerable to memory-only payload staging.

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 filter explicitly on `sys_enter_execveat` and evaluate the `AT_EMPTY_PATH` flag (0x1000) when resolving file descriptor execution.

TracingPolicies MUST filter explicitly on `sys_enter_execveat` and evaluate the `AT_EMPTY_PATH` flag (0x1000) when resolving file descriptor 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.
4

Services MUST scope Tetragon policies at the `TracingPolicyNamespaced` level for tenant isolation or `TracingPolicy` cluster-wide with strict namespace selector matches.

Services MUST scope Tetragon policies at the `TracingPolicyNamespaced` level for tenant isolation or `TracingPolicy` cluster-wide with strict namespace selector matches.

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 execute binaries directly from memory descriptors (`/proc/self/fd/*` or anon_inode) inside production application containers.

Components NEVER execute binaries directly from memory descriptors (`/proc/self/fd/*` or anon_inode) inside production application containers.

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 Anonymous Memory Execution (memfd_create) Enforcement critical for AI coding assistants?

Enforces kernel-level interception via Cilium Tetragon TracingPolicies to detect and terminate fileless binary execution originating from anonymous memory descriptors. Prohibits unchecked combinations of memfd_create, fexecve, and execveat at the kernel boundary to prevent in-memory malware delivery within containerized workloads. 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 (Permissive Kernel Syscall Policies Enabling Fileless In-Memory Execution via Anonymous File Descriptors) 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