This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: tauri2-ipc-granular-capability-scope-acl

Tauri 2.0 Granular IPC Command Capability & Scope ACL Invariant

Enforces strict least-privilege capability manifests and explicit argument-scoping ACLs for all Tauri 2.0 webview-to-Rust IPC boundaries. Prohibits global wildcards, un-scoped filesystem paths, and unrestricted shell execution permissions across all capability definition files.

Prohibited Anti-Pattern: Assigning wildcard permissions or un-scoped filesystem/shell capabilities to webview windows

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Granular IPC Command Capability & Scope ACL Invariant - Enforces strict least-privilege capability manifests and explicit argument-scoping ACLs for all Tauri 2.0 webview-to-Rust IPC boundaries. Prohibits global wildcards, un-scoped filesystem paths, and unrestricted shell execution permissions across all capability definition files.
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/tauri2-ipc-granular-capability-scope-acl"
---

# Tauri 2.0 Granular IPC Command Capability & Scope ACL Invariant

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Assigning wildcard permissions or un-scoped filesystem/shell capabilities to webview windows

## System Constraints
You are a Principal Security Architect enforcing the Tauri 2.0 IPC Capability and Scope ACL Invariant. Tauri 2.0 replaces the legacy v1 allowlist with an explicit capability-based security model. You must verify that every IPC interaction across the webview boundary is defended by granular, least-privilege JSON capability files, strict path scopes, and cryptographically verified window identifiers. Never permit wildcard permissions (such as fs:default, shell:all, or broad path scopes like ** without restrictions) that permit Remote Code Execution (RCE) or Local File Inclusion (LFI) in the event of XSS in the frontend layer.

## Strict Guidelines
- Engineers MUST ALWAYS isolate capabilities into separate JSON manifest files inside `src-tauri/capabilities/` targeting specific window labels.
- Engineers MUST NOT grant open-ended permissions such as `core:default`, `shell:allow-execute`, or `fs:allow-all` without explicit scope constraints.
- Code MUST restrict filesystem plugin permissions to explicit directories using scope path interpolations (e.g., `$APPDATA/**`, `$RESOURCE/**`) and explicitly forbid traversing to root or sensitive paths (`$HOME/.ssh/**`, `/etc/**`).
- Services exposing custom `#[tauri::command]` functions MUST implement explicit parameter validation in Rust rather than relying on frontend input hygiene.
- Components NEVER execute raw system shells from the webview; all system interactions must be pre-configured fixed-program invocations with strictly bounded arguments.

## Bad vs Good Implementations
### Tauri 2.0 Capability Manifest Definition

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Granting wildcards across all windows ('*') with unrestricted 'fs:default' and 'shell:default' lets any XSS flaw access the entire host filesystem and execute arbitrary shell binaries.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "main-capability",
  "description": "Insecure capability file using wildcards",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:default",
    "shell:default"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Permissions are locked to the specific 'main' window label, filesystem reads are restricted to the local data directory with traversal defenses, and URL shell openers require strict regex validation.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "main-window-capability",
  "description": "Least-privilege capability restricting filesystem access to app cache",
  "windows": ["main"],
  "permissions": [
    "core:event:allow-listen",
    "core:event:allow-emit",
    {
      "identifier": "fs:allow-read-text-file",
      "allow": [
        { "path": "$APPLOCALDATA/logs/**" }
      ],
      "deny": [
        { "path": "$APPLOCALDATA/logs/../**" }
      ]
    },
    {
      "identifier": "shell:allow-open",
      "allow": [
        { "validator": "^https://(api\\.example\\.com|docs\\.example\\.com)/" }
      ]
    }
  ]
}
```

### Rust Custom Command IPC Registration & State Validation

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Exposing arbitrary process spawning through a Tauri command bypasses capability scopes entirely, providing a direct remote code execution vector from the webview.
```rust
use tauri::command;

#[command]
pub fn execute_custom_tool(binary_name: String, args: Vec<String>) -> Result<String, String> {
    // Vulnerable: Arbitrary command execution invoked directly from WebView input
    std::process::Command::new(binary_name)
        .args(args)
        .output()
        .map(|out| String::from_utf8_lossy(&out.stdout).to_string())
        .map_err(|e| e.to_string())
}
```

#### Production Standard (Correct)
> **Standard**: The command performs strict alphanumeric validation on input identifiers, resolves files against the secure AppLocalData directory, and executes canonical path verification to prevent path traversal.
```rust
use tauri::{command, AppHandle};
use std::path::PathBuf;

#[command]
pub async fn read_sanitized_report(
    app: AppHandle,
    report_id: String,
) -> Result<String, String> {
    // Validate input format to eliminate path traversal characters
    if !report_id.chars().all(|c| c.is_ascii_alphanumeric() || c == '-') {
        return Err("Invalid report ID format".into());
    }

    let base_dir = app.path().app_local_data_dir()
        .map_err(|_| "Failed to resolve data directory")?;
    let safe_path: PathBuf = base_dir.join("reports").join(format!("{}.json", report_id));

    // Verify canonical path resides strictly inside target boundary
    let canonical = safe_path.canonicalize().map_err(|_| "Report not found")?;
    if !canonical.starts_with(&base_dir) {
        return Err("Access denied: directory traversal attempt".into());
    }

    tokio::fs::read_to_string(canonical)
        .await
        .map_err(|e| format!("Failed to read report: {}", e))
}
```

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: Tauri 2.0 Granular IPC Command Capability & Scope ACL Invariant

Tauri 2.0 Granular IPC Command Capability & Scope ACL Invariant defines an industrial-grade behavioral standard for security engineering. Enforces strict least-privilege capability manifests and explicit argument-scoping ACLs for all Tauri 2.0 webview-to-Rust IPC boundaries. Prohibits global wildcards, un-scoped filesystem paths, and unrestricted shell execution permissions across all capability definition files. 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: Assigning wildcard permissions or un-scoped filesystem/shell capabilities to webview windows 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 DriftAssigning wildcard permissions or un-scoped filesystem/shell capabilities to webview windowsCritical
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 capabilities into separate JSON manifest files inside `src-tauri/capabilities/` targeting specific window labels.

Engineers MUST ALWAYS isolate capabilities into separate JSON manifest files inside `src-tauri/capabilities/` targeting specific window labels.

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 grant open-ended permissions such as `core

Engineers MUST NOT grant open-ended permissions such as `core:default`, `shell:allow-execute`, or `fs:allow-all` without explicit scope 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.
3

Code MUST restrict filesystem plugin permissions to explicit directories using scope path interpolations (e.g., `$APPDATA/**`, `$RESOURCE/**`) and explicitly forbid traversing to root or sensitive paths (`$HOME/.ssh/**`, `/etc/**`).

Code MUST restrict filesystem plugin permissions to explicit directories using scope path interpolations (e.g., `$APPDATA/**`, `$RESOURCE/**`) and explicitly forbid traversing to root or sensitive paths (`$HOME/.ssh/**`, `/etc/**`).

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 exposing custom `#[tauri

Services exposing custom `#[tauri::command]` functions MUST implement explicit parameter validation in Rust rather than relying on frontend input hygiene.

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 system shells from the webview

Components NEVER execute raw system shells from the webview; all system interactions must be pre-configured fixed-program invocations with strictly bounded arguments.

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 Tauri 2.0 Granular IPC Command Capability & Scope ACL Invariant critical for AI coding assistants?

Enforces strict least-privilege capability manifests and explicit argument-scoping ACLs for all Tauri 2.0 webview-to-Rust IPC boundaries. Prohibits global wildcards, un-scoped filesystem paths, and unrestricted shell execution permissions across all capability definition files. 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 (Assigning wildcard permissions or un-scoped filesystem/shell capabilities to webview windows) 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

Tauri