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

Tauri 2.0 Granular Capability-Scoped IPC Permission Shield and Origin Guardrail

Enforces Tauri 2.0 compile-time JSON capability contracts and cryptographic IPC boundary isolation for hybrid mobile platforms. Eliminates wildcards in permission files, enforces window-level capability isolation, and mandates origin validation to prevent arbitrary native command execution from compromised webview contexts.

Prohibited Anti-Pattern: Unrestricted IPC Access via Wildcard Permissions and Unscoped Window Capabilities

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Granular Capability-Scoped IPC Permission Shield and Origin Guardrail - Enforces Tauri 2.0 compile-time JSON capability contracts and cryptographic IPC boundary isolation for hybrid mobile platforms. Eliminates wildcards in permission files, enforces window-level capability isolation, and mandates origin validation to prevent arbitrary native command execution from compromised webview contexts.
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-capability-scoped-ipc-permission-shield"
---

# Tauri 2.0 Granular Capability-Scoped IPC Permission Shield and Origin Guardrail

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Unrestricted IPC Access via Wildcard Permissions and Unscoped Window Capabilities

## System Constraints
You are a Principal Mobile Security Architect enforcing Tauri 2.0 Granular Capability-Scoped IPC Permission Shields. Tauri 2.0 strictly supersedes the v1 allowlist with an explicit capability and permission model. You must reject any wildcard permission scopes, unvalidated remote origins, or unrestricted custom IPC commands. Enforce compile-time capability schemas, window-isolated command bindings, and cryptographic origin verification for all hybrid webview-to-native execution boundaries.

## Strict Guidelines
- Engineers MUST ALWAYS declare capabilities in granular JSON files inside 'src-tauri/capabilities/' with explicit window targets and granular permissions rather than global wildcards.
- Engineers MUST NOT grant default 'core:*' or wildcard plugin permissions (such as 'fs:default' or 'shell:all') to any window capability set.
- Engineers MUST ALWAYS bind custom native Rust commands to explicit custom permissions defined via Tauri 2.0 permission manifests rather than leaving commands unprotected.
- Webview callers MUST validate target command existence and payload schemas using strongly typed wrappers before invoking 'invoke()' over the IPC bridge.
- Components NEVER allow remote URLs or third-party web contexts to inherit mobile native execution capabilities without signed origin pinning and explicit capability restriction.

## Bad vs Good Implementations
### Capability Definition: Wildcard Permissions vs Explicit Scoped Invariants

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Using '*' for target windows and high-privilege wildcards like 'fs:all' grants any webview context unrestricted file-system and shell access, violating the principle of least privilege.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-capability",
  "description": "Insecure wildcard capability grant",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:all",
    "shell:allow-open"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Pins the capability explicitly to the 'main' window and limits file system operations strictly to a path-scoped read operation within the designated application data cache directory.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-capability-main",
  "description": "Hardened scoped capability for the primary mobile window",
  "windows": ["main"],
  "permissions": [
    "core:event:default",
    "core:window:allow-set-title",
    {
      "identifier": "fs:allow-read-text-file",
      "allow": [{
        "path": "$APP_DATA_DIR/secure_cache/**"
      }]
    }
  ]
}
```

### Rust Command Registration and IPC Validation

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The command performs raw path traversal without checking caller window capabilities, app-directory scoping, or path sanitization.
```rust
// Insecure custom command without capability enforcement or parameter validation
#[tauri::command]
pub fn execute_vault_read(file_name: String) -> Result<String, String> {
    let path = std::path::PathBuf::from("/secret/vault").join(file_name);
    std::fs::read_to_string(path).map_err(|e| e.to_string())
}
```

#### Production Standard (Correct)
> **Standard**: Validates the caller context, enforces directory boundary constraints using standard path resolution, and prevents directory traversal attacks.
```rust
use tauri::{ipc::Request, Manager, Runtime};
use std::path::{Path, PathBuf};

#[tauri::command]
pub async fn execute_vault_read<R: Runtime>(
    app: tauri::AppHandle<R>,
    window: tauri::Window<R>,
    file_name: String,
) -> Result<String, String> {
    // Verify caller window label
    if window.label() != "main" {
        return Err("Unauthorized caller context".into());
    }
    
    // Prevent directory traversal attacks
    if file_name.contains("..") || file_name.starts_with('/') {
        return Err("Invalid file path format".into());
    }

    let safe_dir = app.path().app_data_dir().map_err(|e| e.to_string())?;
    let target = safe_dir.join("vault").join(file_name);
    
    std::fs::read_to_string(target).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 Granular Capability-Scoped IPC Permission Shield and Origin Guardrail

Tauri 2.0 Granular Capability-Scoped IPC Permission Shield and Origin Guardrail defines an industrial-grade behavioral standard for mobile engineering. Enforces Tauri 2.0 compile-time JSON capability contracts and cryptographic IPC boundary isolation for hybrid mobile platforms. Eliminates wildcards in permission files, enforces window-level capability isolation, and mandates origin validation to prevent arbitrary native command execution from compromised webview 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: Unrestricted IPC Access via Wildcard Permissions and Unscoped Window Capabilities 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 DriftUnrestricted IPC Access via Wildcard Permissions and Unscoped Window CapabilitiesCritical
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 capabilities in granular JSON files inside 'src-tauri/capabilities/' with explicit window targets and granular permissions rather than global wildcards.

Engineers MUST ALWAYS declare capabilities in granular JSON files inside 'src-tauri/capabilities/' with explicit window targets and granular permissions rather than global wildcards.

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 default 'core

Engineers MUST NOT grant default 'core:*' or wildcard plugin permissions (such as 'fs:default' or 'shell:all') to any window capability set.

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 bind custom native Rust commands to explicit custom permissions defined via Tauri 2.0 permission manifests rather than leaving commands unprotected.

Engineers MUST ALWAYS bind custom native Rust commands to explicit custom permissions defined via Tauri 2.0 permission manifests rather than leaving commands unprotected.

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

Webview callers MUST validate target command existence and payload schemas using strongly typed wrappers before invoking 'invoke()' over the IPC bridge.

Webview callers MUST validate target command existence and payload schemas using strongly typed wrappers before invoking 'invoke()' over the IPC bridge.

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 allow remote URLs or third-party web contexts to inherit mobile native execution capabilities without signed origin pinning and explicit capability restriction.

Components NEVER allow remote URLs or third-party web contexts to inherit mobile native execution capabilities without signed origin pinning and explicit capability restriction.

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-Scoped IPC Permission Shield and Origin Guardrail critical for AI coding assistants?

Enforces Tauri 2.0 compile-time JSON capability contracts and cryptographic IPC boundary isolation for hybrid mobile platforms. Eliminates wildcards in permission files, enforces window-level capability isolation, and mandates origin validation to prevent arbitrary native command execution from compromised webview 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 (Unrestricted IPC Access via Wildcard Permissions and Unscoped Window Capabilities) 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