This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: cilium-tetragon-lsm-privilege-escalation-guardrail

Synchronous eBPF LSM Namespace and Unshare Privilege Escalation Prevention

Enforces synchronous in-kernel blocking of container breakout and unshare privilege escalation attempts via Cilium Tetragon eBPF Linux Security Module (LSM) hooks. Prevents kernel execution of unauthorized namespace creation (CLONE_NEWUSER) and capability escalation by triggering immediate SIGKILL actions prior to syscall completion.

Prohibited Anti-Pattern: Relying on Asynchronous Audit-Only Kprobes for Container Breakout Detection

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Synchronous eBPF LSM Namespace and Unshare Privilege Escalation Prevention - Enforces synchronous in-kernel blocking of container breakout and unshare privilege escalation attempts via Cilium Tetragon eBPF Linux Security Module (LSM) hooks. Prevents kernel execution of unauthorized namespace creation (CLONE_NEWUSER) and capability escalation by triggering immediate SIGKILL actions prior to syscall completion.
globs: k8s/**/*.yaml, deploy/**/*.yaml, helm/**/*.yaml, security/**/*.yaml, tetragon/**/*.yaml
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/cilium-tetragon-lsm-privilege-escalation-guardrail"
---

# Synchronous eBPF LSM Namespace and Unshare Privilege Escalation Prevention

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Relying on Asynchronous Audit-Only Kprobes for Container Breakout Detection

## System Constraints
You are a Principal Security and Infrastructure Architect enforcing kernel-level synchronous container isolation through Cilium Tetragon eBPF LSM policies. Mandate that all container runtime security manifests enforce deterministic, in-kernel blocking actions (SIGKILL or EPERM overrides) on namespace manipulation (unshare, setns) and privilege transitions, completely rejecting passive audit-only configurations for critical syscall primitives.

## Strict Guidelines
- Engineers MUST ALWAYS declare TracingPolicy or TracingPolicyNamespaced resources under apiVersion 'cilium.io/v1alpha1' with explicit 'Sigkill' or 'Override' actions for unauthorized namespace operations.
- Engineers MUST NOT rely on passive observability, post-hoc alerts, or unconstrained tracepoints for known privilege escalation vectors such as unshare with CLONE_NEWUSER.
- TracingPolicy resources MUST bind to LSM hooks (e.g., 'lsm/create_user_ns', 'lsm/capable') or synchronous kprobe hooks with immediate enforcement capabilities rather than purely asynchronous tracepoints.
- Selectors MUST explicitly filter for non-root or unauthorized namespace contexts and target suspicious flag masks (such as CLONE_NEWUSER: 0x10000000) inside container boundaries.
- Infrastructure deployments MUST ensure Tetragon is deployed with 'tetragon.enableProcessCred=true' and verified LSM BPF program attachment in the underlying host Linux kernel (>= 5.7 with BPF_LSM enabled).

## Bad vs Good Implementations
### Tetragon TracingPolicy: Namespace Privilege Escalation Guardrail

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Passive kprobe tracing simply logs the execution of the unshare syscall after the fact. In an active exploit (e.g., unshare privilege escalation to establish an unprivileged user namespace mapped to root), the attacker compromises host resources before any external controller or SIEM can react.
```yaml
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: audit-unshare-syscall
spec:
  kprobes:
    - call: "sys_enter_unshare"
      syscall: true
      args:
        - index: 0
          type: "int"
      # Flaw: No 'action' specified. Emits an event asynchronously
      # while allowing the container breakout to proceed unimpeded.
```

#### Production Standard (Correct)
> **Standard**: This policy attaches an in-kernel synchronous filter via eBPF. When any container in the target namespace invokes sys_unshare with the CLONE_NEWUSER bitmask, Tetragon instantly sends SIGKILL to the offending process before the kernel allocates new namespace credentials, preventing privilege escalation entirely.
```yaml
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
  name: block-namespace-privilege-escalation
spec:
  kprobes:
    - call: "sys_enter_unshare"
      syscall: true
      args:
        - index: 0
          type: "int"
      selectors:
        - matchArgs:
            - index: 0
              operator: "Mask"
              values:
                - "268435456" # CLONE_NEWUSER (0x10000000)
          matchNamespaces:
            - namespace: "default"
              operator: "In"
          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: Synchronous eBPF LSM Namespace and Unshare Privilege Escalation Prevention

Synchronous eBPF LSM Namespace and Unshare Privilege Escalation Prevention defines an industrial-grade behavioral standard for devops engineering. Enforces synchronous in-kernel blocking of container breakout and unshare privilege escalation attempts via Cilium Tetragon eBPF Linux Security Module (LSM) hooks. Prevents kernel execution of unauthorized namespace creation (CLONE_NEWUSER) and capability escalation by triggering immediate SIGKILL actions prior to syscall completion. 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 Audit-Only Kprobes for Container Breakout Detection 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 Audit-Only Kprobes for Container Breakout DetectionCritical
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 or TracingPolicyNamespaced resources under apiVersion 'cilium.io/v1alpha1' with explicit 'Sigkill' or 'Override' actions for unauthorized namespace operations.

Engineers MUST ALWAYS declare TracingPolicy or TracingPolicyNamespaced resources under apiVersion 'cilium.io/v1alpha1' with explicit 'Sigkill' or 'Override' actions for unauthorized namespace 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.
2

Engineers MUST NOT rely on passive observability, post-hoc alerts, or unconstrained tracepoints for known privilege escalation vectors such as unshare with CLONE_NEWUSER.

Engineers MUST NOT rely on passive observability, post-hoc alerts, or unconstrained tracepoints for known privilege escalation vectors such as unshare with CLONE_NEWUSER.

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 bind to LSM hooks (e.g., 'lsm/create_user_ns', 'lsm/capable') or synchronous kprobe hooks with immediate enforcement capabilities rather than purely asynchronous tracepoints.

TracingPolicy resources MUST bind to LSM hooks (e.g., 'lsm/create_user_ns', 'lsm/capable') or synchronous kprobe hooks with immediate enforcement capabilities rather than purely asynchronous tracepoints.

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

Selectors MUST explicitly filter for non-root or unauthorized namespace contexts and target suspicious flag masks (such as CLONE_NEWUSER

Selectors MUST explicitly filter for non-root or unauthorized namespace contexts and target suspicious flag masks (such as CLONE_NEWUSER: 0x10000000) inside container boundaries.

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

Infrastructure deployments MUST ensure Tetragon is deployed with 'tetragon.enableProcessCred=true' and verified LSM BPF program attachment in the underlying host Linux kernel (>= 5.7 with BPF_LSM enabled).

Infrastructure deployments MUST ensure Tetragon is deployed with 'tetragon.enableProcessCred=true' and verified LSM BPF program attachment in the underlying host Linux kernel (>= 5.7 with BPF_LSM enabled).

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 Synchronous eBPF LSM Namespace and Unshare Privilege Escalation Prevention critical for AI coding assistants?

Enforces synchronous in-kernel blocking of container breakout and unshare privilege escalation attempts via Cilium Tetragon eBPF Linux Security Module (LSM) hooks. Prevents kernel execution of unauthorized namespace creation (CLONE_NEWUSER) and capability escalation by triggering immediate SIGKILL actions prior to syscall completion. 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 Audit-Only Kprobes for Container Breakout Detection) 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

Synchronous