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

Tauri 2.0 Mobile IPC Capability-Based Access Control and Bridge Isolation

Enforces strict capability-based access control (CBAC) manifests and deterministic command mapping between mobile webviews and the Tauri 2.0 Rust runtime on iOS and Android. Precludes arbitrary IPC command injection, overprivileged default permissions, and cross-webview bridge escalation by requiring granular capability boundaries, scoped remote origin controls, and typed runtime payload validation.

Prohibited Anti-Pattern: Overprivileged Default Capability Sets and Unscoped Invoke Handlers 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-Based Access Control and Bridge Isolation - Enforces strict capability-based access control (CBAC) manifests and deterministic command mapping between mobile webviews and the Tauri 2.0 Rust runtime on iOS and Android. Precludes arbitrary IPC command injection, overprivileged default permissions, and cross-webview bridge escalation by requiring granular capability boundaries, scoped remote origin controls, and typed runtime payload validation.
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/tauri2-mobile-ipc-capability-guardrails"
---

# Tauri 2.0 Mobile IPC Capability-Based Access Control and Bridge Isolation

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Overprivileged Default Capability Sets and Unscoped Invoke Handlers in Mobile Webviews

## System Constraints
You are a Principal Security Architect enforcing Tauri 2.0 Multi-Process IPC Capability-Based Access Control (CBAC) on iOS and Android. Mandate zero-trust native bridge configurations: every command invoke must bind to an explicit capability JSON manifest with minimal plugin permissions, window labels must be strictly partitioned, and no wildcard permissions ('*:*') are permitted. Detect and reject ambient or unvalidated invoke calls in frontend layers and untyped Tauri commands in the Rust layer.

## Strict Guidelines
- Engineers MUST ALWAYS isolate distinct mobile screens or webview contexts into separate capability files under `src-tauri/capabilities/` using explicit `windows` or `webviews` selectors.
- Engineers MUST NEVER configure wildcard permissions (e.g., `'core:default'`, `'fs:allow-*'`, or `'shell:*'`) in mobile capability manifests; permissions must declare explicit granular scopes (e.g., `'fs:allow-read-text-file'` with concrete target paths).
- Engineers MUST ALWAYS validate all IPC input parameters in the Rust command handler using strongly typed serde deserializers with runtime boundary checks before bridging to native mobile APIs.
- Frontend components MUST NEVER invoke untyped or raw string literals with `@tauri-apps/api/core::invoke`; invocations MUST route through strictly typed client abstraction layers.
- Plugins targeting native mobile features (Camera, Biometrics, Geolocation, Deep Links) MUST define platform-specific capability overrides using the `platforms: ['iOS', 'android']` constraint.
- Native mobile webview configurations MUST disable insecure remote protocols and disallow external remote origins from binding to core native bridge capabilities.

## Bad vs Good Implementations
### Tauri 2.0 Mobile Capability Manifest: Granular Scoping vs Overprivileged Defaults

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Granting '*' window access with broad default permission bundles ('core:default', 'fs:default', 'shell:default') allows any hijacked or injected webview frame to execute arbitrary native operations and filesystem writes across iOS and Android sandboxes.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-capability",
  "description": "Anti-pattern: Grants global access to all commands and plugins on mobile",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:default",
    "shell:default",
    "camera:allow-all"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Declares explicit window ownership ('main'), restricts execution to mobile targets ('iOS', 'android'), and whitelists only the exact granular permissions needed, preventing privilege escalation beyond the session cache directory.
```json
{
  "$schema": "../gen/schemas/mobile-schema.json",
  "identifier": "mobile-auth-capability",
  "description": "Enforces least privilege on mobile biometric and secure vault operations",
  "windows": ["main"],
  "platforms": ["iOS", "android"],
  "permissions": [
    "biometric:allow-authenticate",
    {
      "identifier": "fs:allow-read-text-file",
      "allow": [{
        "path": "$APPCACHE/session/*"
      }]
    }
  ]
}
```

### Frontend IPC Invocation: Typed Secure Bridge vs Ambient Invoke

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Passing arbitrary command names and untyped dynamic payloads directly to invoke() creates a dynamic bridge exploitation vector, allowing XSS or untrusted modules to probe and trigger hidden IPC commands.
```typescript
import { invoke } from '@tauri-apps/api/core';

// Anti-pattern: Untyped ambient command invocation with arbitrary parameters
export async function executeNativeAction(commandName: string, payload: unknown): Promise<unknown> {
  return await invoke(commandName, { data: payload });
}
```

#### Production Standard (Correct)
> **Standard**: Ensures the IPC bridge is protected with immutable type contracts, runtime pre-validation of parameters, and non-tamperable static command targets conforming to Tauri 2.0 plugin notation.
```typescript
import { invoke } from '@tauri-apps/api/core';

export interface AuthenticateRequest {
  readonly challenge: string;
  readonly timeoutMs: number;
}

export interface AuthenticateResponse {
  readonly signature: string;
  readonly authenticatedAt: number;
}

// Compliant: Strictly typed, closed-envelope wrapper for an allowed Tauri command
export async function requestBiometricAuth(
  params: AuthenticateRequest
): Promise<AuthenticateResponse> {
  if (!params.challenge || params.timeoutMs <= 0) {
    throw new Error('Invalid authentication parameters');
  }
  return await invoke<AuthenticateResponse>('plugin:biometric|authenticate', {
    payload: {
      challenge: params.challenge,
      timeoutMs: Math.min(params.timeoutMs, 30000)
    }
  });
}
```

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-Based Access Control and Bridge Isolation

Tauri 2.0 Mobile IPC Capability-Based Access Control and Bridge Isolation defines an industrial-grade behavioral standard for mobile engineering. Enforces strict capability-based access control (CBAC) manifests and deterministic command mapping between mobile webviews and the Tauri 2.0 Rust runtime on iOS and Android. Precludes arbitrary IPC command injection, overprivileged default permissions, and cross-webview bridge escalation by requiring granular capability boundaries, scoped remote origin controls, and typed runtime payload validation. 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: Overprivileged Default Capability Sets and Unscoped Invoke Handlers 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 DriftOverprivileged Default Capability Sets and Unscoped Invoke Handlers 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 distinct mobile screens or webview contexts into separate capability files under `src-tauri/capabilities/` using explicit `windows` or `webviews` selectors.

Engineers MUST ALWAYS isolate distinct mobile screens or webview contexts into separate capability files under `src-tauri/capabilities/` using explicit `windows` or `webviews` selectors.

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

Engineers MUST NEVER configure wildcard permissions (e.g., `'core:default'`, `'fs:allow-*'`, or `'shell:*'`) in mobile capability manifests; permissions must declare explicit granular scopes (e.g., `'fs:allow-read-text-file'` with concrete target paths).

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 validate all IPC input parameters in the Rust command handler using strongly typed serde deserializers with runtime boundary checks before bridging to native mobile APIs.

Engineers MUST ALWAYS validate all IPC input parameters in the Rust command handler using strongly typed serde deserializers with runtime boundary checks before bridging to 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

Frontend components MUST NEVER invoke untyped or raw string literals with `@tauri-apps/api/core

Frontend components MUST NEVER invoke untyped or raw string literals with `@tauri-apps/api/core::invoke`; invocations MUST route through strictly typed client abstraction layers.

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

Plugins targeting native mobile features (Camera, Biometrics, Geolocation, Deep Links) MUST define platform-specific capability overrides using the `platforms

Plugins targeting native mobile features (Camera, Biometrics, Geolocation, Deep Links) MUST define platform-specific capability overrides using the `platforms: ['iOS', 'android']` constraint.

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

Native mobile webview configurations MUST disable insecure remote protocols and disallow external remote origins from binding to core native bridge capabilities.

Native mobile webview configurations MUST disable insecure remote protocols and disallow external remote origins from binding to core native bridge 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.
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-Based Access Control and Bridge Isolation critical for AI coding assistants?

Enforces strict capability-based access control (CBAC) manifests and deterministic command mapping between mobile webviews and the Tauri 2.0 Rust runtime on iOS and Android. Precludes arbitrary IPC command injection, overprivileged default permissions, and cross-webview bridge escalation by requiring granular capability boundaries, scoped remote origin controls, and typed runtime payload validation. 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 (Overprivileged Default Capability Sets and Unscoped Invoke Handlers 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