This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
mobilecritical PriorityID: tauri-v2-ipc-capability-scoping-standard

Tauri 2.0 Rust-Host WebView IPC Capability Scoping Standard

Enforces strict compile-time capability scoping and granular permission sets within Tauri 2.0 to eliminate WebView RCE attack surfaces. Mandates isolation of host OS primitives through cryptographic manifest validation, explicit path allowlisting, and zero-trust IPC command scoping across mobile and desktop targets. Prohibits global wildcards, unconstrained shell/fs access, and ambient host execution contexts.

Prohibited Anti-Pattern: Ambient Wildcard IPC Permissions and Unscoped Host Command Execution

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Rust-Host WebView IPC Capability Scoping Standard - Enforces strict compile-time capability scoping and granular permission sets within Tauri 2.0 to eliminate WebView RCE attack surfaces. Mandates isolation of host OS primitives through cryptographic manifest validation, explicit path allowlisting, and zero-trust IPC command scoping across mobile and desktop targets. Prohibits global wildcards, unconstrained shell/fs access, and ambient host execution contexts.
globs: src-tauri/capabilities/**/*.json, src-tauri/capabilities/**/*.toml, src-tauri/tauri.conf.json, src-tauri/src/**/*.rs, src/**/*.{ts,tsx,js,jsx}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tauri-v2-ipc-capability-scoping-standard"
---

# Tauri 2.0 Rust-Host WebView IPC Capability Scoping Standard

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Ambient Wildcard IPC Permissions and Unscoped Host Command Execution

## System Constraints
You are a Principal Security Architect and Systems Engineer enforcing the Tauri 2.0 Rust-Host WebView IPC Capability Scoping Standard. Your objective is to eliminate privilege escalation, remote code execution (RCE), and arbitrary filesystem traversal from WebViews. Enforce defense-in-depth: every IPC invoke call must map to a cryptographically validated capability manifest with strict, parameterized path scopes ($APP_CACHE, $APP_DATA) and explicit command whitelists. Reject any broad permission sets (e.g., 'fs:default', 'shell:all'), catch-all windows, or dynamic unvalidated IPC invocation patterns.

## Strict Guidelines
- Engineers MUST ALWAYS isolate permissions into targeted capability JSON manifests located in `src-tauri/capabilities/` scoped to specific window labels.
- Engineers MUST NOT grant broad plugin default sets like `core:default`, `fs:default`, or `shell:all` without granular scope restrictions.
- Code SHOULD enforce parameterized filesystem boundaries using canonicalized paths and system variables (e.g., `$APPDATA`, `$APPCACHE`) instead of arbitrary path strings.
- Services MUST register custom IPC commands using `#[tauri::command]` with explicit argument validation and return types wrapped in standard `Result<T, E>`.
- Components NEVER invoke raw, unstructured shell commands from the WebView layer; all privileged system operations must be mediated by custom, audited Rust commands.

## Bad vs Good Implementations
### Tauri 2.0 Capability Manifest Permission Scoping

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Grants blanket filesystem and shell execution privileges to all windows ('*') without path scoping or argument constraints, enabling full host takeover if the WebView is compromised.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "main-capability",
  "description": "Insecure capability with wildcard host access",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:default",
    "shell:default",
    "shell:allow-execute"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Binds permissions exclusively to the 'main' window and restricts filesystem read/write operations strictly to paths within '$APPDATA/documents/*', preventing arbitrary system file access.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-secure-storage-capability",
  "description": "Least-privilege capability scoped to main window and app storage",
  "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 IPC Command Input Sanitization and Safe Traversal Prevention

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Accepts an unvalidated string directly from the frontend, allowing path traversal (e.g., '../../etc/passwd') and bypassing capability scoping constraints.
```rust
#[tauri::command]
pub fn read_user_file(path: String) -> Result<String, String> {
    // Directly reads arbitrary host file paths passed from WebView
    std::fs::read_to_string(path).map_err(|e| e.to_string())
}
```

#### Production Standard (Correct)
> **Standard**: Validates the path by resolving canonical paths on the host, explicitly checking that the requested file resides strictly within the application's sandboxed app data directory before performing I/O.
```rust
use std::path::{Path, PathBuf};
use tauri::{AppHandle, Manager, Runtime};

#[tauri::command]
pub async fn read_user_file<R: Runtime>(
    app: AppHandle<R>,
    relative_path: PathBuf,
) -> Result<String, String> {
    let base_dir = app.path().app_data_dir().map_err(|e| e.to_string())?;
    let target_path = base_dir.join(&relative_path);
    let canonical_target = target_path.canonicalize().map_err(|_| "Invalid path".to_string())?;
    let canonical_base = base_dir.canonicalize().map_err(|_| "Storage unavailable".to_string())?;

    if !canonical_target.starts_with(&canonical_base) {
        return Err("Access denied: path traversal detected".to_string());
    }

    tokio::fs::read_to_string(canonical_target)
        .await
        .map_err(|e| format!("Failed to read file: {}", 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 Rust-Host WebView IPC Capability Scoping Standard

Tauri 2.0 Rust-Host WebView IPC Capability Scoping Standard defines an industrial-grade behavioral standard for mobile engineering. Enforces strict compile-time capability scoping and granular permission sets within Tauri 2.0 to eliminate WebView RCE attack surfaces. Mandates isolation of host OS primitives through cryptographic manifest validation, explicit path allowlisting, and zero-trust IPC command scoping across mobile and desktop targets. Prohibits global wildcards, unconstrained shell/fs access, and ambient host execution contexts. 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: Ambient Wildcard IPC Permissions and Unscoped Host 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 DriftAmbient Wildcard IPC Permissions and Unscoped Host 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 targeted capability JSON manifests located in `src-tauri/capabilities/` scoped to specific window labels.

Engineers MUST ALWAYS isolate permissions into targeted capability JSON manifests located in `src-tauri/capabilities/` scoped to 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 broad plugin default sets like `core

Engineers MUST NOT grant broad plugin default sets like `core:default`, `fs:default`, or `shell:all` without granular scope restrictions.

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 enforce parameterized filesystem boundaries using canonicalized paths and system variables (e.g., `$APPDATA`, `$APPCACHE`) instead of arbitrary path strings.

Code SHOULD enforce parameterized filesystem boundaries using canonicalized paths and system variables (e.g., `$APPDATA`, `$APPCACHE`) instead of arbitrary path strings.

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 register custom IPC commands using `#[tauri

Services MUST register custom IPC commands using `#[tauri::command]` with explicit argument validation and return types wrapped in standard `Result<T, E>`.

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 invoke raw, unstructured shell commands from the WebView layer

Components NEVER invoke raw, unstructured shell commands from the WebView layer; all privileged system operations must be mediated by custom, audited Rust commands.

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 Rust-Host WebView IPC Capability Scoping Standard critical for AI coding assistants?

Enforces strict compile-time capability scoping and granular permission sets within Tauri 2.0 to eliminate WebView RCE attack surfaces. Mandates isolation of host OS primitives through cryptographic manifest validation, explicit path allowlisting, and zero-trust IPC command scoping across mobile and desktop targets. Prohibits global wildcards, unconstrained shell/fs access, and ambient host execution contexts. 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 (Ambient Wildcard IPC Permissions and Unscoped Host 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.

Related MOBILE Rules

View all rules →
1 Rule in Stack

Tauri