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 Capability-Based IPC Permission Sandboxing & Payload Boundary Enforcement

Enforces granular, capability-driven IPC permission boundaries and strict payload schema validation across Tauri 2.0 mobile webview-native interfaces. Prevents privilege escalation and arbitrary command execution by isolating window identifiers, validating runtime payloads with Zod before bridge serialization, and eliminating broad plugin access scopes.

Prohibited Anti-Pattern: Monolithic Wildcard Permission Grants and Unvalidated Runtime IPC Command Invocations

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Capability-Based IPC Permission Sandboxing & Payload Boundary Enforcement - Enforces granular, capability-driven IPC permission boundaries and strict payload schema validation across Tauri 2.0 mobile webview-native interfaces. Prevents privilege escalation and arbitrary command execution by isolating window identifiers, validating runtime payloads with Zod before bridge serialization, and eliminating broad plugin access scopes.
globs: src/**/*.{ts,tsx}, src-tauri/capabilities/**/*.json, src-tauri/tauri.conf.json, src-tauri/src/**/*.rs
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tauri-v2-capability-ipc-sandboxing"
---

# Tauri 2.0 Capability-Based IPC Permission Sandboxing & Payload Boundary Enforcement

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Monolithic Wildcard Permission Grants and Unvalidated Runtime IPC Command Invocations

## System Constraints
You are a Principal Engineer enforcing Tauri 2.0 Capability-Based IPC Permission Sandboxing. Mandate explicit window-to-capability mappings, eliminate wildcard permissions in capability manifests, require strict runtime contract validation via Zod prior to invoking `@tauri-apps/api/core.invoke`, and enforce granular command-level access control on both iOS and Android targets.

## Strict Guidelines
- Engineers MUST ALWAYS isolate mobile webview instances using explicit capability files (e.g., `src-tauri/capabilities/mobile.json`) targeting exact window labels rather than assigning default capabilities.
- Engineers MUST NOT configure wildcard permissions (e.g., `"permissions": ["core:default", "fs:*"]`) or allow broad command scopes that grant arbitrary file system or shell execution access to mobile surfaces.
- Code SHOULD validate all IPC payloads at the TypeScript boundary using deterministic parsing schemas (e.g., Zod) before executing `@tauri-apps/api/core.invoke` to prevent malformed or malicious argument serialization.
- Services MUST implement corresponding Rust-side command handlers with explicit argument typing, returning standardized Result<T, E> types rather than unwrapping or passing raw untyped JSON values.
- Components NEVER invoke raw, dynamically generated command names; all command strings must be strongly typed nominal string literals managed in a centralized IPC client registry.

## Bad vs Good Implementations
### Unsafe Dynamic IPC Call with Wildcard Permissions vs. Schema-Enforced Typed Boundary

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Directly concatenating command names and passing unvalidated external arguments across the bridge allows command injection, path traversal, and exploits over-permissive wildcard plugin capabilities.
```typescript
import { invoke } from '@tauri-apps/api/core';

// ANTI-PATTERN: Dynamic invocation with unvalidated inputs and generic plugin bypass
export async function executeUserFileAction(action: string, filePath: string, payload: unknown) {
  return await invoke('plugin:fs|' + action, {
    path: filePath,
    data: payload
  });
}
```

#### Production Standard (Correct)
> **Standard**: Validates IPC payloads against a strict schema preventing path traversal, disallows dynamic command resolution, and invokes an explicitly registered, sandboxed Rust command.
```typescript
import { invoke } from '@tauri-apps/api/core';
import { z } from 'zod';

const SafeFileWriteSchema = z.object({
  filename: z.string().regex(/^[a-zA-Z0-9_-]+\.json$/),
  content: z.record(z.unknown())
});

type SafeFileWriteInput = z.infer<typeof SafeFileWriteSchema>;

export async function writeMobileReport(input: SafeFileWriteInput): Promise<{ success: boolean }> {
  const validated = SafeFileWriteSchema.parse(input);
  return await invoke<{ success: boolean }>('write_scoped_report', {
    payload: {
      filename: validated.filename,
      content: JSON.stringify(validated.content)
    }
  });
}
```

### Insecure Broad Capability Manifest vs. Granular Window-Scoped Capability Manifest

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Grants global wildcard file read/write permissions to every window ('*'), bypassing Tauri 2.0's capability sandbox and exposing the native mobile sandbox to remote webview compromise.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-capability",
  "description": "Insecure full access capability",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:default",
    "fs:allow-read-all",
    "fs:allow-write-all"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Restricts capability permissions exclusively to the 'main' window and sandboxes file access strictly within the application data reports subdirectory.
```json
{
  "$schema": "../gen/schemas/mobile-schema.json",
  "identifier": "mobile-report-capability",
  "description": "Sandboxed capability for mobile telemetry reporting window",
  "windows": ["main"],
  "permissions": [
    "core:default",
    {
      "identifier": "fs:allow-write-text-file",
      "allow": [{
        "path": "$APPDATA/reports/*"
      }]
    }
  ]
}
```

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 Permission Sandboxing & Payload Boundary Enforcement

Tauri 2.0 Capability-Based IPC Permission Sandboxing & Payload Boundary Enforcement defines an industrial-grade behavioral standard for mobile engineering. Enforces granular, capability-driven IPC permission boundaries and strict payload schema validation across Tauri 2.0 mobile webview-native interfaces. Prevents privilege escalation and arbitrary command execution by isolating window identifiers, validating runtime payloads with Zod before bridge serialization, and eliminating broad plugin access scopes. 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 Wildcard Permission Grants and Unvalidated Runtime 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 DriftMonolithic Wildcard Permission Grants and Unvalidated Runtime 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 mobile webview instances using explicit capability files (e.g., `src-tauri/capabilities/mobile.json`) targeting exact window labels rather than assigning default capabilities.

Engineers MUST ALWAYS isolate mobile webview instances using explicit capability files (e.g., `src-tauri/capabilities/mobile.json`) targeting exact window labels rather than assigning default capabilities.

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 wildcard permissions (e.g., `"permissions"

Engineers MUST NOT configure wildcard permissions (e.g., `"permissions": ["core:default", "fs:*"]`) or allow broad command scopes that grant arbitrary file system or shell execution access to mobile surfaces.

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 all IPC payloads at the TypeScript boundary using deterministic parsing schemas (e.g., Zod) before executing `@tauri-apps/api/core.invoke` to prevent malformed or malicious argument serialization.

Code SHOULD validate all IPC payloads at the TypeScript boundary using deterministic parsing schemas (e.g., Zod) before executing `@tauri-apps/api/core.invoke` to prevent malformed or malicious argument serialization.

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 implement corresponding Rust-side command handlers with explicit argument typing, returning standardized Result<T, E> types rather than unwrapping or passing raw untyped JSON values.

Services MUST implement corresponding Rust-side command handlers with explicit argument typing, returning standardized Result<T, E> types rather than unwrapping or passing raw untyped JSON values.

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 invoke raw, dynamically generated command names

Components NEVER invoke raw, dynamically generated command names; all command strings must be strongly typed nominal string literals managed in a centralized IPC client registry.

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 Permission Sandboxing & Payload Boundary Enforcement critical for AI coding assistants?

Enforces granular, capability-driven IPC permission boundaries and strict payload schema validation across Tauri 2.0 mobile webview-native interfaces. Prevents privilege escalation and arbitrary command execution by isolating window identifiers, validating runtime payloads with Zod before bridge serialization, and eliminating broad plugin access scopes. 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 Wildcard Permission Grants and Unvalidated Runtime 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