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

Tauri 2.0 Mobile IPC Isolation and Capabilities Permission Scoping

Enforces strict capability permission boundaries, payload validation, and secure IPC invoke scoping for Tauri v2 Android and iOS environments. Prevents arbitrary IPC command execution, excessive native privilege granting, and deserialization vulnerabilities across the mobile webview-native boundary.

Prohibited Anti-Pattern: Wildcard Permissions and Unsanitized Tauri v2 Mobile IPC Invocations

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Mobile IPC Isolation and Capabilities Permission Scoping - Enforces strict capability permission boundaries, payload validation, and secure IPC invoke scoping for Tauri v2 Android and iOS environments. Prevents arbitrary IPC command execution, excessive native privilege granting, and deserialization vulnerabilities across the mobile webview-native boundary.
globs: src-tauri/capabilities/**/*.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-permissions-guardrail"
---

# Tauri 2.0 Mobile IPC Isolation and Capabilities Permission Scoping

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Wildcard Permissions and Unsanitized Tauri v2 Mobile IPC Invocations

## System Constraints
You are a Principal Engineer enforcing Tauri 2.0 Mobile IPC & Permissions Scope. Mandate fine-grained capabilities configurations, input validation on native commands, and strict webview origin isolation for Android and iOS targets. Prevent broad wildcard plugin permissions and raw, unsanitized invoke calls.

## Strict Guidelines
- Engineers MUST ALWAYS isolate mobile capabilities into dedicated permission files targeting explicit mobile platforms using the 'platforms': ['android', 'iOS'] restriction in Tauri v2 capability JSONs.
- Engineers MUST NOT grant wildcard permissions (e.g., 'fs:default', 'core:default') in production mobile capability manifests, specifying only explicit granular command access.
- Code SHOULD validate and sanitize all command arguments on both the frontend TypeScript layer via runtime schemas (e.g., Zod) and the Rust backend via strongly typed serde deserializers before touching native mobile APIs.
- Services MUST handle mobile-specific native errors gracefully in Rust commands, mapping unhandled native exceptions to typed, serialized IPC errors without leaking native stack traces.
- Components NEVER invoke Tauri commands dynamically with raw string variables; command names MUST be typed string literals checked against an explicit IPC contract interface.

## Bad vs Good Implementations
### Tauri v2 Mobile Capabilities Manifest: Permissive vs. Least-Privilege Scoped

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Grants unrestricted filesystem and core defaults across all targets with wildcard windows, exposing sensitive Android and iOS app sandboxes to complete compromise upon webview injection.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-capability",
  "description": "Capability for mobile app",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:default",
    "fs:allow-read-write"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Restricts platform execution explicitly to Android/iOS, isolates to the 'main' webview window, and constrains file access strictly to the application data directory scope.
```json
{
  "$schema": "../gen/schemas/mobile-schema.json",
  "identifier": "mobile-capability",
  "description": "Granular capability for mobile app scoped to app sandbox",
  "platforms": ["android", "iOS"],
  "windows": ["main"],
  "permissions": [
    "core:path:default",
    "core:event:allow-listen",
    {
      "identifier": "fs:allow-read-text-file",
      "allow": [{ "path": "$APPDATA/**" }]
    }
  ]
}
```

### Frontend IPC Invocations: Untyped vs. Schema-Validated Mobile Invoke

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Omits payload validation and allows arbitrary unconstrained path strings to cross the mobile IPC boundary, leading to path traversal or native bridge panics.
```typescript
import { invoke } from '@tauri-apps/api/core';

export async function loadUserData(rawPath: string) {
  // Insecure: raw string dynamic invoke and unchecked arguments
  return await invoke('read_secure_file', { path: rawPath });
}
```

#### Production Standard (Correct)
> **Standard**: Validates input constraints upfront, prevents traversal patterns, and adheres to a strictly typed, immutable IPC bridge contract.
```typescript
import { invoke } from '@tauri-apps/api/core';
import { z } from 'zod';

const SafeFileQuerySchema = z.object({
  fileName: z.string().regex(/^[a-zA-Z0-9_-]+\.json$/),
});

type SafeFileQuery = z.infer<typeof SafeFileQuerySchema>;

export async function loadUserData(query: SafeFileQuery): Promise<Record<string, unknown>> {
  const validated = SafeFileQuerySchema.parse(query);
  return await invoke<Record<string, unknown>>('read_secure_file', {
    payload: validated
  });
}
```

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 Isolation and Capabilities Permission Scoping

Tauri 2.0 Mobile IPC Isolation and Capabilities Permission Scoping defines an industrial-grade behavioral standard for mobile engineering. Enforces strict capability permission boundaries, payload validation, and secure IPC invoke scoping for Tauri v2 Android and iOS environments. Prevents arbitrary IPC command execution, excessive native privilege granting, and deserialization vulnerabilities across the mobile webview-native boundary. 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 Permissions and Unsanitized Tauri v2 Mobile IPC Invocations 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 Permissions and Unsanitized Tauri v2 Mobile IPC InvocationsCritical
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 capabilities into dedicated permission files targeting explicit mobile platforms using the 'platforms'

Engineers MUST ALWAYS isolate mobile capabilities into dedicated permission files targeting explicit mobile platforms using the 'platforms': ['android', 'iOS'] restriction in Tauri v2 capability JSONs.

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 wildcard permissions (e.g., 'fs

Engineers MUST NOT grant wildcard permissions (e.g., 'fs:default', 'core:default') in production mobile capability manifests, specifying only explicit granular command access.

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 validate and sanitize all command arguments on both the frontend TypeScript layer via runtime schemas (e.g., Zod) and the Rust backend via strongly typed serde deserializers before touching native mobile APIs.

Code SHOULD validate and sanitize all command arguments on both the frontend TypeScript layer via runtime schemas (e.g., Zod) and the Rust backend via strongly typed serde deserializers before touching native mobile APIs.

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 handle mobile-specific native errors gracefully in Rust commands, mapping unhandled native exceptions to typed, serialized IPC errors without leaking native stack traces.

Services MUST handle mobile-specific native errors gracefully in Rust commands, mapping unhandled native exceptions to typed, serialized IPC errors without leaking native stack traces.

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 Tauri commands dynamically with raw string variables

Components NEVER invoke Tauri commands dynamically with raw string variables; command names MUST be typed string literals checked against an explicit IPC contract interface.

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 Isolation and Capabilities Permission Scoping critical for AI coding assistants?

Enforces strict capability permission boundaries, payload validation, and secure IPC invoke scoping for Tauri v2 Android and iOS environments. Prevents arbitrary IPC command execution, excessive native privilege granting, and deserialization vulnerabilities across the mobile webview-native boundary. 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 Permissions and Unsanitized Tauri v2 Mobile IPC Invocations) 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 →
mobile
106

Tauri 2.0 Mobile IPC & Capabilities Permissions Matrix Standard

Tauri v2 introduces a capability-driven permissions system replacing legacy v1 allowlists across iOS and Android runtimes. Failure to constrain IPC command handlers with typed schemas and explicit mobile capability definitions exposes native mobile OS surfaces to arbitrary code execution, permission leakage, and silent serialization failures. Production mobile deployments require strictly typed IPC boundary validation, granular capability scopes, and graceful permission degradation.

mobile
70

Capacitor 7 Native Bridge, Biometric Auth & Android 15 Lifecycle Production Standard

Capacitor 7 enforces strict bridge lifecycle contracts, asynchronous native plugin interop, and mandatory Android 15 edge-to-edge window inset handling. Storing sensitive authentication tokens in unencrypted web storage or failing to bind biometric authentication directly to hardware-backed Keystore or Secure Enclave mechanisms compromises app integrity and causes fatal crash or viewport occlusion issues on modern mobile operating systems.

mobile
111

Capacitor 7 Native Bridge Invariants, Hardware Keystore, and Android 15 Edge-to-Edge

Enforces strict lifecycle management for Capacitor 7 native bridges, hardware-backed Keystore/Secure Enclave token persistence, and Android 15 edge-to-edge layout constraints. Prevents memory leaks from uncleaned plugin listeners, token exposure in unencrypted WebStorage, and UI occlusions caused by mandatory window insets.

1 Rule in Stack

Tauri