This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
mobilecritical PriorityID: tauri2-origin-bound-acl-ipc-sandbox-guardrail

Tauri 2.0 Capability-Based Multi-Webview IPC Sandbox & Origin ACL Enforcement

Enforces strict origin-bound, capability-scoped Access Control Lists (ACLs) across multi-window desktop and mobile hybrid runtimes in Tauri 2.0. Prevents lateral host privilege escalation from secondary, auth, or remote webviews by eliminating wildcard capability assignments and mandating granular command-level authorization.

Prohibited Anti-Pattern: Wildcard capability assignment allowing secondary or remote webviews to invoke privileged host IPC commands

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Capability-Based Multi-Webview IPC Sandbox & Origin ACL Enforcement - Enforces strict origin-bound, capability-scoped Access Control Lists (ACLs) across multi-window desktop and mobile hybrid runtimes in Tauri 2.0. Prevents lateral host privilege escalation from secondary, auth, or remote webviews by eliminating wildcard capability assignments and mandating granular command-level authorization.
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/tauri2-origin-bound-acl-ipc-sandbox-guardrail"
---

# Tauri 2.0 Capability-Based Multi-Webview IPC Sandbox & Origin ACL Enforcement

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Wildcard capability assignment allowing secondary or remote webviews to invoke privileged host IPC commands

## System Constraints
You are a Principal Security Architect enforcing Tauri 2.0 capability-based security invariants. You must mandate strict separation of IPC permissions across all webview contexts, disallowing wildcard capability windows, permissive plugin scopes, and unvalidated IPC command bindings.

## Strict Guidelines
- Engineers MUST ALWAYS isolate webviews into distinct capabilities defined in `src-tauri/capabilities/*.json` using exact window/webview label matches rather than wildcards (`*`).
- Engineers MUST NOT grant high-privilege plugins (e.g., `fs`, `shell`, `process`, `dialog`) to secondary windows, OAuth webviews, or non-primary mobile overlays.
- Code SHOULD enforce command argument filtering within Tauri 2.0 permission definitions to prevent path traversal and arbitrary command execution.
- Services MUST validate the calling Webview label and origin inside custom Rust IPC commands via `tauri::ipc::Request` or `tauri::WebviewWindow` references prior to executing privileged host operations.
- Components NEVER execute raw `@tauri-apps/api/core` `invoke` calls from unauthenticated or dynamically loaded external web contexts.

## Bad vs Good Implementations
### Capability Definition and IPC Invocation Isolation

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Assigning windows: ['*'] with permissive core, filesystem, and shell capabilities permits any spawned child window, authentication popup, or remote iframe to invoke high-privilege host APIs, resulting in complete host compromise upon XSS or malicious navigation.
```typescript
// capabilities/default.json allowing global command execution across all windows
// {
//   "$schema": "../gen/schemas/desktop-schema.json",
//   "identifier": "main-capability",
//   "windows": ["*"],
//   "permissions": ["core:default", "fs:allow-read-all", "shell:allow-execute"]
// }

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

// Invoked blindly from secondary/auth/external webview without contextual origin verification
export async function executeHostCommand(commandStr: string): Promise<string> {
  return await invoke('execute_privileged_task', { command: commandStr });
}
```

#### Production Standard (Correct)
> **Standard**: Explicitly restricts capabilities per named webview in granular capability files, prevents wildcards, establishes path-restricted ACL permissions, and checks caller window boundaries to ensure lateral privilege escalation is architecturally blocked.
```typescript
// capabilities/auth-window.json (Isolated minimal scope)
// {
//   "$schema": "../gen/schemas/desktop-schema.json",
//   "identifier": "auth-isolated-capability",
//   "windows": ["auth-window"],
//   "permissions": ["core:event:allow-listen", "core:event:allow-emit"]
// }

// capabilities/main-window.json (Restricted main runtime scope)
// {
//   "$schema": "../gen/schemas/desktop-schema.json",
//   "identifier": "main-app-capability",
//   "windows": ["main"],
//   "permissions": [
//     "core:default",
//     { "identifier": "fs:allow-read", "allow": [{ "path": "$APP_DATA_DIR/**" }] }
//   ]
// }

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

export async function executeRestrictedRead(filename: string): Promise<string> {
  const currentWindow = getCurrentWebviewWindow();
  
  if (currentWindow.label !== 'main') {
    throw new Error('AccessDenied: Unauthorized webview context for host operation.');
  }
  
  // Strict argument typing passed to tightly scoped IPC endpoint
  return await invoke<string>('read_application_manifest', { 
    targetFile: filename 
  });
}
```

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 Multi-Webview IPC Sandbox & Origin ACL Enforcement

Tauri 2.0 Capability-Based Multi-Webview IPC Sandbox & Origin ACL Enforcement defines an industrial-grade behavioral standard for mobile engineering. Enforces strict origin-bound, capability-scoped Access Control Lists (ACLs) across multi-window desktop and mobile hybrid runtimes in Tauri 2.0. Prevents lateral host privilege escalation from secondary, auth, or remote webviews by eliminating wildcard capability assignments and mandating granular command-level authorization. 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: Wildcard capability assignment allowing secondary or remote webviews to invoke privileged host IPC commands 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 DriftWildcard capability assignment allowing secondary or remote webviews to invoke privileged host IPC commandsCritical
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 webviews into distinct capabilities defined in `src-tauri/capabilities/*.json` using exact window/webview label matches rather than wildcards (`*`).

Engineers MUST ALWAYS isolate webviews into distinct capabilities defined in `src-tauri/capabilities/*.json` using exact window/webview label matches rather than wildcards (`*`).

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 high-privilege plugins (e.g., `fs`, `shell`, `process`, `dialog`) to secondary windows, OAuth webviews, or non-primary mobile overlays.

Engineers MUST NOT grant high-privilege plugins (e.g., `fs`, `shell`, `process`, `dialog`) to secondary windows, OAuth webviews, or non-primary mobile overlays.

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 enforce command argument filtering within Tauri 2.0 permission definitions to prevent path traversal and arbitrary command execution.

Code SHOULD enforce command argument filtering within Tauri 2.0 permission definitions to prevent path traversal and arbitrary command 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.
4

Services MUST validate the calling Webview label and origin inside custom Rust IPC commands via `tauri

Services MUST validate the calling Webview label and origin inside custom Rust IPC commands via `tauri::ipc::Request` or `tauri::WebviewWindow` references prior to executing privileged host 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.
5

Components NEVER execute raw `@tauri-apps/api/core` `invoke` calls from unauthenticated or dynamically loaded external web contexts.

Components NEVER execute raw `@tauri-apps/api/core` `invoke` calls from unauthenticated or dynamically loaded external web contexts.

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 Multi-Webview IPC Sandbox & Origin ACL Enforcement critical for AI coding assistants?

Enforces strict origin-bound, capability-scoped Access Control Lists (ACLs) across multi-window desktop and mobile hybrid runtimes in Tauri 2.0. Prevents lateral host privilege escalation from secondary, auth, or remote webviews by eliminating wildcard capability assignments and mandating granular command-level authorization. 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 (Wildcard capability assignment allowing secondary or remote webviews to invoke privileged host IPC commands) 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