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-acl-enforcement

Tauri 2.0 Mobile Rust IPC Capability ACL Enforcement

Restricts webview-to-native IPC bridge traffic strictly to cryptographically verified Rust command capabilities on iOS and Android platforms. Enforces explicit Capability Access Control Lists (ACLs) per mobile target, preventing unauthorized native code execution via the webview boundary.

Prohibited Anti-Pattern: Unconstrained Webview IPC Invocations Bypassing Mobile ACL Capabilities

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Mobile Rust IPC Capability ACL Enforcement - Restricts webview-to-native IPC bridge traffic strictly to cryptographically verified Rust command capabilities on iOS and Android platforms. Enforces explicit Capability Access Control Lists (ACLs) per mobile target, preventing unauthorized native code execution via the webview 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-capability-acl-enforcement"
---

# Tauri 2.0 Mobile Rust IPC Capability ACL Enforcement

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Unconstrained Webview IPC Invocations Bypassing Mobile ACL Capabilities

## System Constraints
You are a Principal Security Architect and Mobile Systems Engineer enforcing Tauri 2.0 Mobile Rust IPC Capability ACL Enforcement. In Tauri 2.0, all native IPC commands invoked across the JavaScript-to-Rust bridge on iOS and Android must be constrained by strictly scoped capability definitions in `src-tauri/capabilities/*.json`. Mandate that engineers define explicit permissions, bind commands to target platform identifiers, avoid global wildcard permissions, and guarantee runtime payload schema validation before bridge traversal.

## Strict Guidelines
- Engineers MUST ALWAYS isolate mobile capabilities into dedicated capability manifests (e.g., `src-tauri/capabilities/mobile.json`) explicitly targeting platforms: ["iOS", "android"].
- Engineers MUST NOT configure blanket wildcards (such as `core:default` or `allow-all`) in capability permission sets intended for mobile distribution.
- Engineers MUST ALWAYS bind each `#[tauri::command]` to an explicit ACL permission set defined in the capability configuration file.
- Services MUST route all frontend IPC calls through strictly typed, branded invoke wrappers that validate command arguments with runtime schema validators (such as Zod or Valibot) prior to IPC dispatch.
- Components NEVER execute raw `@tauri-apps/api/core::invoke` calls directly in UI rendering lifecycles without routing through audited bridge service layers.

## Bad vs Good Implementations
### Insecure Unconstrained IPC vs. Strict ACL-Bound Mobile Command Architecture

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Directly invokes an unvalidated native command string without runtime argument schemas. If mobile capabilities are not explicitly declared and isolated from desktop environments, malicious scripts or XSS vectors in the webview gain full access to native mobile JNI or Obj-C/Swift bridge functionality.
```typescript
import { invoke } from '@tauri-apps/api/core';

// ANTI-PATTERN: Direct, untyped invocation without capability scoping
// Allows unvalidated payload injection directly to native mobile runtime
export async function writeSensitiveDeviceRecord(recordId: string, payload: any): Promise<void> {
  await invoke('save_device_record', {
    id: recordId,
    data: payload
  });
}
```

#### Production Standard (Correct)
> **Standard**: Validates the command payload with Zod before bridge dispatch and uses explicit namespaced command identifiers that correspond directly to permissions verified in the mobile capability manifest, preventing unauthorized device bridge access.
```typescript
import { invoke } from '@tauri-apps/api/core';
import { z } from 'zod';

// INVARIANT: Strict runtime validation schema aligned with mobile Rust command permissions
const DeviceRecordSchema = z.object({
  recordId: z.string().uuid(),
  payload: z.record(z.string(), z.string().max(1024))
});

export type DeviceRecordInput = z.infer<typeof DeviceRecordSchema>;

interface IpcCommandResult<T> {
  success: boolean;
  data?: T;
  error?: string;
}

/**
 * Invokes 'plugin:mobile-secure-storage|save_device_record' strictly constrained
 * by ACL in `src-tauri/capabilities/mobile.json` targeting iOS and Android.
 */
export async function writeSensitiveDeviceRecord(
  input: DeviceRecordInput
): Promise<IpcCommandResult<void>> {
  const parseResult = DeviceRecordSchema.safeParse(input);
  if (!parseResult.success) {
    return {
      success: false,
      error: `IPC Schema Validation Failed: ${parseResult.error.message}`
    };
  }

  try {
    await invoke<void>('plugin:mobile-secure-storage|save_device_record', {
      recordId: parseResult.data.recordId,
      payload: parseResult.data.payload
    });
    return { success: true };
  } catch (bridgeError) {
    // Native capability denial or IPC bridge transport failure
    return {
      success: false,
      error: bridgeError instanceof Error ? bridgeError.message : 'IPC Execution Denied'
    };
  }
}
```

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 Rust IPC Capability ACL Enforcement

Tauri 2.0 Mobile Rust IPC Capability ACL Enforcement defines an industrial-grade behavioral standard for mobile engineering. Restricts webview-to-native IPC bridge traffic strictly to cryptographically verified Rust command capabilities on iOS and Android platforms. Enforces explicit Capability Access Control Lists (ACLs) per mobile target, preventing unauthorized native code execution via the webview 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: Unconstrained Webview IPC Invocations Bypassing Mobile ACL Capabilities 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 DriftUnconstrained Webview IPC Invocations Bypassing Mobile ACL CapabilitiesCritical
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 manifests (e.g., `src-tauri/capabilities/mobile.json`) explicitly targeting platforms

Engineers MUST ALWAYS isolate mobile capabilities into dedicated capability manifests (e.g., `src-tauri/capabilities/mobile.json`) explicitly targeting platforms: ["iOS", "android"].

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 configure blanket wildcards (such as `core

Engineers MUST NOT configure blanket wildcards (such as `core:default` or `allow-all`) in capability permission sets intended for mobile distribution.

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 bind each `#[tauri

Engineers MUST ALWAYS bind each `#[tauri::command]` to an explicit ACL permission set defined in the capability configuration file.

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 route all frontend IPC calls through strictly typed, branded invoke wrappers that validate command arguments with runtime schema validators (such as Zod or Valibot) prior to IPC dispatch.

Services MUST route all frontend IPC calls through strictly typed, branded invoke wrappers that validate command arguments with runtime schema validators (such as Zod or Valibot) prior to IPC dispatch.

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

Components NEVER execute raw `@tauri-apps/api/core::invoke` calls directly in UI rendering lifecycles without routing through audited bridge service 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.
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 Rust IPC Capability ACL Enforcement critical for AI coding assistants?

Restricts webview-to-native IPC bridge traffic strictly to cryptographically verified Rust command capabilities on iOS and Android platforms. Enforces explicit Capability Access Control Lists (ACLs) per mobile target, preventing unauthorized native code execution via the webview 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 (Unconstrained Webview IPC Invocations Bypassing Mobile ACL Capabilities) 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