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

Tauri 2.0 Multi-WebView Capability Fencing and Channel Isolation

Enforces strict compile-time capability scoping and runtime IPC channel boundaries across distinct Tauri 2.0 WebViews. Prevents lateral privilege escalation by isolating native Rust bridge commands, restricting wildcard window permissions, and preventing secondary or embedded webviews (e.g., OAuth modals, remote content previews) from invoking high-privilege native device APIs.

Prohibited Anti-Pattern: Assigning global IPC capabilities or leaking streaming channels to auxiliary webviews via wildcard permissions

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Multi-WebView Capability Fencing and Channel Isolation - Enforces strict compile-time capability scoping and runtime IPC channel boundaries across distinct Tauri 2.0 WebViews. Prevents lateral privilege escalation by isolating native Rust bridge commands, restricting wildcard window permissions, and preventing secondary or embedded webviews (e.g., OAuth modals, remote content previews) from invoking high-privilege native device APIs.
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-multi-webview-capability-fence-channel-isolation"
---

# Tauri 2.0 Multi-WebView Capability Fencing and Channel Isolation

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Assigning global IPC capabilities or leaking streaming channels to auxiliary webviews via wildcard permissions

## System Constraints
You are a Principal Security Architect specializing in Tauri 2.0 mobile and desktop runtime security. Mandate absolute compile-time capability fences and strict IPC channel isolation between distinct WebViews. Auxiliary, child, or remote WebViews MUST NOT inherit host-level native capabilities.

## Strict Guidelines
- Engineers MUST ALWAYS declare granular, explicit Webview labels in src-tauri/capabilities/*.json files instead of wildcard ('*') targets.
- Engineers MUST NOT grant core OS permissions (filesystem, biometrics, secure storage) to secondary or child webview capability definitions.
- Engineers MUST instantiate separate Tauri 2.0 IPC Channels (tauri::ipc::Channel) per webview to avoid inter-frame event stream sniffing.
- Rust bridge commands MUST validate caller identity via tauri::Webview or tauri::ipc::Request when handling critical system mutations.
- Components NEVER invoke privileged core commands from webviews running remote untrusted origins or third-party web contexts.

## Bad vs Good Implementations
### Tauri 2.0 Capability Definition: Fenced vs Wildcard

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Configuring wildcards ('*') in capabilities allows any child, modal, or preview webview to call sensitive native plugins such as filesystem, keystore, or biometrics, enabling lateral privilege escalation.
```typescript
// src-tauri/capabilities/default.json (Anti-Pattern: Wildcard Access)
// {
//   "$schema": "../gen/schemas/desktop-schema.json",
//   "identifier": "default-capability",
//   "description": "Enables capabilities for all webviews",
//   "windows": ["*"],
//   "webviews": ["*"],
//   "permissions": ["core:default", "biometric:default", "fs:allow-read-text-file"]
// }

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

// Client code in an auxiliary child webview (e.g., untrusted OAuth modal)
export async function readHostData(filePath: string): Promise<string> {
  // Anti-pattern: Child webview can invoke sensitive native operations
  // because the backend configured wildcard webview permissions.
  return await invoke<string>('plugin:fs|read_text_file', { path: filePath });
}
```

#### Production Standard (Correct)
> **Standard**: Separate capability files isolate permissions per webview label ('main' vs 'auth-webview'). High-privilege plugins are kept inaccessible to auxiliary webviews, and inter-webview communications are explicitly mediated through scoped Tauri channels.
```typescript
// src-tauri/capabilities/main-window.json (Isolated Primary Window)
// {
//   "identifier": "main-capability",
//   "webviews": ["main"],
//   "permissions": ["core:default", "biometric:default", "fs:allow-read-text-file"]
// }
// src-tauri/capabilities/auth-modal.json (Restricted Child Window)
// {
//   "identifier": "auth-modal-capability",
//   "webviews": ["auth-webview"],
//   "permissions": ["core:default"]
// }

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

interface SafeTokenPayload {
  code: string;
}

// Invariant fix: Secondary webview communicates only through a scoped, isolated channel
export async function initIsolatedAuthCallback(
  onSuccess: (code: string) => void
): Promise<void> {
  const channel = new Channel<SafeTokenPayload>();
  channel.onmessage = (message) => {
    onSuccess(message.code);
  };

  // Native bridge command restricted exclusively to 'auth-webview' label
  await invoke('register_auth_listener', { onToken: channel });
}
```

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 Multi-WebView Capability Fencing and Channel Isolation

Tauri 2.0 Multi-WebView Capability Fencing and Channel Isolation defines an industrial-grade behavioral standard for mobile engineering. Enforces strict compile-time capability scoping and runtime IPC channel boundaries across distinct Tauri 2.0 WebViews. Prevents lateral privilege escalation by isolating native Rust bridge commands, restricting wildcard window permissions, and preventing secondary or embedded webviews (e.g., OAuth modals, remote content previews) from invoking high-privilege native device APIs. 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: Assigning global IPC capabilities or leaking streaming channels to auxiliary webviews via wildcard permissions 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 DriftAssigning global IPC capabilities or leaking streaming channels to auxiliary webviews via wildcard permissionsCritical
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 declare granular, explicit Webview labels in src-tauri/capabilities/*.json files instead of wildcard ('*') targets.

Engineers MUST ALWAYS declare granular, explicit Webview labels in src-tauri/capabilities/*.json files instead of wildcard ('*') targets.

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 core OS permissions (filesystem, biometrics, secure storage) to secondary or child webview capability definitions.

Engineers MUST NOT grant core OS permissions (filesystem, biometrics, secure storage) to secondary or child webview capability definitions.

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 instantiate separate Tauri 2.0 IPC Channels (tauri

Engineers MUST instantiate separate Tauri 2.0 IPC Channels (tauri::ipc::Channel) per webview to avoid inter-frame event stream sniffing.

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

Rust bridge commands MUST validate caller identity via tauri

Rust bridge commands MUST validate caller identity via tauri::Webview or tauri::ipc::Request when handling critical system mutations.

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 privileged core commands from webviews running remote untrusted origins or third-party web contexts.

Components NEVER invoke privileged core commands from webviews running remote untrusted origins or third-party 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 Multi-WebView Capability Fencing and Channel Isolation critical for AI coding assistants?

Enforces strict compile-time capability scoping and runtime IPC channel boundaries across distinct Tauri 2.0 WebViews. Prevents lateral privilege escalation by isolating native Rust bridge commands, restricting wildcard window permissions, and preventing secondary or embedded webviews (e.g., OAuth modals, remote content previews) from invoking high-privilege native device APIs. 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 (Assigning global IPC capabilities or leaking streaming channels to auxiliary webviews via wildcard permissions) 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