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

Tauri 2.0 Fine-Grained IPC Capabilities & Webview Sandboxing

Enforces explicit compile-time capability scoping and origin isolation for Tauri 2.0 mobile architectures. Disallows wildcard native plugin permissions and unpartitioned webview access across Android and iOS execution contexts. Mandates deterministic per-window permission sets to eliminate native privilege escalation vulnerabilities from compromised web contexts.

Prohibited Anti-Pattern: Permissive Wildcard Plugin Bindings and Global Webview Capabilities in Mobile Native IPC

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Fine-Grained IPC Capabilities & Webview Sandboxing - Enforces explicit compile-time capability scoping and origin isolation for Tauri 2.0 mobile architectures. Disallows wildcard native plugin permissions and unpartitioned webview access across Android and iOS execution contexts. Mandates deterministic per-window permission sets to eliminate native privilege escalation vulnerabilities from compromised web contexts.
globs: src-tauri/capabilities/**/*.json, src-tauri/tauri.conf.json, src/**/*.{ts,tsx}, src-tauri/src/**/*.rs
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tauri-v2-ipc-capability-sandboxing-production-standard"
---

# Tauri 2.0 Fine-Grained IPC Capabilities & Webview Sandboxing

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Permissive Wildcard Plugin Bindings and Global Webview Capabilities in Mobile Native IPC

## System Constraints
You are a Principal Software Architect enforcing Tauri 2.0 Fine-Grained IPC Capabilities and Origin Sandboxing on mobile runtimes (Android WebView and iOS WKWebView). You must reject any configuration granting unconstrained plugin access, broad directory traversal permissions, or shared IPC contexts between primary views and secondary webviews (such as OAuth or external WebViews). Require distinct capability files per window, explicit origin binding, and typed IPC wrappers that fail closed on privilege rejection.

## Strict Guidelines
- Engineers MUST ALWAYS isolate mobile capabilities into dedicated files under `src-tauri/capabilities/*.json` bound specifically to named windows or webviews.
- Engineers MUST NOT grant wildcard capabilities (`"core:default"`, `"fs:default"`, or unconstrained plugin sets) to secondary or remote-origin webviews.
- Engineers MUST configure explicit path scopes (`$APP_DATA/*`, `$APP_CACHE/*`) on filesystem and storage permissions, strictly prohibiting raw root or user-level directory access.
- Code MUST wrap `invoke` calls within type-safe frontend service boundaries that validate response schemas and handle permission-denied IPC errors gracefully without leaking raw native stack traces.
- Secondary webviews (e.g., OAuth authentication flows or external documentation) MUST be configured with empty capabilities (`capabilities: []`) or restricted exclusively to non-native core events.
- Services MUST enforce cryptographic origin verification when deep-linking or processing custom protocol schemes (`tauri://` or `app://`) on iOS and Android.

## Bad vs Good Implementations
### Tauri 2.0 Typed IPC Invocation with Granular Sandboxing and Scoped Capabilities

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Directly calling native plugin commands with hardcoded or unvalidated paths assumes ambient global capability grants. On Tauri 2.0 mobile, this fails when capabilities are properly locked down or, worse, leads to complete sandbox escape if wildcard permissions (e.g., `fs:default`) are mistakenly bundled into the release APK/IPA.
```typescript
// Anti-pattern: Untyped global IPC invoke vulnerable to permission escalation and unhandled mobile IPC drops
import { invoke } from '@tauri-apps/api/core';

export async function readSensitiveUserData(filename: string): Promise<string> {
  // Bad: Directly invoking dangerous native plugins assuming global filesystem access
  // Relies on ambient fs:* capabilities granted globally in tauri.conf.json
  return await invoke('plugin:fs|read_text_file', {
    path: `/data/user/0/com.app/${filename}`
  });
}
```

#### Production Standard (Correct)
> **Standard**: Validates inputs to prevent directory traversal prior to reaching the IPC bridge. Constrains operations to pre-scoped directories (`BaseDirectory.AppData`), matching explicit Tauri 2.0 capability definitions (`fs:allow-read-text-file` scoped to `$APPDATA/*`), and encapsulates IPC errors without exposing native platform details.
```typescript
// Production standard: Type-safe, sandboxed IPC bridge adhering to explicit Tauri 2.0 capability boundaries
import { invoke } from '@tauri-apps/api/core';
import { BaseDirectory } from '@tauri-apps/plugin-fs';

interface SafeFileReadRequest {
  readonly relativePath: string;
  readonly baseDir: BaseDirectory.AppData;
}

interface SafeFileReadResult {
  readonly success: boolean;
  readonly content?: string;
  readonly error?: string;
}

const PATH_TRAVERSAL_REGEX = /(?:\.\.[\/\\]|[\/\\]\.\.)/;

export async function readApplicationUserData(
  relativePath: string
): Promise<SafeFileReadResult> {
  // Invariant Guardrail: Prohibit path traversal before reaching IPC boundary
  if (PATH_TRAVERSAL_REGEX.test(relativePath) || relativePath.startsWith('/')) {
    return {
      success: false,
      error: 'SECURITY_VIOLATION: Insecure relative path parameter.'
    };
  }

  try {
    // Command mapped strictly to: "fs:allow-read-text-file" scoped to "$APPDATA/*"
    const content = await invoke<string>('plugin:fs|read_text_file', {
      path: relativePath,
      options: { baseDir: BaseDirectory.AppData }
    });

    return { success: true, content };
  } catch (err: unknown) {
    const message = err instanceof Error ? err.message : String(err);
    return {
      success: false,
      error: `IPC_SANDBOX_REJECT: Capability or access denied (${message})`
    };
  }
}
```

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 Fine-Grained IPC Capabilities & Webview Sandboxing

Tauri 2.0 Fine-Grained IPC Capabilities & Webview Sandboxing defines an industrial-grade behavioral standard for mobile engineering. Enforces explicit compile-time capability scoping and origin isolation for Tauri 2.0 mobile architectures. Disallows wildcard native plugin permissions and unpartitioned webview access across Android and iOS execution contexts. Mandates deterministic per-window permission sets to eliminate native privilege escalation vulnerabilities from compromised web contexts. 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: Permissive Wildcard Plugin Bindings and Global Webview Capabilities in Mobile Native IPC 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 DriftPermissive Wildcard Plugin Bindings and Global Webview Capabilities in Mobile Native IPCCritical
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 files under `src-tauri/capabilities/*.json` bound specifically to named windows or webviews.

Engineers MUST ALWAYS isolate mobile capabilities into dedicated files under `src-tauri/capabilities/*.json` bound specifically to named windows or 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.
2

Engineers MUST NOT grant wildcard capabilities (`"core

Engineers MUST NOT grant wildcard capabilities (`"core:default"`, `"fs:default"`, or unconstrained plugin sets) to secondary or remote-origin 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

Engineers MUST configure explicit path scopes (`$APP_DATA/*`, `$APP_CACHE/*`) on filesystem and storage permissions, strictly prohibiting raw root or user-level directory access.

Engineers MUST configure explicit path scopes (`$APP_DATA/*`, `$APP_CACHE/*`) on filesystem and storage permissions, strictly prohibiting raw root or user-level directory access.

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 wrap `invoke` calls within type-safe frontend service boundaries that validate response schemas and handle permission-denied IPC errors gracefully without leaking raw native stack traces.

Code MUST wrap `invoke` calls within type-safe frontend service boundaries that validate response schemas and handle permission-denied IPC errors gracefully without leaking raw native stack traces.

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

Secondary webviews (e.g., OAuth authentication flows or external documentation) MUST be configured with empty capabilities (`capabilities

Secondary webviews (e.g., OAuth authentication flows or external documentation) MUST be configured with empty capabilities (`capabilities: []`) or restricted exclusively to non-native core events.

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

Services MUST enforce cryptographic origin verification when deep-linking or processing custom protocol schemes (`tauri

Services MUST enforce cryptographic origin verification when deep-linking or processing custom protocol schemes (`tauri://` or `app://`) on iOS and 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.
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 Fine-Grained IPC Capabilities & Webview Sandboxing critical for AI coding assistants?

Enforces explicit compile-time capability scoping and origin isolation for Tauri 2.0 mobile architectures. Disallows wildcard native plugin permissions and unpartitioned webview access across Android and iOS execution contexts. Mandates deterministic per-window permission sets to eliminate native privilege escalation vulnerabilities from compromised web contexts. 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 (Permissive Wildcard Plugin Bindings and Global Webview Capabilities in Mobile Native IPC) 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