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

Tauri 2.0 Capability-Based IPC Sandboxing and Origin Isolation Standard

Enforces Tauri 2.0 capability-driven permission manifests, explicit webview origin boundaries, and least-privilege IPC command access across mobile and desktop runtimes. Eliminates arbitrary native code execution and lateral privilege escalation by isolating webview contexts and strictly forbidding wildcard plugin permissions. Mandates cryptographic origin validation, granular capability scoping, and deterministic payload schema validation between the frontend and native Rust handlers.

Prohibited Anti-Pattern: Exposing Wildcard Plugin Capabilities and Permitting Remote or Untrusted Webviews to Invoke Native System APIs

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Capability-Based IPC Sandboxing and Origin Isolation Standard - Enforces Tauri 2.0 capability-driven permission manifests, explicit webview origin boundaries, and least-privilege IPC command access across mobile and desktop runtimes. Eliminates arbitrary native code execution and lateral privilege escalation by isolating webview contexts and strictly forbidding wildcard plugin permissions. Mandates cryptographic origin validation, granular capability scoping, and deterministic payload schema validation between the frontend and native Rust handlers.
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/tauri2-capability-ipc-sandboxing-origin-isolation-standard"
---

# Tauri 2.0 Capability-Based IPC Sandboxing and Origin Isolation Standard

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Exposing Wildcard Plugin Capabilities and Permitting Remote or Untrusted Webviews to Invoke Native System APIs

## System Constraints
You are a Principal Software Architect enforcing the Tauri 2.0 Capability-Based IPC Sandboxing & Origin Isolation Standard. You must reject any configuration that uses broad or wildcard capabilities, disables origin validation, passes unvalidated dynamic strings to native invoke bindings, or exposes critical system plugins without scoped filesystem and network boundaries.

## Strict Guidelines
- Engineers MUST ALWAYS isolate permissions into modular capability files under `src-tauri/capabilities/` and scope each capability to explicit window and webview labels.
- Engineers MUST NOT grant blanket permissions such as `fs:default`, `shell:allow-all`, or `http:default` without restricting target directories, allowed URLs, or execution arguments.
- Engineers MUST NEVER expose native IPC commands or capabilities to remote URLs (`remote: { urls: [...] }`) unless the origin is strictly HTTPS-pinned and verified via a secure Content Security Policy (CSP).
- Frontend code MUST ALWAYS invoke native commands through strongly typed wrapper functions using `@tauri-apps/api/core` with compile-time validated parameter schemas; dynamic command dispatch (`invoke(userInput)`) is strictly prohibited.
- Rust command implementations MUST validate and sanitize all deserialized IPC arguments against boundary conditions and filesystem traversal attacks before executing OS-level primitives.
- Mobile builds (iOS and Android) MUST define distinct capability files targeting platform-specific window identifiers and disabling unused desktop capabilities like shell execution.

## Bad vs Good Implementations
### Tauri 2.0 Capability Manifest: Wildcard vs Granular Scoped Permissions

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Using wildcard windows ['*'] and unbounded default capabilities allows any webview context, including external links or XSS-vulnerable windows, to execute arbitrary shell commands, access the entire filesystem, and issue network requests.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "default-capability",
  "description": "Insecure blanket capability granting full access to all windows",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:default",
    "shell:default",
    "http:default"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Restricts capability execution exclusively to the authenticated 'main' window, limits filesystem access strictly to the application's cache directory via path scoping, and limits outbound HTTP requests to an explicitly approved API origin.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-secure-storage-capability",
  "description": "Scoped capability for secure mobile cache and isolated file reads",
  "windows": ["main"],
  "permissions": [
    "core:default",
    {
      "identifier": "fs:allow-read-text-file",
      "allow": [
        {
          "path": "$APPDATA/cache/**"
        }
      ]
    },
    {
      "identifier": "http:default",
      "allow": [
        {
          "url": "https://api.production.internal/**"
        }
      ]
    }
  ]
}
```

### Frontend IPC Invocation: Unchecked Dynamic Invocation vs Type-Safe Guarded Invocation

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Dynamic command routing enables untrusted callers or compromised dependencies to execute arbitrary native Tauri commands by passing malicious command strings and unvalidated parameters.
```typescript
import { invoke } from '@tauri-apps/api/core';

// ANTI-PATTERN: Dynamically evaluating command name and payload from unverified input
export async function executeNativeAction(commandName: string, payload: Record<string, unknown>): Promise<unknown> {
  return await invoke(commandName, payload);
}
```

#### Production Standard (Correct)
> **Standard**: Enforces an explicit static command identifier, validates inputs with strict structural checks to prevent traversal attacks, and ensures compile-time type safety for both request parameters and response values.
```typescript
import { invoke } from '@tauri-apps/api/core';

interface SecureWritePayload {
  readonly filename: string;
  readonly content: string;
}

interface WriteResult {
  readonly bytesWritten: number;
}

const FILENAME_REGEX = /^[a-zA-Z0-9_-]+\.json$/;

export async function writeEncryptedCache(
  payload: SecureWritePayload
): Promise<WriteResult> {
  if (!FILENAME_REGEX.test(payload.filename)) {
    throw new Error('Invalid filename format: path traversal detected or disallowed extension');
  }

  return await invoke<WriteResult>('write_encrypted_cache', {
    payload: {
      filename: payload.filename,
      content: payload.content
    }
  });
}
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Tauri 2.0 Capability-Based IPC Sandboxing and Origin Isolation Standard

Tauri 2.0 Capability-Based IPC Sandboxing and Origin Isolation Standard defines an industrial-grade behavioral standard for mobile engineering. Enforces Tauri 2.0 capability-driven permission manifests, explicit webview origin boundaries, and least-privilege IPC command access across mobile and desktop runtimes. Eliminates arbitrary native code execution and lateral privilege escalation by isolating webview contexts and strictly forbidding wildcard plugin permissions. Mandates cryptographic origin validation, granular capability scoping, and deterministic payload schema validation between the frontend and native Rust handlers. 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: Exposing Wildcard Plugin Capabilities and Permitting Remote or Untrusted Webviews to Invoke Native System APIs 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 DriftExposing Wildcard Plugin Capabilities and Permitting Remote or Untrusted Webviews to Invoke Native System APIsCritical
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 permissions into modular capability files under `src-tauri/capabilities/` and scope each capability to explicit window and webview labels.

Engineers MUST ALWAYS isolate permissions into modular capability files under `src-tauri/capabilities/` and scope each capability to explicit window and webview labels.

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 blanket permissions such as `fs

Engineers MUST NOT grant blanket permissions such as `fs:default`, `shell:allow-all`, or `http:default` without restricting target directories, allowed URLs, or execution arguments.

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 NEVER expose native IPC commands or capabilities to remote URLs (`remote

Engineers MUST NEVER expose native IPC commands or capabilities to remote URLs (`remote: { urls: [...] }`) unless the origin is strictly HTTPS-pinned and verified via a secure Content Security Policy (CSP).

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 code MUST ALWAYS invoke native commands through strongly typed wrapper functions using `@tauri-apps/api/core` with compile-time validated parameter schemas

Frontend code MUST ALWAYS invoke native commands through strongly typed wrapper functions using `@tauri-apps/api/core` with compile-time validated parameter schemas; dynamic command dispatch (`invoke(userInput)`) is strictly prohibited.

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

Rust command implementations MUST validate and sanitize all deserialized IPC arguments against boundary conditions and filesystem traversal attacks before executing OS-level primitives.

Rust command implementations MUST validate and sanitize all deserialized IPC arguments against boundary conditions and filesystem traversal attacks before executing OS-level primitives.

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

Mobile builds (iOS and Android) MUST define distinct capability files targeting platform-specific window identifiers and disabling unused desktop capabilities like shell execution.

Mobile builds (iOS and Android) MUST define distinct capability files targeting platform-specific window identifiers and disabling unused desktop capabilities like shell execution.

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

Enforces Tauri 2.0 capability-driven permission manifests, explicit webview origin boundaries, and least-privilege IPC command access across mobile and desktop runtimes. Eliminates arbitrary native code execution and lateral privilege escalation by isolating webview contexts and strictly forbidding wildcard plugin permissions. Mandates cryptographic origin validation, granular capability scoping, and deterministic payload schema validation between the frontend and native Rust handlers. 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 (Exposing Wildcard Plugin Capabilities and Permitting Remote or Untrusted Webviews to Invoke Native System APIs) 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