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

Tauri 2.0 Mobile IPC Granular Capability Scoping & Origin Enforcement

Enforces strict principle-of-least-privilege capability manifests and cryptographically isolated IPC permissions for Tauri 2.0 on iOS and Android. Disallows default wildcard plugin bindings and unauthenticated webview context invocations to eliminate arbitrary native mobile bridge execution and privilege escalation vectors.

Prohibited Anti-Pattern: Wildcard Plugin Capabilities and Unvalidated IPC Bridges in Embedded Web Contexts

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Mobile IPC Granular Capability Scoping & Origin Enforcement - Enforces strict principle-of-least-privilege capability manifests and cryptographically isolated IPC permissions for Tauri 2.0 on iOS and Android. Disallows default wildcard plugin bindings and unauthenticated webview context invocations to eliminate arbitrary native mobile bridge execution and privilege escalation vectors.
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-granular-capability-scoping"
---

# Tauri 2.0 Mobile IPC Granular Capability Scoping & Origin Enforcement

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Wildcard Plugin Capabilities and Unvalidated IPC Bridges in Embedded Web Contexts

## System Constraints
You are a Principal Engineer and Security Architect enforcing Tauri 2.0 Mobile IPC Granular Capability Scoping. Mandate strict capability ACL definitions, origin-bound permission sets, and zero-trust IPC command verification across both Rust core and client webview invocations. Prohibit wildcard permissions ('*'), unauthenticated window contexts, and missing permission identifiers.

## Strict Guidelines
- Engineers MUST ALWAYS isolate native plugin privileges into individual, granular capability files within `src-tauri/capabilities/` scoped exclusively to explicit window labels.
- Engineers MUST NOT use wildcard permissions (`*:*` or `plugin-name:*`) in any capability file or configuration.
- Engineers MUST ALWAYS configure cryptographic origin checks or strict local-scheme validation (`tauri://localhost` or configured custom mobile protocol) for all IPC entry points.
- Engineers MUST explicitly list allowable commands in the `permissions` array instead of granting full plugin scopes (e.g., use `fs:allow-read-text-file` instead of `fs:default`).
- Services MUST validate IPC arguments in Rust command handlers using typed deserialization and custom validation before delegating to mobile OS APIs (JNI/Obj-C).
- Components NEVER execute raw native shell, un-sandboxed filesystem, or device-level APIs directly from embedded external or unverified sub-frames.

## Bad vs Good Implementations
### Granular Capability Manifest (src-tauri/capabilities/mobile.json)

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Grants blanket access to all windows ('*') and bundles unbounded plugin scopes ('dialog:*', 'fs:default'), allowing compromised webviews or loaded iframes to invoke destructive arbitrary native APIs.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-capability",
  "description": "Insecure default capability for mobile",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:default",
    "dialog:*",
    "biometric:*"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Restricts invocation rights specifically to the 'main' window on target mobile platforms and limits plugin commands to precise actions with key-scoped access policies.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-auth-capability",
  "description": "Scoped native biometric and secure store access for primary mobile webview",
  "windows": ["main"],
  "platforms": ["iOS", "android"],
  "permissions": [
    "core:app:allow-name",
    "biometric:allow-authenticate",
    {
      "identifier": "store:allow-get",
      "allow": [{ "key": "session_token" }]
    },
    {
      "identifier": "store:allow-set",
      "allow": [{ "key": "session_token" }]
    }
  ]
}
```

### Front-End IPC Invocation with Typed Validation

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Executes untyped invocations against dynamically constructed plugin commands without pre-flight validation or contract guarantees, exposing the bridge to injection attacks.
```typescript
import { invoke } from '@tauri-apps/api/core';

// Bad: Untyped and invoking un-scoped/wildcard native commands
export async function unlockDevice(payload: any): Promise<void> {
  await invoke('plugin:biometric|authenticate', payload);
}
```

#### Production Standard (Correct)
> **Standard**: Applies strictly typed contracts and runtime validation prior to dispatching commands through the capability-checked Tauri IPC bridge.
```typescript
import { invoke } from '@tauri-apps/api/core';

interface BiometricAuthOptions {
  readonly reason: string;
  readonly cancelTitle: string;
}

interface AuthResult {
  readonly success: boolean;
}

export async function requestBiometricAuth(
  options: BiometricAuthOptions
): Promise<AuthResult> {
  if (!options.reason || options.reason.trim().length === 0) {
    throw new Error('Biometric authentication reason must not be empty');
  }

  return await invoke<AuthResult>('plugin:biometric|authenticate', {
    payload: {
      reason: options.reason,
      cancelTitle: options.cancelTitle
    }
  });
}
```

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 Granular Capability Scoping & Origin Enforcement

Tauri 2.0 Mobile IPC Granular Capability Scoping & Origin Enforcement defines an industrial-grade behavioral standard for mobile engineering. Enforces strict principle-of-least-privilege capability manifests and cryptographically isolated IPC permissions for Tauri 2.0 on iOS and Android. Disallows default wildcard plugin bindings and unauthenticated webview context invocations to eliminate arbitrary native mobile bridge execution and privilege escalation vectors. 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 Capabilities and Unvalidated IPC Bridges in Embedded Web Contexts 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 Capabilities and Unvalidated IPC Bridges in Embedded Web ContextsCritical
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 native plugin privileges into individual, granular capability files within `src-tauri/capabilities/` scoped exclusively to explicit window labels.

Engineers MUST ALWAYS isolate native plugin privileges into individual, granular capability files within `src-tauri/capabilities/` scoped exclusively to explicit window labels.

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 use wildcard permissions (`*

Engineers MUST NOT use wildcard permissions (`*:*` or `plugin-name:*`) in any capability file or configuration.

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 configure cryptographic origin checks or strict local-scheme validation (`tauri

Engineers MUST ALWAYS configure cryptographic origin checks or strict local-scheme validation (`tauri://localhost` or configured custom mobile protocol) for all IPC entry points.

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

Engineers MUST explicitly list allowable commands in the `permissions` array instead of granting full plugin scopes (e.g., use `fs

Engineers MUST explicitly list allowable commands in the `permissions` array instead of granting full plugin scopes (e.g., use `fs:allow-read-text-file` instead of `fs:default`).

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

Services MUST validate IPC arguments in Rust command handlers using typed deserialization and custom validation before delegating to mobile OS APIs (JNI/Obj-C).

Services MUST validate IPC arguments in Rust command handlers using typed deserialization and custom validation before delegating to mobile OS APIs (JNI/Obj-C).

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

Components NEVER execute raw native shell, un-sandboxed filesystem, or device-level APIs directly from embedded external or unverified sub-frames.

Components NEVER execute raw native shell, un-sandboxed filesystem, or device-level APIs directly from embedded external or unverified sub-frames.

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 Granular Capability Scoping & Origin Enforcement critical for AI coding assistants?

Enforces strict principle-of-least-privilege capability manifests and cryptographically isolated IPC permissions for Tauri 2.0 on iOS and Android. Disallows default wildcard plugin bindings and unauthenticated webview context invocations to eliminate arbitrary native mobile bridge execution and privilege escalation vectors. 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 Capabilities and Unvalidated IPC Bridges in Embedded Web Contexts) 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