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

Tauri 2.0 Multi-WebView IPC Isolation & Capability Scoping

Enforces strict window-scoped capability segregation and IPC context isolation across multi-webview Tauri 2.0 mobile architectures. Mandates explicit webview label binding in capability configurations and cryptographic caller validation within Rust command handlers to prevent secondary webviews from invoking privileged native operations.

Prohibited Anti-Pattern: Ambient Native Exposure via Wildcard IPC Capability Allocation Across WebViews

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Multi-WebView IPC Isolation & Capability Scoping - Enforces strict window-scoped capability segregation and IPC context isolation across multi-webview Tauri 2.0 mobile architectures. Mandates explicit webview label binding in capability configurations and cryptographic caller validation within Rust command handlers to prevent secondary webviews from invoking privileged native operations.
globs: src-tauri/capabilities/**/*.json, src-tauri/src/**/*.rs, src/**/*.ts, src/**/*.tsx
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tauri-v2-multi-webview-ipc-isolation-fence"
---

# Tauri 2.0 Multi-WebView IPC Isolation & Capability Scoping

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Ambient Native Exposure via Wildcard IPC Capability Allocation Across WebViews

## System Constraints
You are a Principal Security Architect enforcing Tauri 2.0 Multi-WebView IPC Isolation. In multi-webview Tauri mobile deployments, native platform capabilities (biometrics, secure keystore, camera, file system) must be strictly partitioned. You must mandate zero-trust window capability mapping, enforce per-webview capability JSON configurations, verify caller webview labels directly in Rust IPC handler signatures, and forbid ambient execution or wildcard permissions.

## Strict Guidelines
- Engineers MUST ALWAYS isolate capabilities per window label inside `src-tauri/capabilities/*.json` using explicit `windows` arrays instead of default wildcard inheritance.
- Engineers MUST extract and validate the caller `tauri::Webview` or `tauri::WebviewWindow` instance within every privileged Rust command handler to verify the executing window context.
- Engineers MUST NOT grant high-privilege native capabilities (e.g., biometrics, secure storage, deep links) to secondary, ephemeral, or external-facing webviews.
- Code SHOULD implement Tauri 2.0's Isolation Pattern with a cryptographic runtime challenge when untrusted or dynamic third-party web content is rendered.
- Services MUST reject unauthenticated cross-webview IPC events by segregating event listener namespaces using window-specific channel tokens.
- Components NEVER invoke Tauri global invoke (`window.__TAURI_INTERNALS__.invoke`) directly without using strongly-typed, auto-generated, isolated command bindings.

## Bad vs Good Implementations
### Tauri 2.0 Capability ACL Configuration

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Using wildcard `windows: ["*"]` grants secondary or dynamically created webviews access to critical mobile capabilities (biometrics, full filesystem, persistent stores), opening vector paths for local privilege escalation.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "ambient-capabilities",
  "description": "Anti-pattern: Grants all permissions globally across every webview window",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "biometric:allow-authenticate",
    "store:default",
    "fs:allow-read-all"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Explicitly binds high-privilege native plugins and commands exclusively to the authenticated `main` webview label. Any secondary webview window created at runtime is denied access by default.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "isolated-main-capability",
  "description": "Restricts sensitive native capabilities strictly to the verified primary mobile webview",
  "windows": ["main"],
  "permissions": [
    "core:default",
    "biometric:allow-authenticate",
    "store:default"
  ]
}
```

### Rust Command Webview Context Verification

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The Rust command ignores caller provenance. If any secondary webview or compromised renderer can reach the IPC bridge, it executes the privileged operation without boundary checks.
```typescript
// Rust Command: src-tauri/src/commands.rs
// #[tauri::command]
// pub async fn access_secure_vault(payload: String) -> Result<String, String> {
//     // Flaw: No Webview parameter; any window can execute this command
//     read_keystore(payload)
// }

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

export async function requestSensitiveData(token: string): Promise<string> {
  // Arbitrary webview invoking unvalidated native command
  return await invoke<string>('access_secure_vault', { payload: token });
}
```

#### Production Standard (Correct)
> **Standard**: Enforces double-sided context validation: the frontend asserts window identity before dispatching, and the native Rust backend strictly inspects `tauri::Webview::label(&webview)` to ensure only the trusted window executes the keystore access.
```typescript
// Rust Command: src-tauri/src/commands.rs
// #[tauri::command]
// pub async fn access_secure_vault(
//     webview: tauri::Webview,
//     payload: String
// ) -> Result<String, String> {
//     if webview.label() != "main" {
//         return Err("IPC_ACCESS_DENIED: Webview context unauthorized".into());
//     }
//     read_keystore(payload)
// }

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

export async function requestSensitiveData(token: string): Promise<string> {
  const current = getCurrentWebview();
  if (current.label !== 'main') {
    throw new Error('Operation not permitted from current webview context.');
  }
  return await invoke<string>('access_secure_vault', { payload: token });
}
```

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 IPC Isolation & Capability Scoping

Tauri 2.0 Multi-WebView IPC Isolation & Capability Scoping defines an industrial-grade behavioral standard for mobile engineering. Enforces strict window-scoped capability segregation and IPC context isolation across multi-webview Tauri 2.0 mobile architectures. Mandates explicit webview label binding in capability configurations and cryptographic caller validation within Rust command handlers to prevent secondary webviews from invoking privileged native operations. 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: Ambient Native Exposure via Wildcard IPC Capability Allocation Across 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 DriftAmbient Native Exposure via Wildcard IPC Capability Allocation Across 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 capabilities per window label inside `src-tauri/capabilities/*.json` using explicit `windows` arrays instead of default wildcard inheritance.

Engineers MUST ALWAYS isolate capabilities per window label inside `src-tauri/capabilities/*.json` using explicit `windows` arrays instead of default wildcard inheritance.

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 extract and validate the caller `tauri

Engineers MUST extract and validate the caller `tauri::Webview` or `tauri::WebviewWindow` instance within every privileged Rust command handler to verify the executing window context.

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 NOT grant high-privilege native capabilities (e.g., biometrics, secure storage, deep links) to secondary, ephemeral, or external-facing webviews.

Engineers MUST NOT grant high-privilege native capabilities (e.g., biometrics, secure storage, deep links) to secondary, ephemeral, or external-facing webviews.

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

Code SHOULD implement Tauri 2.0's Isolation Pattern with a cryptographic runtime challenge when untrusted or dynamic third-party web content is rendered.

Code SHOULD implement Tauri 2.0's Isolation Pattern with a cryptographic runtime challenge when untrusted or dynamic third-party web content is rendered.

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

Services MUST reject unauthenticated cross-webview IPC events by segregating event listener namespaces using window-specific channel tokens.

Services MUST reject unauthenticated cross-webview IPC events by segregating event listener namespaces using window-specific channel tokens.

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

Components NEVER invoke Tauri global invoke (`window.__TAURI_INTERNALS__.invoke`) directly without using strongly-typed, auto-generated, isolated command bindings.

Components NEVER invoke Tauri global invoke (`window.__TAURI_INTERNALS__.invoke`) directly without using strongly-typed, auto-generated, isolated command bindings.

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 IPC Isolation & Capability Scoping critical for AI coding assistants?

Enforces strict window-scoped capability segregation and IPC context isolation across multi-webview Tauri 2.0 mobile architectures. Mandates explicit webview label binding in capability configurations and cryptographic caller validation within Rust command handlers to prevent secondary webviews from invoking privileged native operations. 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 (Ambient Native Exposure via Wildcard IPC Capability Allocation Across 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