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

Tauri 2.0 Multi-Window IPC Capability Scope Isolation Standard

Enforces strict window-level and webview-level capability scoping in Tauri 2.0 mobile and multi-window architectures to prevent cross-frame privilege escalation. Native commands and plugin operations must cryptographically bind to verified webview labels declared in granular permission manifests rather than relying on wildcard window allowances or ambient IPC execution. Eliminates unauthorized plugin invocation across untrusted webview contexts and third-party iframe overlays.

Prohibited Anti-Pattern: Ambient IPC Execution via Wildcard Window Capabilities and Unverified Webview Labels

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Multi-Window IPC Capability Scope Isolation Standard - Enforces strict window-level and webview-level capability scoping in Tauri 2.0 mobile and multi-window architectures to prevent cross-frame privilege escalation. Native commands and plugin operations must cryptographically bind to verified webview labels declared in granular permission manifests rather than relying on wildcard window allowances or ambient IPC execution. Eliminates unauthorized plugin invocation across untrusted webview contexts and third-party iframe overlays.
globs: src-tauri/src/**/*.rs, src-tauri/capabilities/**/*.json, src-tauri/tauri.conf.json, src/**/*.{ts,tsx}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tauri-v2-multi-window-ipc-capability-scope-isolation"
---

# Tauri 2.0 Multi-Window IPC Capability Scope Isolation Standard

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Ambient IPC Execution via Wildcard Window Capabilities and Unverified Webview Labels

## System Constraints
You are a Principal Security Architect enforcing the Tauri 2.0 Multi-Window IPC Capability Scope Isolation Standard. You must mandate strict principle-of-least-privilege capability manifests and explicit webview origin verification in Rust commands and TypeScript IPC calls. Prohibit wildcard window access, ambient invocation without window label checks, and insecure inter-webview messaging.

## Strict Guidelines
- Engineers MUST ALWAYS isolate distinct functional contexts (e.g., auth, main view, untrusted webview) into separate capability manifest files in `src-tauri/capabilities/*.json` targeting exact window labels.
- Engineers MUST NOT use wildcard `"windows": ["*"]` in capability manifests containing native mobile plugins (biometrics, secure storage, camera, deep links) or custom state-mutating commands.
- Rust commands MUST explicitly validate caller identity using `tauri::WebviewWindow` or `tauri::Webview` parameter types to verify the caller's label against authorization invariants prior to executing sensitive actions.
- Components NEVER execute raw `@tauri-apps/api/core` `invoke` calls from dynamic iframes or secondary unauthenticated webviews without passing through an authenticated IPC gatekeeper bridge.
- Code SHOULD enforce strict Content Security Policy (CSP) and origin-locking per webview in `tauri.conf.json` to prevent malicious frame injection from spoofing valid webview handles.

## Bad vs Good Implementations
### Tauri 2.0 Capability Manifest Scoping and Command Caller Validation

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Granting capabilities to wildcard windows ('*') allows low-trust or auxiliary webview windows to call high-privilege native commands and mobile security plugins. The Rust command lacks webview origin context verification, allowing cross-frame invocation.
```rust
// src-tauri/capabilities/default.json
// BAD: Overly permissive capability grant exposing secure storage to all windows
// {
//   "$schema": "../gen/schemas/desktop-schema.json",
//   "identifier": "default-capability",
//   "windows": ["*"],
//   "permissions": ["core:default", "secure-storage:default"]
// }

// src-tauri/src/main.rs
#[tauri::command]
async fn unlock_vault(token: String) -> Result<String, String> {
    // Anti-pattern: Ambient command does not verify caller identity or window origin.
    // Any webview or injected secondary frame can execute this command.
    execute_secure_vault_unlock(&token)
}
```

#### Production Standard (Correct)
> **Standard**: Capabilities are isolated to specific window labels ('auth-window'). The Rust command injects the calling WebviewWindow context and enforces strict identity checks, ensuring unprivileged webviews cannot trigger secure commands even if maliciously addressed.
```rust
// src-tauri/capabilities/auth.json
// GOOD: Specific capability binding exclusively to the verified auth webview
// {
//   "$schema": "../gen/schemas/desktop-schema.json",
//   "identifier": "isolated-auth-capability",
//   "windows": ["auth-window"],
//   "permissions": ["core:default", "biometric:authenticate"]
// }

// src-tauri/src/commands/vault.rs
use tauri::{command, WebviewWindow};

#[command]
async fn unlock_vault(
    window: WebviewWindow,
    token: String
) -> Result<String, String> {
    // Mandate caller window validation against authoritative runtime identifier
    if window.label() != "auth-window" {
        return Err("AccessDenied: Caller window is not authorized for vault operations.".into());
    }

    execute_secure_vault_unlock(&token)
}
```

### TypeScript IPC Gatekeeper and Window-Context Boundary Enforcement

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Using ambient invoke from arbitrary frontend modules permits untrusted child components, third-party embeds, or secondary webviews to trigger high-privilege native commands without asserting context integrity.
```typescript
// BAD: Direct, unvalidated IPC invocation in shared components without origin check
import { invoke } from '@tauri-apps/api/core';

export async function requestSensitiveMobileAction(payload: Record<string, unknown>) {
  // Insecure: Invokes native backend indiscriminately from any context or frame
  return await invoke('perform_mobile_transaction', { payload });
}
```

#### Production Standard (Correct)
> **Standard**: The client-side API verifies that invocation occurs strictly within the designated webview label before sending the IPC message, ensuring compliance with the Tauri 2.0 capabilities hierarchy.
```typescript
// GOOD: Enforce current webview identity before initiating native IPC calls
import { invoke } from '@tauri-apps/api/core';
import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow';

const AUTHORIZED_TRANSACTION_WINDOW = 'transaction-window';

export async function requestSensitiveMobileAction(payload: Record<string, unknown>) {
  const currentWindow = getCurrentWebviewWindow();
  
  if (currentWindow.label !== AUTHORIZED_TRANSACTION_WINDOW) {
    throw new Error(
      `IPC Capability Violation: Cannot invoke transaction from window context '${currentWindow.label}'.`
    );
  }

  return await invoke<string>('perform_mobile_transaction', { payload });
}
```

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-Window IPC Capability Scope Isolation Standard

Tauri 2.0 Multi-Window IPC Capability Scope Isolation Standard defines an industrial-grade behavioral standard for mobile engineering. Enforces strict window-level and webview-level capability scoping in Tauri 2.0 mobile and multi-window architectures to prevent cross-frame privilege escalation. Native commands and plugin operations must cryptographically bind to verified webview labels declared in granular permission manifests rather than relying on wildcard window allowances or ambient IPC execution. Eliminates unauthorized plugin invocation across untrusted webview contexts and third-party iframe overlays. 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 IPC Execution via Wildcard Window Capabilities and Unverified Webview Labels 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 IPC Execution via Wildcard Window Capabilities and Unverified Webview LabelsCritical
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 distinct functional contexts (e.g., auth, main view, untrusted webview) into separate capability manifest files in `src-tauri/capabilities/*.json` targeting exact window labels.

Engineers MUST ALWAYS isolate distinct functional contexts (e.g., auth, main view, untrusted webview) into separate capability manifest files in `src-tauri/capabilities/*.json` targeting exact window 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 use wildcard `"windows"

Engineers MUST NOT use wildcard `"windows": ["*"]` in capability manifests containing native mobile plugins (biometrics, secure storage, camera, deep links) or custom state-mutating 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.
3

Rust commands MUST explicitly validate caller identity using `tauri

Rust commands MUST explicitly validate caller identity using `tauri::WebviewWindow` or `tauri::Webview` parameter types to verify the caller's label against authorization invariants prior to executing sensitive actions.

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

Components NEVER execute raw `@tauri-apps/api/core` `invoke` calls from dynamic iframes or secondary unauthenticated webviews without passing through an authenticated IPC gatekeeper bridge.

Components NEVER execute raw `@tauri-apps/api/core` `invoke` calls from dynamic iframes or secondary unauthenticated webviews without passing through an authenticated IPC gatekeeper bridge.

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

Code SHOULD enforce strict Content Security Policy (CSP) and origin-locking per webview in `tauri.conf.json` to prevent malicious frame injection from spoofing valid webview handles.

Code SHOULD enforce strict Content Security Policy (CSP) and origin-locking per webview in `tauri.conf.json` to prevent malicious frame injection from spoofing valid webview handles.

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-Window IPC Capability Scope Isolation Standard critical for AI coding assistants?

Enforces strict window-level and webview-level capability scoping in Tauri 2.0 mobile and multi-window architectures to prevent cross-frame privilege escalation. Native commands and plugin operations must cryptographically bind to verified webview labels declared in granular permission manifests rather than relying on wildcard window allowances or ambient IPC execution. Eliminates unauthorized plugin invocation across untrusted webview contexts and third-party iframe overlays. 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 IPC Execution via Wildcard Window Capabilities and Unverified Webview Labels) 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