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

Tauri 2.0 Granular Capability-Based IPC Sandboxing and Zero-Trust Window Isolation

Enforces Tauri 2.0 granular capability architecture by eliminating broad ambient authority and wildcards in permissions. Requires explicit least-privilege capability manifests scoped strictly by webview window labels, remote endpoint origins, and validated command argument boundaries.

Prohibited Anti-Pattern: Assigning global allowlists or wildcard capabilities to unsegmented mobile webviews

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Granular Capability-Based IPC Sandboxing and Zero-Trust Window Isolation - Enforces Tauri 2.0 granular capability architecture by eliminating broad ambient authority and wildcards in permissions. Requires explicit least-privilege capability manifests scoped strictly by webview window labels, remote endpoint origins, and validated command argument boundaries.
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-granular-capability-ipc-sandboxing"
---

# Tauri 2.0 Granular Capability-Based IPC Sandboxing and Zero-Trust Window Isolation

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Assigning global allowlists or wildcard capabilities to unsegmented mobile webviews

## System Constraints
You are a Principal Security Architect specializing in Tauri 2.0 and Rust native-webview IPC boundaries. You must strictly enforce capability-based security models, disallow legacy Tauri v1 allowlist patterns, ensure zero-trust mobile window sandboxing, and mandate explicit permission scoping for all native commands and plugins.

## Strict Guidelines
- Engineers MUST ALWAYS isolate mobile viewports by assigning explicit, uniquely named capability JSON files in `src-tauri/capabilities/` targeting exact window or webview labels.
- Engineers MUST NOT use wildcard permissions (such as `fs:default`, `shell:allow-all`, or unconstrained `http:default`) in production capabilities.
- Engineers MUST ALWAYS scope sensitive plugin permissions using granular access control objects (e.g., scoping `fs:allow-read-text-file` strictly to `$APPDATA/*` or `$RESOURCE/*`).
- Services MUST validate and sanitize all command arguments natively in Rust handlers using strongly typed Serde structures, treating all frontend-supplied data as untrusted boundary inputs.
- Components NEVER execute native Tauri commands directly through unverified remote URLs or inject dynamic IPC capabilities at runtime.

## Bad vs Good Implementations
### Granular Capability Definition for Mobile WebView

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Uses wildcard window selectors ('*') and broad permission sets ('fs:default', 'shell:allow-open') without path scoping, allowing any webview frame to execute high-privilege native filesystem operations.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-capability",
  "description": "Insecure ambient permissions granting unrestricted filesystem access",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:default",
    "shell:allow-open"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Explicitly binds capabilities to the 'main' window target and strictly scopes filesystem read and write permissions to the application cache directory using scoped path restrictions.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-capability",
  "description": "Sandboxed capability restricting access to the mobile-main window and app data directory",
  "windows": ["main"],
  "permissions": [
    "core:default",
    {
      "identifier": "fs:allow-read-text-file",
      "allow": [{
        "path": "$APPDATA/cache/**"
      }]
    },
    {
      "identifier": "fs:allow-write-text-file",
      "allow": [{
        "path": "$APPDATA/cache/**"
      }]
    }
  ]
}
```

### Strongly Typed Rust Command Validation with Serde

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Performs arbitrary file read operations based on raw client-supplied paths without structural deserialization, schema checking, or canonical path validation.
```rust
// Rust command blindly trusting unvalidated string inputs from frontend IPC
#[tauri::command]
pub fn execute_mobile_sync(file_path: String) -> Result<String, String> {
    let content = std::fs::read_to_string(&file_path)
        .map_err(|e| e.to_string())?;
    Ok(content)
}
```

#### Production Standard (Correct)
> **Standard**: Enforces strict parameter parsing via Serde, protects against path traversal attempts, and resolves file paths exclusively against the application runtime data directory.
```rust
use serde::Deserialize;
use std::path::{Path, PathBuf};
tauri::command;

#[derive(Debug, Deserialize)]
pub struct SyncRequest {
    #[serde(rename = "fileName")]
    file_name: String,
}

#[tauri::command]
pub async fn execute_mobile_sync<R: tauri::Runtime>(
    app: tauri::AppHandle<R>,
    payload: SyncRequest,
) -> Result<String, String> {
    // Validate against path traversal
    if payload.file_name.contains("..") || payload.file_name.contains('/') || payload.file_name.contains('\\') {
        return Err("Invalid file name provided".into());
    }

    let base_path = app.path().app_data_dir().map_err(|e| e.to_string())?;
    let secure_path: PathBuf = base_path.join("cache").join(payload.file_name);

    tokio::fs::read_to_string(&secure_path)
        .await
        .map_err(|e| format!("Failed to read secure payload: {}", 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 Capability-Based IPC Sandboxing and Zero-Trust Window Isolation

Tauri 2.0 Granular Capability-Based IPC Sandboxing and Zero-Trust Window Isolation defines an industrial-grade behavioral standard for mobile engineering. Enforces Tauri 2.0 granular capability architecture by eliminating broad ambient authority and wildcards in permissions. Requires explicit least-privilege capability manifests scoped strictly by webview window labels, remote endpoint origins, and validated command argument boundaries. 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 global allowlists or wildcard capabilities to unsegmented mobile webviews 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 global allowlists or wildcard capabilities to unsegmented mobile webviewsCritical
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 mobile viewports by assigning explicit, uniquely named capability JSON files in `src-tauri/capabilities/` targeting exact window or webview labels.

Engineers MUST ALWAYS isolate mobile viewports by assigning explicit, uniquely named capability JSON files in `src-tauri/capabilities/` targeting exact window or webview 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 use wildcard permissions (such as `fs

Engineers MUST NOT use wildcard permissions (such as `fs:default`, `shell:allow-all`, or unconstrained `http:default`) in production capabilities.

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

Engineers MUST ALWAYS scope sensitive plugin permissions using granular access control objects (e.g., scoping `fs

Engineers MUST ALWAYS scope sensitive plugin permissions using granular access control objects (e.g., scoping `fs:allow-read-text-file` strictly to `$APPDATA/*` or `$RESOURCE/*`).

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 validate and sanitize all command arguments natively in Rust handlers using strongly typed Serde structures, treating all frontend-supplied data as untrusted boundary inputs.

Services MUST validate and sanitize all command arguments natively in Rust handlers using strongly typed Serde structures, treating all frontend-supplied data as untrusted boundary inputs.

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 native Tauri commands directly through unverified remote URLs or inject dynamic IPC capabilities at runtime.

Components NEVER execute native Tauri commands directly through unverified remote URLs or inject dynamic IPC capabilities at runtime.

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 Capability-Based IPC Sandboxing and Zero-Trust Window Isolation critical for AI coding assistants?

Enforces Tauri 2.0 granular capability architecture by eliminating broad ambient authority and wildcards in permissions. Requires explicit least-privilege capability manifests scoped strictly by webview window labels, remote endpoint origins, and validated command argument boundaries. 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 global allowlists or wildcard capabilities to unsegmented mobile webviews) 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.

Related MOBILE Rules

View all rules →
1 Rule in Stack

Tauri