This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: tauri-v2-granular-ipc-capabilities-invariant

Enforce Granular Capability-Based IPC Permissions in Tauri 2.0

Tauri 2.0 replaces the legacy monolithic allowlist with a capability-driven access control model for IPC commands. Every frontend-to-Rust command, plugin capability, and filesystem/network scope must be explicitly mapped to designated windows and domains through scoped capability files, eliminating the risk of arbitrary command injection and remote code execution.

Prohibited Anti-Pattern: Over-privileged Default Capabilities and Wildcard IPC Command Execution

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Enforce Granular Capability-Based IPC Permissions in Tauri 2.0 - Tauri 2.0 replaces the legacy monolithic allowlist with a capability-driven access control model for IPC commands. Every frontend-to-Rust command, plugin capability, and filesystem/network scope must be explicitly mapped to designated windows and domains through scoped capability files, eliminating the risk of arbitrary command injection and remote code execution.
globs: src-tauri/capabilities/**/*.json, src-tauri/tauri.conf.json, src-tauri/src/**/*.rs, src/**/*.{ts,tsx}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tauri-v2-granular-ipc-capabilities-invariant"
---

# Enforce Granular Capability-Based IPC Permissions in Tauri 2.0

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Over-privileged Default Capabilities and Wildcard IPC Command Execution

## System Constraints
You are a Principal Security Architect enforcing Tauri 2.0's granular capability-based access control. Mandate strict segmentation of IPC commands, explicit capability scoping, and least-privilege permissions across all webview contexts.

## Strict Guidelines
- Engineers MUST ALWAYS isolate permissions into modular JSON files within `src-tauri/capabilities/` rather than granting blanket access.
- Engineers MUST NOT use wildcard plugin defaults (such as `shell:default`, `fs:default`, or `http:default`) when scoped permissions (like `fs:allow-read-text-file`) suffice.
- Code SHOULD bind capabilities strictly to explicit window labels (e.g., `"windows": ["main"]`) and never expose native privileges to wildcard (`"*"`) windows when handling external or untrusted web content.
- Services MUST constrain all filesystem and network capabilities with explicit path and URL scopes, preventing path traversal outside of designated sandbox directories.
- Components NEVER execute raw shell commands or unrestricted Rust commands without runtime parameter validation and capability-level argument constraints.

## Bad vs Good Implementations
### Tauri 2.0 IPC Capability Configuration

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Grants complete, un-scoped filesystem and shell execution rights to all windows, creating an immediate remote code execution vector if any untrusted or third-party webview content is loaded.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "main-capability",
  "description": "Insecure full access capability granted to all windows",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:default",
    "shell:default"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Explicitly binds permissions exclusively to the 'main' window, disallows shell execution, and confines filesystem access strictly to the application's documents directory via scoped path rules.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "main-capability",
  "description": "Least-privilege scoped permissions for the primary application window",
  "windows": ["main"],
  "permissions": [
    "core:path:default",
    "core:event:default",
    {
      "identifier": "fs:allow-read-text-file",
      "allow": [{
        "path": "$APPDATA/documents/**"
      }]
    },
    {
      "identifier": "fs:allow-write-text-file",
      "allow": [{
        "path": "$APPDATA/documents/**"
      }]
    }
  ]
}
```

### Rust Custom IPC Command Registration and Permission Definition

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Bypasses Tauri 2.0 capabilities and permits arbitrary file writes to any path accessible by the native process.
```rust
// Command registered without custom permission validation
#[tauri::command]
async fn execute_export(path: String, payload: String) -> Result<(), String> {
    // Directly writing to arbitrary paths supplied by the frontend
    std::fs::write(&path, payload).map_err(|e| e.to_string())
}
```

#### Production Standard (Correct)
> **Standard**: Resolves directories strictly through Tauri's runtime path resolver and sanitizes inputs against path traversal attacks.
```rust
use tauri::Manager;

#[tauri::command]
async fn execute_export<R: tauri::Runtime>(
    app: tauri::AppHandle<R>,
    file_name: String,
    payload: String,
) -> Result<(), String> {
    // Validate sanitized filename within trusted app-scoped data directory
    if file_name.contains('/') || file_name.contains('\\') || file_name.contains(".." ) {
        return Err("Invalid file name: directory traversal detected".into());
    }
    
    let safe_dir = app.path().app_data_dir().map_err(|e| e.to_string())?;
    let target = safe_dir.join("exports").join(file_name);
    
    std::fs::create_dir_all(target.parent().unwrap()).map_err(|e| e.to_string())?;
    std::fs::write(target, payload).map_err(|e| e.to_string())
}
```

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: Enforce Granular Capability-Based IPC Permissions in Tauri 2.0

Enforce Granular Capability-Based IPC Permissions in Tauri 2.0 defines an industrial-grade behavioral standard for security engineering. Tauri 2.0 replaces the legacy monolithic allowlist with a capability-driven access control model for IPC commands. Every frontend-to-Rust command, plugin capability, and filesystem/network scope must be explicitly mapped to designated windows and domains through scoped capability files, eliminating the risk of arbitrary command injection and remote code execution. 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: Over-privileged Default Capabilities and Wildcard IPC Command Execution 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 DriftOver-privileged Default Capabilities and Wildcard IPC Command ExecutionCritical
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 isolate permissions into modular JSON files within `src-tauri/capabilities/` rather than granting blanket access.

Engineers MUST ALWAYS isolate permissions into modular JSON files within `src-tauri/capabilities/` rather than granting blanket access.

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 use wildcard plugin defaults (such as `shell

Engineers MUST NOT use wildcard plugin defaults (such as `shell:default`, `fs:default`, or `http:default`) when scoped permissions (like `fs:allow-read-text-file`) suffice.

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

Code SHOULD bind capabilities strictly to explicit window labels (e.g., `"windows"

Code SHOULD bind capabilities strictly to explicit window labels (e.g., `"windows": ["main"]`) and never expose native privileges to wildcard (`"*"`) windows when handling external or untrusted web content.

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 constrain all filesystem and network capabilities with explicit path and URL scopes, preventing path traversal outside of designated sandbox directories.

Services MUST constrain all filesystem and network capabilities with explicit path and URL scopes, preventing path traversal outside of designated sandbox directories.

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 raw shell commands or unrestricted Rust commands without runtime parameter validation and capability-level argument constraints.

Components NEVER execute raw shell commands or unrestricted Rust commands without runtime parameter validation and capability-level argument constraints.

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 Enforce Granular Capability-Based IPC Permissions in Tauri 2.0 critical for AI coding assistants?

Tauri 2.0 replaces the legacy monolithic allowlist with a capability-driven access control model for IPC commands. Every frontend-to-Rust command, plugin capability, and filesystem/network scope must be explicitly mapped to designated windows and domains through scoped capability files, eliminating the risk of arbitrary command injection and remote code execution. 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 (Over-privileged Default Capabilities and Wildcard IPC Command Execution) 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

Enforce