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

Tauri 2.0 Mobile Capability Sandboxing & Origin-Bound IPC Guardrails

Enforces strict capability-based Access Control Lists (ACLs) and origin-bound IPC permission sandboxing in Tauri 2.0 mobile architectures. Mandates granular command scoping, file-system path sandboxing, and webview origin isolation to prevent remote code execution (RCE) and unauthorized native privilege escalation from compromised renderer contexts.

Prohibited Anti-Pattern: Permissive Wildcard IPC Capabilities and Unscoped Command Invocation in Tauri Mobile Webviews

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Mobile Capability Sandboxing & Origin-Bound IPC Guardrails - Enforces strict capability-based Access Control Lists (ACLs) and origin-bound IPC permission sandboxing in Tauri 2.0 mobile architectures. Mandates granular command scoping, file-system path sandboxing, and webview origin isolation to prevent remote code execution (RCE) and unauthorized native privilege escalation from compromised renderer contexts.
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-capability-ipc-sandbox"
---

# Tauri 2.0 Mobile Capability Sandboxing & Origin-Bound IPC Guardrails

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Permissive Wildcard IPC Capabilities and Unscoped Command Invocation in Tauri Mobile Webviews

## System Constraints
You are a Principal Security Architect enforcing the Tauri 2.0 Capability-Based IPC Permission Sandbox. You must eliminate all instances of broad IPC permissions, wildcard capabilities, unscoped native invocations, and arbitrary renderer trust on mobile platforms. Enforce precise JSON capability manifests, strict window targeting, runtime permission verification, and cryptographically verified schema contracts on all IPC messages.

## Strict Guidelines
- Engineers MUST ALWAYS isolate mobile capabilities into dedicated manifests (e.g., `src-tauri/capabilities/mobile.json`) targeting only specific mobile window labels rather than applying global capabilities across all platforms.
- Engineers MUST NOT grant wildcard permissions (`*`) or unrestricted core plugins (`core:default`, `fs:default`, `shell:allow-execute`) to mobile webview windows.
- Engineers MUST ALWAYS scope file system permissions (`fs:allow-*`) to explicit application sandboxes (e.g., `$APP_DATA/*`, `$APPCACHE/*`) with read-only flags where writes are not strictly required.
- Engineers MUST validate all arguments passed to `invoke()` using strict runtime schemas (such as Zod in TypeScript and Serde validators in Rust) before processing them in native Rust command handlers.
- Components NEVER invoke raw system shells or unchecked dynamic commands from the frontend webview; native mobile actions must be encapsulated in tightly typed, domain-specific Rust commands.
- Services MUST explicitly configure remote URL capabilities and webview origins in `tauri.conf.json`, forbidding unauthorized external origins from calling native IPC bridges.

## Bad vs Good Implementations
### Mobile Capability Sandbox Configuration

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Grants wildcard window access with dangerous shell execution and broad filesystem permissions. A compromise in the mobile webview (via XSS or third-party script injection) results in complete native device takeover via arbitrary shell and filesystem commands.
```typescript
// src-tauri/capabilities/default.json (ANTI-PATTERN: Permissive global capabilities)
/*
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "default",
  "description": "Broad access for all platforms",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:allow-read",
    "fs:allow-write",
    "shell:allow-open",
    "shell:allow-execute"
  ]
}
*/

import { invoke } from '@tauri-apps/api/core';

// Frontend: Unvalidated invocation of privileged command
export async function runShellCommand(cmd: string, args: string[]) {
  return await invoke('exec_shell', { cmd, args });
}
```

#### Production Standard (Correct)
> **Standard**: Isolates the mobile capability to the 'main' window on mobile targets, eliminates raw shell execution, restricts filesystem access strictly to '$APP_DATA/user-settings.json', and enforces runtime schema validation on both invocation inputs and returned payloads.
```typescript
// src-tauri/capabilities/mobile.json (PRODUCTION: Sandboxed mobile capability)
/*
{
  "$schema": "../gen/schemas/mobile-schema.json",
  "identifier": "mobile-sandboxed",
  "description": "Strict capability sandbox for mobile runtime",
  "windows": ["main"],
  "platforms": ["android", "ios"],
  "permissions": [
    "core:event:allow-listen",
    "core:event:allow-emit",
    {
      "identifier": "fs:allow-read-text-file",
      "allow": [{
        "path": "$APP_DATA/user-settings.json"
      }]
    },
    "app:allow-read-secure-profile"
  ]
}
*/

import { invoke } from '@tauri-apps/api/core';
import { z } from 'zod';

const SecureProfileSchema = z.object({
  userId: z.string().uuid(),
  displayName: z.string().min(1).max(50),
  sessionToken: z.string().min(32)
});

export type SecureProfile = z.infer<typeof SecureProfileSchema>;

export async function getSecureProfile(userId: string): Promise<SecureProfile> {
  const sanitizedUserId = z.string().uuid().parse(userId);
  const rawResult = await invoke('plugin:app|read_secure_profile', {
    payload: { userId: sanitizedUserId }
  });
  return SecureProfileSchema.parse(rawResult);
}
```

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 Capability Sandboxing & Origin-Bound IPC Guardrails

Tauri 2.0 Mobile Capability Sandboxing & Origin-Bound IPC Guardrails defines an industrial-grade behavioral standard for mobile engineering. Enforces strict capability-based Access Control Lists (ACLs) and origin-bound IPC permission sandboxing in Tauri 2.0 mobile architectures. Mandates granular command scoping, file-system path sandboxing, and webview origin isolation to prevent remote code execution (RCE) and unauthorized native privilege escalation from compromised renderer 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 IPC Capabilities and Unscoped Command Invocation in Tauri Mobile Webviews 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 IPC Capabilities and Unscoped Command Invocation in Tauri Mobile WebviewsCritical
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 manifests (e.g., `src-tauri/capabilities/mobile.json`) targeting only specific mobile window labels rather than applying global capabilities across all platforms.

Engineers MUST ALWAYS isolate mobile capabilities into dedicated manifests (e.g., `src-tauri/capabilities/mobile.json`) targeting only specific mobile window labels rather than applying global capabilities across all platforms.

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 (`*`) or unrestricted core plugins (`core

Engineers MUST NOT grant wildcard permissions (`*`) or unrestricted core plugins (`core:default`, `fs:default`, `shell:allow-execute`) to mobile webview windows.

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 scope file system permissions (`fs

Engineers MUST ALWAYS scope file system permissions (`fs:allow-*`) to explicit application sandboxes (e.g., `$APP_DATA/*`, `$APPCACHE/*`) with read-only flags where writes are not strictly required.

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 validate all arguments passed to `invoke()` using strict runtime schemas (such as Zod in TypeScript and Serde validators in Rust) before processing them in native Rust command handlers.

Engineers MUST validate all arguments passed to `invoke()` using strict runtime schemas (such as Zod in TypeScript and Serde validators in Rust) before processing them in native Rust command handlers.

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 system shells or unchecked dynamic commands from the frontend webview

Components NEVER invoke raw system shells or unchecked dynamic commands from the frontend webview; native mobile actions must be encapsulated in tightly typed, domain-specific Rust commands.

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 explicitly configure remote URL capabilities and webview origins in `tauri.conf.json`, forbidding unauthorized external origins from calling native IPC bridges.

Services MUST explicitly configure remote URL capabilities and webview origins in `tauri.conf.json`, forbidding unauthorized external origins from calling native IPC bridges.

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 Capability Sandboxing & Origin-Bound IPC Guardrails critical for AI coding assistants?

Enforces strict capability-based Access Control Lists (ACLs) and origin-bound IPC permission sandboxing in Tauri 2.0 mobile architectures. Mandates granular command scoping, file-system path sandboxing, and webview origin isolation to prevent remote code execution (RCE) and unauthorized native privilege escalation from compromised renderer 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 IPC Capabilities and Unscoped Command Invocation in Tauri Mobile Webviews) 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