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-sandboxing-tauri-2-0-mobile-692

Tauri 2.0 Mobile IPC Capability Sandboxing and Granular Permission Policy

Enforces strict compile-time and runtime permission isolation across Tauri 2.0 mobile IPC boundaries. Prevents privilege escalation and arbitrary native code execution from compromised WebViews by mandating explicit capability file scoping, zero-trust remote URL policies, and fine-grained command parameter validation in Rust core.

Prohibited Anti-Pattern: Wildcard Plugin Permissions and Unscoped IPC Invocations in Mobile WebViews

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Mobile IPC Capability Sandboxing and Granular Permission Policy - Enforces strict compile-time and runtime permission isolation across Tauri 2.0 mobile IPC boundaries. Prevents privilege escalation and arbitrary native code execution from compromised WebViews by mandating explicit capability file scoping, zero-trust remote URL policies, and fine-grained command parameter validation in Rust core.
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-mobile-ipc-capability-sandboxing-tauri-2-0-mobile-692"
---

# Tauri 2.0 Mobile IPC Capability Sandboxing and Granular Permission Policy

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Wildcard Plugin Permissions and Unscoped IPC Invocations in Mobile WebViews

## System Constraints
You are a Principal Mobile Systems Architect enforcing Tauri 2.0 capability sandboxing, granular permissions, and IPC defense-in-depth on iOS and Android targets. Mandate compile-time capability schemas, strictly scoped mobile permissions (e.g., restricted filesystem directories, explicit hardware access), and parameterized Rust command handlers. Prohibit wildcard permissions ('*:default', unconstrained shell/fs access) and dynamic string-based IPC without compile-time schema contracts.

## Strict Guidelines
- Engineers MUST declare explicit JSON capability files in `src-tauri/capabilities/` defining window and webview label mappings, strictly avoiding catch-all capabilities.
- Engineers MUST NOT grant global or wildcard plugin permissions (e.g., `fs:*`, `core:default`, or unconstrained `shell:*`) in mobile contexts.
- Filesystem and hardware access MUST be scoped to isolated sandboxes (e.g., scoping `fs:allow-read-text-file` strictly to `$APPDATA/*` or `$DOCUMENT/*` subpaths).
- Rust IPC command handlers MUST deserialize into typed structs deriving `serde::Deserialize` and validate parameter invariants before executing native Android/iOS system calls.
- Tauri configuration (`tauri.conf.json`) MUST enforce a strict Content Security Policy (CSP) and disable dangerous options like `dangerousRemoteUrlIPC`.

## Bad vs Good Implementations
### Granular Capability Definition vs. Over-Permissioned Catch-All

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Grants wildcard access to all windows across core, filesystem, and shell APIs. In a mobile environment, a compromised web asset or XSS vulnerability can leverage shell or unbounded fs permissions to compromise native OS data.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-capability",
  "description": "Capability for mobile app context",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:default",
    "shell:default"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Targets exclusively the 'main' window label and provides granular, scoped access to only the necessary filesystem path ($APPDATA/user_session/*) and explicit biometric authentication without exposing shell or unrestricted fs commands.
```json
{
  "$schema": "../gen/schemas/mobile-schema.json",
  "identifier": "mobile-secure-capability",
  "description": "Granular scoped capability for primary mobile webview",
  "windows": ["main"],
  "permissions": [
    "core:event:allow-listen",
    "core:event:allow-emit",
    {
      "identifier": "fs:allow-read-text-file",
      "allow": [{
        "path": "$APPDATA/user_session/*"
      }]
    },
    {
      "identifier": "biometric:authenticate",
      "allow": []
    }
  ]
}
```

### Strictly Validated IPC Invocation with Command Payload Enforcement

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Bypasses typed Rust command boundaries and directly attempts unvalidated path manipulation against raw native paths, vulnerable to path traversal and injection.
```typescript
import { invoke } from '@tauri-apps/api/core';

// Invoking unverified shell command or dynamic path execution
export async function writeUserExport(fileName: string, rawContent: string): Promise<void> {
  // Anti-pattern: Sending unsanitized path and payload directly across IPC
  await invoke('plugin:fs|write_file', {
    path: `/data/data/com.app/${fileName}`,
    contents: rawContent
  });
}
```

#### Production Standard (Correct)
> **Standard**: Invokes an application-specific, sandboxed Rust command with validated schema arguments rather than direct access to raw low-level filesystem plugins.
```typescript
import { invoke } from '@tauri-apps/api/core';

interface ExportPayload {
  readonly sessionToken: string;
  readonly exportData: Record<string, unknown>;
}

export async function writeUserExport(sessionToken: string, exportData: Record<string, unknown>): Promise<void> {
  if (!/^[a-zA-Z0-9_-]{32,64}$/.test(sessionToken)) {
    throw new Error('Invalid session token format');
  }
  
  await invoke<void>('save_secure_user_export', {
    payload: {
      sessionToken,
      exportData
    } satisfies ExportPayload
  });
}
```

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 Sandboxing and Granular Permission Policy

Tauri 2.0 Mobile IPC Capability Sandboxing and Granular Permission Policy defines an industrial-grade behavioral standard for mobile engineering. Enforces strict compile-time and runtime permission isolation across Tauri 2.0 mobile IPC boundaries. Prevents privilege escalation and arbitrary native code execution from compromised WebViews by mandating explicit capability file scoping, zero-trust remote URL policies, and fine-grained command parameter validation in Rust core. 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 Plugin Permissions and Unscoped IPC Invocations in 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 DriftWildcard Plugin Permissions and Unscoped IPC Invocations in 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 declare explicit JSON capability files in `src-tauri/capabilities/` defining window and webview label mappings, strictly avoiding catch-all capabilities.

Engineers MUST declare explicit JSON capability files in `src-tauri/capabilities/` defining window and webview label mappings, strictly avoiding catch-all 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.
2

Engineers MUST NOT grant global or wildcard plugin permissions (e.g., `fs

Engineers MUST NOT grant global or wildcard plugin permissions (e.g., `fs:*`, `core:default`, or unconstrained `shell:*`) in mobile contexts.

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

Filesystem and hardware access MUST be scoped to isolated sandboxes (e.g., scoping `fs

Filesystem and hardware access MUST be scoped to isolated sandboxes (e.g., scoping `fs:allow-read-text-file` strictly to `$APPDATA/*` or `$DOCUMENT/*` subpaths).

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

Rust IPC command handlers MUST deserialize into typed structs deriving `serde

Rust IPC command handlers MUST deserialize into typed structs deriving `serde::Deserialize` and validate parameter invariants before executing native Android/iOS system calls.

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

Tauri configuration (`tauri.conf.json`) MUST enforce a strict Content Security Policy (CSP) and disable dangerous options like `dangerousRemoteUrlIPC`.

Tauri configuration (`tauri.conf.json`) MUST enforce a strict Content Security Policy (CSP) and disable dangerous options like `dangerousRemoteUrlIPC`.

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 Sandboxing and Granular Permission Policy critical for AI coding assistants?

Enforces strict compile-time and runtime permission isolation across Tauri 2.0 mobile IPC boundaries. Prevents privilege escalation and arbitrary native code execution from compromised WebViews by mandating explicit capability file scoping, zero-trust remote URL policies, and fine-grained command parameter validation in Rust core. 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 Plugin Permissions and Unscoped IPC Invocations in 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