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

Tauri 2.0 Mobile IPC Capability Manifest and Webview Isolation Standard

Enforces strict principle-of-least-privilege IPC command invocation boundaries within Tauri 2.0 mobile architectures. Requires deterministic capability JSON files binding discrete permissions exclusively to designated webview labels, preventing arbitrary invoke access and lateral privilege escalation from compromised webviews to native mobile subsystems.

Prohibited Anti-Pattern: Global Default-Allow Capabilities and Unscoped Webview IPC Command Invocations

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Mobile IPC Capability Manifest and Webview Isolation Standard - Enforces strict principle-of-least-privilege IPC command invocation boundaries within Tauri 2.0 mobile architectures. Requires deterministic capability JSON files binding discrete permissions exclusively to designated webview labels, preventing arbitrary invoke access and lateral privilege escalation from compromised webviews to native mobile subsystems.
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-ipc-capability-scoping-manifest"
---

# Tauri 2.0 Mobile IPC Capability Manifest and Webview Isolation Standard

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Global Default-Allow Capabilities and Unscoped Webview IPC Command Invocations

## System Constraints
You are a Principal Security Architect enforcing Tauri 2.0 IPC Capability Scoping. Mandate strict permission mapping, granular capability JSON isolation, and zero-trust webview-to-native IPC boundaries for all mobile targets.

## Strict Guidelines
- Engineers MUST ALWAYS isolate native capabilities into explicit JSON manifests under `src-tauri/capabilities/` specifying targeted webview window labels instead of using global wildcards (`*`).
- Engineers MUST NOT grant unrestricted plugin scopes (such as `fs:default`, `shell:default`, or unconstrained custom commands) to multi-context or authentication webviews.
- Code SHOULD validate and strongly type the payload schema on both the client TypeScript invoker and the Rust command handler using serde deserialization guards.
- Services MUST split privileged mobile hardware APIs (camera, biometrics, secure storage) into dedicated isolated capabilities applied strictly to the authenticated `main` webview.
- Components NEVER execute raw dynamic command strings via untyped Tauri `invoke` without statically verified command bindings in the capability manifest.

## Bad vs Good Implementations
### Unscoped Wildcard Capability vs. Granular Window-Scoped Manifest

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Using wildcard windows ('*') and broad permission sets (e.g., 'fs:default', 'shell:allow-execute') exposes critical native mobile primitives to any present or future webview, enabling lateral command execution if an untrusted asset or secondary webview is compromised.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-all-access",
  "description": "Anti-pattern: Grants full native execution rights to every webview window",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:default",
    "shell:allow-execute",
    "biometric:default"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Restricts critical permissions exclusively to the designated 'main' webview window, replaces wildcard execution with minimal requisite permissions, and strictly constraints filesystem access to the sandboxed application directory.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "main-mobile-capability",
  "description": "Production: Scoped strictly to the primary webview with granular command-level access",
  "windows": ["main"],
  "permissions": [
    "core:event:allow-listen",
    "core:event:allow-emit",
    "biometric:allow-authenticate",
    {
      "identifier": "core:path:allow-resolve-directory",
      "allow": [{ "path": "$APPDATA" }]
    }
  ]
}
```

### Client-Side Type-Safe IPC Invocation Pattern

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Untyped invoke calls lack schema verification, permit dangerous 'any' payloads across the serialization bridge, and do not enforce contextual window origin checks.
```typescript
import { invoke } from '@tauri-apps/api/core';

// Anti-pattern: Untyped invoke vulnerable to silent schema failure and unauthorized IPC
export async function authenticateUser(payload: any): Promise<any> {
  return await invoke('authenticate_user', { payload });
}
```

#### Production Standard (Correct)
> **Standard**: Validates the calling webview context at runtime, enforces strict immutability and compile-time typing on the payload and return types, ensuring conformity with the capability manifest.
```typescript
import { invoke } from '@tauri-apps/api/core';
import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow';

interface AuthPayload {
  readonly challenge: string;
  readonly timeoutMs: number;
}

interface AuthResponse {
  readonly token: string;
  readonly expiresAt: number;
}

export async function authenticateUser(payload: AuthPayload): Promise<AuthResponse> {
  const currentWindow = getCurrentWebviewWindow();
  if (currentWindow.label !== 'main') {
    throw new Error(`Unauthorized invocation context: ${currentWindow.label}`);
  }
  return await invoke<AuthResponse>('authenticate_user', { payload });
}
```

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 Manifest and Webview Isolation Standard

Tauri 2.0 Mobile IPC Capability Manifest and Webview Isolation Standard defines an industrial-grade behavioral standard for mobile engineering. Enforces strict principle-of-least-privilege IPC command invocation boundaries within Tauri 2.0 mobile architectures. Requires deterministic capability JSON files binding discrete permissions exclusively to designated webview labels, preventing arbitrary invoke access and lateral privilege escalation from compromised webviews to native mobile subsystems. 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: Global Default-Allow Capabilities and Unscoped Webview IPC Command 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 DriftGlobal Default-Allow Capabilities and Unscoped Webview IPC Command 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 native capabilities into explicit JSON manifests under `src-tauri/capabilities/` specifying targeted webview window labels instead of using global wildcards (`*`).

Engineers MUST ALWAYS isolate native capabilities into explicit JSON manifests under `src-tauri/capabilities/` specifying targeted webview window labels instead of using global wildcards (`*`).

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 unrestricted plugin scopes (such as `fs

Engineers MUST NOT grant unrestricted plugin scopes (such as `fs:default`, `shell:default`, or unconstrained custom commands) to multi-context or authentication webviews.

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 strongly type the payload schema on both the client TypeScript invoker and the Rust command handler using serde deserialization guards.

Code SHOULD validate and strongly type the payload schema on both the client TypeScript invoker and the Rust command handler using serde deserialization guards.

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 split privileged mobile hardware APIs (camera, biometrics, secure storage) into dedicated isolated capabilities applied strictly to the authenticated `main` webview.

Services MUST split privileged mobile hardware APIs (camera, biometrics, secure storage) into dedicated isolated capabilities applied strictly to the authenticated `main` webview.

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 dynamic command strings via untyped Tauri `invoke` without statically verified command bindings in the capability manifest.

Components NEVER execute raw dynamic command strings via untyped Tauri `invoke` without statically verified command bindings in the capability manifest.

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 Manifest and Webview Isolation Standard critical for AI coding assistants?

Enforces strict principle-of-least-privilege IPC command invocation boundaries within Tauri 2.0 mobile architectures. Requires deterministic capability JSON files binding discrete permissions exclusively to designated webview labels, preventing arbitrary invoke access and lateral privilege escalation from compromised webviews to native mobile subsystems. 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 (Global Default-Allow Capabilities and Unscoped Webview IPC Command 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 →
1 Rule in Stack

Tauri