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

Tauri 2.0 Capability-Based IPC Sandboxing and Least Privilege Enforcement

Enforces strict capability-based access control (CBAC) for webview-to-core IPC bridges in Tauri 2.0 mobile applications. Eliminates privilege escalation across the native mobile boundary by prohibiting default wildcard permissions, requiring granular JSON/TOML capability files mapped directly to webview labels and mobile platform targets, and mandating input boundary sanitization before IPC dispatch.

Prohibited Anti-Pattern: Monolithic Capability Wildcarding and Unscoped IPC Bridge Invocation

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Capability-Based IPC Sandboxing and Least Privilege Enforcement - Enforces strict capability-based access control (CBAC) for webview-to-core IPC bridges in Tauri 2.0 mobile applications. Eliminates privilege escalation across the native mobile boundary by prohibiting default wildcard permissions, requiring granular JSON/TOML capability files mapped directly to webview labels and mobile platform targets, and mandating input boundary sanitization before IPC dispatch.
globs: src-tauri/capabilities/**/*.json, src-tauri/capabilities/**/*.toml, 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-capability-ipc-sandboxing-tauri-2-0-capabi-829"
---

# Tauri 2.0 Capability-Based IPC Sandboxing and Least Privilege Enforcement

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Monolithic Capability Wildcarding and Unscoped IPC Bridge Invocation

## System Constraints
You are a Principal Security Architect enforcing Tauri 2.0 Capability-Based IPC Sandboxing. In Tauri 2.0, permissions are non-hierarchical, opt-in, and governed by fine-grained capabilities. You must reject any configuration that uses broad or default allow-lists (such as core:default or plugin:*:allow-*) across mobile targets (iOS/Android). Enforce isolated context boundaries: webview windows must be explicitly named, mobile platforms must be segmented into scoped capability files, and IPC invocations from the frontend must type-check and validate payloads before reaching native commands. Ensure that native Rust commands evaluate command scopes and perform runtime validation beyond static capability checks.

## Strict Guidelines
- Engineers MUST ALWAYS isolate capabilities into modular target-specific capability files in `src-tauri/capabilities/` rather than placing all permissions in a single file.
- Engineers MUST NOT grant wildcard permissions (`*:*`, `core:default`, or unconstrained `plugin:fs:default`) to mobile webviews.
- Code MUST explicitly declare `windows` and `platforms` (e.g., `["android", "iOS"]`) in every capability declaration file.
- Frontend bridge calls MUST invoke typed wrappers generated via `@tauri-apps/api/core` with runtime schema validation (e.g., Zod) prior to invoking `invoke()`.
- Native Rust `#[tauri::command]` handlers MUST define and enforce argument limits using `tauri::ipc::CommandItem` or explicit capability scopes (`tauri::ipc::Scope`) for sensitive file, network, or biometric operations.

## Bad vs Good Implementations
### Configuring Granular Capabilities vs Monolithic Wildcards

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Assigns broad default bundles ('core:default', 'fs:default') to all windows ('*') indiscriminately, exposing unrestricted file system access and raw HTTP transport to any webview context without platform scoping or directory constraints.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-capability",
  "description": "Insecure default capability granting universal access",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:default",
    "http:default"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Explicitly targets the 'main' window on mobile platforms ('android', 'iOS') and limits the filesystem permission to read/write only within a sandboxed application data subdirectory using explicit path constraints.
```json
{
  "$schema": "../gen/schemas/mobile-schema.json",
  "identifier": "mobile-secure-storage-cap",
  "description": "Restricts secure file storage to the dedicated mobile webview on Android and iOS",
  "windows": ["main"],
  "platforms": ["android", "iOS"],
  "permissions": [
    {
      "identifier": "fs:allow-read-text-file",
      "allow": [{ "path": "$APPDATA/secure_store/*" }]
    },
    {
      "identifier": "fs:allow-write-text-file",
      "allow": [{ "path": "$APPDATA/secure_store/*" }]
    }
  ]
}
```

### Frontend Typed IPC Invocation with Runtime Validation

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Passes arbitrary unvalidated user input directly to the native bridge without runtime schema validation or compile-time payload guarantees, enabling injection and malformed command parameters.
```typescript
import { invoke } from '@tauri-apps/api/core';

export async function saveUserData(data: any): Promise<void> {
  // Anti-pattern: Untyped invoke passing unvalidated client payload directly to native bridge
  await invoke('save_user_data', { payload: data });
}
```

#### Production Standard (Correct)
> **Standard**: Validates the payload against a strict Zod schema before crossing the native IPC boundary, preventing malformed or malicious data from reaching the Rust backend.
```typescript
import { invoke } from '@tauri-apps/api/core';
import { z } from 'zod';

const UserDataSchema = z.object({
  userId: z.string().uuid(),
  encryptedPayload: z.string().base64(),
  timestamp: z.number().int().positive()
});

export type UserData = z.infer<typeof UserDataSchema>;

export async function saveUserData(rawInput: unknown): Promise<void> {
  const validated = UserDataSchema.parse(rawInput);
  await invoke<void>('save_user_data', { payload: validated });
}
```

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 Capability-Based IPC Sandboxing and Least Privilege Enforcement

Tauri 2.0 Capability-Based IPC Sandboxing and Least Privilege Enforcement defines an industrial-grade behavioral standard for mobile engineering. Enforces strict capability-based access control (CBAC) for webview-to-core IPC bridges in Tauri 2.0 mobile applications. Eliminates privilege escalation across the native mobile boundary by prohibiting default wildcard permissions, requiring granular JSON/TOML capability files mapped directly to webview labels and mobile platform targets, and mandating input boundary sanitization before IPC dispatch. 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: Monolithic Capability Wildcarding and Unscoped IPC Bridge Invocation 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 DriftMonolithic Capability Wildcarding and Unscoped IPC Bridge InvocationCritical
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 capabilities into modular target-specific capability files in `src-tauri/capabilities/` rather than placing all permissions in a single file.

Engineers MUST ALWAYS isolate capabilities into modular target-specific capability files in `src-tauri/capabilities/` rather than placing all permissions in a single 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.
2

Engineers MUST NOT grant wildcard permissions (`*

Engineers MUST NOT grant wildcard permissions (`*:*`, `core:default`, or unconstrained `plugin:fs:default`) to mobile 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 MUST explicitly declare `windows` and `platforms` (e.g., `["android", "iOS"]`) in every capability declaration file.

Code MUST explicitly declare `windows` and `platforms` (e.g., `["android", "iOS"]`) in every capability declaration 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

Frontend bridge calls MUST invoke typed wrappers generated via `@tauri-apps/api/core` with runtime schema validation (e.g., Zod) prior to invoking `invoke()`.

Frontend bridge calls MUST invoke typed wrappers generated via `@tauri-apps/api/core` with runtime schema validation (e.g., Zod) prior to invoking `invoke()`.

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

Native Rust `#[tauri

Native Rust `#[tauri::command]` handlers MUST define and enforce argument limits using `tauri::ipc::CommandItem` or explicit capability scopes (`tauri::ipc::Scope`) for sensitive file, network, or biometric operations.

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 Capability-Based IPC Sandboxing and Least Privilege Enforcement critical for AI coding assistants?

Enforces strict capability-based access control (CBAC) for webview-to-core IPC bridges in Tauri 2.0 mobile applications. Eliminates privilege escalation across the native mobile boundary by prohibiting default wildcard permissions, requiring granular JSON/TOML capability files mapped directly to webview labels and mobile platform targets, and mandating input boundary sanitization before IPC dispatch. 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 (Monolithic Capability Wildcarding and Unscoped IPC Bridge Invocation) 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