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

Tauri 2.0 Mobile IPC Capability-Scoped Permission Boundary

Enforces strict compile-time capability mapping and runtime context isolation for Tauri 2.0 mobile targets on iOS and Android. Preempts webview-based privilege escalation by disallowing wildcard plugin permissions, mandating granular ACL definitions, and strictly typing IPC command payloads across the JavaScript-Rust FFI bridge.

Prohibited Anti-Pattern: Wildcard Plugin Authorization and Untyped Global 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-Scoped Permission Boundary - Enforces strict compile-time capability mapping and runtime context isolation for Tauri 2.0 mobile targets on iOS and Android. Preempts webview-based privilege escalation by disallowing wildcard plugin permissions, mandating granular ACL definitions, and strictly typing IPC command payloads across the JavaScript-Rust FFI bridge.
globs: src-tauri/capabilities/**/*.json, src-tauri/capabilities/**/*.toml, 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/tauri2-mobile-ipc-capability-scoped-permissions"
---

# Tauri 2.0 Mobile IPC Capability-Scoped Permission Boundary

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Wildcard Plugin Authorization and Untyped Global IPC Invocations in Mobile Webviews

## System Constraints
You are a Principal Security Architect enforcing Tauri 2.0 mobile IPC boundary invariants. Tauri 2.0 replaces the legacy allowlist architecture with granular, multi-layered capability files and access control lists (ACLs). You must prevent mobile webview cross-origin compromises from escalating to native OS privileges (e.g., camera, filesystem, biometric authentication, notifications) by enforcing least-privilege capability configurations, strict mobile target definitions, and validated FFI schemas.

## Strict Guidelines
- Engineers MUST ALWAYS isolate mobile capabilities into dedicated capability definitions under `src-tauri/capabilities/` targeting explicit mobile platform identifiers (`android`, `ios`).
- Engineers MUST NEVER declare wildcard permissions (e.g., `fs:default`, `http:default`, `*`) in capability permission sets; every permission must use exact command-level ACL scopes.
- Engineers MUST configure mobile window labels explicitly in capability descriptors rather than relying on global window matches (`main` or custom labels with exact origin validation).
- Code MUST validate and deserialize all IPC command payloads on the Rust side using strictly typed Serde structs with runtime boundary validation, rejecting arbitrary JSON blobs.
- Components NEVER execute raw `@tauri-apps/api/core` `invoke` calls without importing statically typed command wrappers generated via or verified against Rust IPC signatures.

## Bad vs Good Implementations
### Tauri 2.0 Mobile Capability Definition: Wildcard Default vs Explicit Command Scope

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Declaring wildcard permissions (`*:default`) and wildcard windows (`*`) exposes high-privilege native filesystem and hardware APIs to any frame or URL navigated within the webview, creating a direct path for remote code execution or arbitrary data exfiltration.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-capability",
  "description": "Insecure permissive capability for mobile webview",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:default",
    "dialog:default",
    "barcode-scanner:default"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Explicitly restricts target platforms to mobile OSes, binds to only the trusted 'main' window, disallows unrestricted file system access, and grants access only to the exact command endpoints and scoped subpaths required.
```json
{
  "$schema": "../gen/schemas/mobile-schema.json",
  "identifier": "mobile-capability",
  "description": "Strictly scoped capability for authenticated mobile app window",
  "platforms": ["android", "iOS"],
  "windows": ["main"],
  "permissions": [
    "core:path:allow-app-data-dir",
    "barcode-scanner:allow-scan",
    "barcode-scanner:allow-cancel",
    {
      "identifier": "fs:allow-read-file",
      "allow": [{
        "path": "$APPDATA/cache/**"
      }]
    }
  ]
}
```

### Frontend IPC Boundary: Untyped Global Invoke vs Validated Wrapper

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Invoking IPC commands with dynamic plugin paths and `any` types circumvents capability type-checking, prevents static auditability, and allows malformed payload injection into native bridge endpoints.
```typescript
import { invoke } from '@tauri-apps/api/core';

// Bad: Untyped invocation with untrusted arbitrary payload
export async function saveMobileData(key: string, payload: any): Promise<any> {
  return await invoke('plugin:store|set', {
    key,
    value: payload,
  });
}
```

#### Production Standard (Correct)
> **Standard**: Enforces an immutable, strictly typed contract between the frontend view model and the Rust command handler matching defined capability permissions.
```typescript
import { invoke } from '@tauri-apps/api/core';

interface SecureCachePayload {
  readonly recordId: string;
  readonly serializedData: string;
  readonly timestampEpochMs: number;
}

interface WriteResult {
  readonly bytesWritten: number;
}

export async function writeSecureCacheRecord(
  payload: SecureCachePayload
): Promise<WriteResult> {
  return await invoke<WriteResult>('write_app_cache_record', {
    request: {
      recordId: payload.recordId,
      serializedData: payload.serializedData,
      timestampEpochMs: payload.timestampEpochMs,
    },
  });
}
```

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-Scoped Permission Boundary

Tauri 2.0 Mobile IPC Capability-Scoped Permission Boundary defines an industrial-grade behavioral standard for mobile engineering. Enforces strict compile-time capability mapping and runtime context isolation for Tauri 2.0 mobile targets on iOS and Android. Preempts webview-based privilege escalation by disallowing wildcard plugin permissions, mandating granular ACL definitions, and strictly typing IPC command payloads across the JavaScript-Rust FFI bridge. 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 Authorization and Untyped Global 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 Authorization and Untyped Global 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 ALWAYS isolate mobile capabilities into dedicated capability definitions under `src-tauri/capabilities/` targeting explicit mobile platform identifiers (`android`, `ios`).

Engineers MUST ALWAYS isolate mobile capabilities into dedicated capability definitions under `src-tauri/capabilities/` targeting explicit mobile platform identifiers (`android`, `ios`).

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

Engineers MUST NEVER declare wildcard permissions (e.g., `fs:default`, `http:default`, `*`) in capability permission sets; every permission must use exact command-level ACL scopes.

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 configure mobile window labels explicitly in capability descriptors rather than relying on global window matches (`main` or custom labels with exact origin validation).

Engineers MUST configure mobile window labels explicitly in capability descriptors rather than relying on global window matches (`main` or custom labels with exact 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.
4

Code MUST validate and deserialize all IPC command payloads on the Rust side using strictly typed Serde structs with runtime boundary validation, rejecting arbitrary JSON blobs.

Code MUST validate and deserialize all IPC command payloads on the Rust side using strictly typed Serde structs with runtime boundary validation, rejecting arbitrary JSON blobs.

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 execute raw `@tauri-apps/api/core` `invoke` calls without importing statically typed command wrappers generated via or verified against Rust IPC signatures.

Components NEVER execute raw `@tauri-apps/api/core` `invoke` calls without importing statically typed command wrappers generated via or verified against Rust IPC signatures.

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-Scoped Permission Boundary critical for AI coding assistants?

Enforces strict compile-time capability mapping and runtime context isolation for Tauri 2.0 mobile targets on iOS and Android. Preempts webview-based privilege escalation by disallowing wildcard plugin permissions, mandating granular ACL definitions, and strictly typing IPC command payloads across the JavaScript-Rust FFI bridge. 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 Authorization and Untyped Global 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