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

Tauri 2.0 Mobile IPC Capability Manifest and Permission Boundary Enforcement

Enforces strict principle-of-least-privilege capability manifests and explicit permission files in Tauri 2.0 mobile architectures. Disallows wildcard IPC exposure, unconstrained remote origins, and global command access to prevent cross-origin privilege escalation and remote code execution via mobile WebViews.

Prohibited Anti-Pattern: Wildcard Capability Manifests Exposing Native Rust Commands to Untrusted Web Contexts

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Mobile IPC Capability Manifest and Permission Boundary Enforcement - Enforces strict principle-of-least-privilege capability manifests and explicit permission files in Tauri 2.0 mobile architectures. Disallows wildcard IPC exposure, unconstrained remote origins, and global command access to prevent cross-origin privilege escalation and remote code execution via mobile WebViews.
globs: src-tauri/capabilities/**/*.json, src-tauri/capabilities/**/*.toml, 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-mobile-ipc-capability-scoping-tauri-2-0-ipc-gr-504"
---

# Tauri 2.0 Mobile IPC Capability Manifest and Permission Boundary Enforcement

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Wildcard Capability Manifests Exposing Native Rust Commands to Untrusted Web Contexts

## System Constraints
You are a Principal Security Architect enforcing the Tauri 2.0 IPC Capability Scoping Boundary. In Tauri 2.0 mobile applications (iOS/Android), all communication between WebView runtimes and native Rust commands MUST be explicitly permitted through granular capability files and fine-grained permission manifests. Never allow default wildcard capabilities, permissive remote URL bindings, or unscoped native commands that can be invoked across iframe or deep-link navigation contexts. Enforce strict isolation between web view labels and Rust invoke handlers.

## Strict Guidelines
- Engineers MUST ALWAYS define discrete capability manifests under `src-tauri/capabilities/` targeting specific window and webview labels (e.g., `windows: ["main"]`).
- Engineers MUST NOT grant remote URL access (`remote.urls`) to privileged native capabilities or custom Rust commands without cryptographic domain pinning and strict origin validation.
- Engineers MUST NOT use wildcard permissions (`*`) or unrestricted plugin sets (e.g., blanket `core:default`) for mobile-exposed surfaces.
- Code SHOULD validate and sanitize IPC payload boundaries inside native Rust command handlers using strongly-typed Serde structs with non-empty validation invariants.
- Services MUST isolate high-privilege operations (e.g., filesystem, keychain, biometric authentication) into dedicated, non-default capabilities that require explicit user interaction.
- Components NEVER execute raw or dynamic strings via `invoke()` without compile-time TypeScript type definitions mapped directly to declared Rust handlers.

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

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Grants arbitrary web views and all remote origins access to critical native permissions (fs:default and execute-command), allowing cross-origin privilege escalation.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-capability-all",
  "description": "Insecure default capability granting universal access",
  "windows": ["*"],
  "remote": {
    "urls": ["https://*.*"]
  },
  "permissions": [
    "core:default",
    "fs:default",
    "allow-execute-system-command"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Scopes capabilities strictly to the 'main' local webview label, eliminates remote web contexts, and grants only explicit, granular permissions required for the mobile surface.
```json
{
  "$schema": "../gen/schemas/mobile-schema.json",
  "identifier": "mobile-auth-capability",
  "description": "Least-privilege capability strictly scoped to local main webview",
  "windows": ["main"],
  "webviews": ["main"],
  "remote": {
    "urls": []
  },
  "permissions": [
    "core:event:default",
    "biometric:allow-authenticate",
    "app:allow-read-secure-token"
  ]
}
```

### Native Rust IPC Command Handler with Granular Scope Enforcement

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Directly reads arbitrary system paths without checking app-scoped sandboxing or using Tauri's managed state and granular FS permissions.
```rust
// Insecure: Accepts untyped payload and lacks validation or capability alignment
#[tauri::command]
pub fn execute_file_transfer(path: String) -> Result<String, String> {
    std::fs::read_to_string(path).map_err(|e| e.to_string())
}
```

#### Production Standard (Correct)
> **Standard**: Uses strongly typed Serde payload validation, checks input boundaries, and restricts file operations to internal sandboxed app storage rather than raw path traversal.
```rust
use tauri::{command, AppHandle, Manager, Runtime};
use serde::Deserialize;

#[derive(Deserialize)]
pub struct SecureReadRequest {
    pub file_id: String,
}

#[command]
pub async fn read_sandboxed_data<R: Runtime>(
    _app: AppHandle<R>,
    payload: SecureReadRequest,
) -> Result<String, String> {
    // Validate identifier against strict alphanumeric pattern
    if !payload.file_id.chars().all(|c| c.is_alphanumeric() || c == '-') {
        return Err("Invalid file identifier provided".into());
    }
    
    // Read strictly from internal sandbox via Tauri managed storage
    crate::secure_store::read_token(&payload.file_id)
        .map_err(|e| format!("Storage error: {}", 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 Mobile IPC Capability Manifest and Permission Boundary Enforcement

Tauri 2.0 Mobile IPC Capability Manifest and Permission Boundary Enforcement defines an industrial-grade behavioral standard for mobile engineering. Enforces strict principle-of-least-privilege capability manifests and explicit permission files in Tauri 2.0 mobile architectures. Disallows wildcard IPC exposure, unconstrained remote origins, and global command access to prevent cross-origin privilege escalation and remote code execution via mobile WebViews. 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: Wildcard Capability Manifests Exposing Native Rust Commands to Untrusted Web Contexts 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 DriftWildcard Capability Manifests Exposing Native Rust Commands to Untrusted Web ContextsCritical
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 define discrete capability manifests under `src-tauri/capabilities/` targeting specific window and webview labels (e.g., `windows

Engineers MUST ALWAYS define discrete capability manifests under `src-tauri/capabilities/` targeting specific window and webview labels (e.g., `windows: ["main"]`).

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 remote URL access (`remote.urls`) to privileged native capabilities or custom Rust commands without cryptographic domain pinning and strict origin validation.

Engineers MUST NOT grant remote URL access (`remote.urls`) to privileged native capabilities or custom Rust commands without cryptographic domain pinning and strict origin validation.

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 NOT use wildcard permissions (`*`) or unrestricted plugin sets (e.g., blanket `core

Engineers MUST NOT use wildcard permissions (`*`) or unrestricted plugin sets (e.g., blanket `core:default`) for mobile-exposed surfaces.

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

Code SHOULD validate and sanitize IPC payload boundaries inside native Rust command handlers using strongly-typed Serde structs with non-empty validation invariants.

Code SHOULD validate and sanitize IPC payload boundaries inside native Rust command handlers using strongly-typed Serde structs with non-empty validation invariants.

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

Services MUST isolate high-privilege operations (e.g., filesystem, keychain, biometric authentication) into dedicated, non-default capabilities that require explicit user interaction.

Services MUST isolate high-privilege operations (e.g., filesystem, keychain, biometric authentication) into dedicated, non-default capabilities that require explicit user interaction.

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.
6

Components NEVER execute raw or dynamic strings via `invoke()` without compile-time TypeScript type definitions mapped directly to declared Rust handlers.

Components NEVER execute raw or dynamic strings via `invoke()` without compile-time TypeScript type definitions mapped directly to declared Rust handlers.

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 Mobile IPC Capability Manifest and Permission Boundary Enforcement critical for AI coding assistants?

Enforces strict principle-of-least-privilege capability manifests and explicit permission files in Tauri 2.0 mobile architectures. Disallows wildcard IPC exposure, unconstrained remote origins, and global command access to prevent cross-origin privilege escalation and remote code execution via mobile WebViews. 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 (Wildcard Capability Manifests Exposing Native Rust Commands to Untrusted Web Contexts) 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