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

Tauri 2.0 Multi-Window IPC Capability Scoping and Window Isolation Guardrail

Enforces strict isolation of Tauri 2.0 IPC capabilities across multi-window and mobile WebView contexts by prohibiting wildcard window targeting. Ensures that plugin and native capabilities are explicitly bound to distinct window labels with least-privilege ACL scopes, preventing privilege escalation and unauthorized command invocation from sandboxed, auxiliary, or third-party WebViews.

Prohibited Anti-Pattern: Wildcard Capability Window Scoping Exposing Privileged IPC Handlers to Untrusted WebViews

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Multi-Window IPC Capability Scoping and Window Isolation Guardrail - Enforces strict isolation of Tauri 2.0 IPC capabilities across multi-window and mobile WebView contexts by prohibiting wildcard window targeting. Ensures that plugin and native capabilities are explicitly bound to distinct window labels with least-privilege ACL scopes, preventing privilege escalation and unauthorized command invocation from sandboxed, auxiliary, or third-party WebViews.
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-multiwindow-ipc-capability-scoping-guardrail"
---

# Tauri 2.0 Multi-Window IPC Capability Scoping and Window Isolation Guardrail

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Wildcard Capability Window Scoping Exposing Privileged IPC Handlers to Untrusted WebViews

## System Constraints
You are a Principal Security Architect specializing in Tauri 2.0 application security, native bridge isolation, and multi-window capability sandboxing. Mandate strict adherence to Tauri 2.0 ACL specifications: all capabilities defined in `src-tauri/capabilities/*.json` must bind explicitly to declared window labels, dynamic WebViews created via `WebviewWindowBuilder` must execute under unprivileged contexts, and wildcard window definitions (`windows: ["*"]`) are strictly forbidden on privileged plugins (filesystem, shell, biometric, deep-link). Enforce defense-in-depth verification on both the JSON capability configuration and runtime Rust IPC dispatch layer.

## Strict Guidelines
- Engineers MUST ALWAYS isolate Tauri 2.0 capabilities into dedicated JSON files per window tier (e.g., `main-caps.json`, `auth-caps.json`) and explicitly declare the target window labels via `windows: ["label-name"]`.
- Engineers MUST NOT use wildcard window bindings (`"windows": ["*"]`) in any capability file granting core, plugin, or sensitive native permissions.
- Engineers MUST isolate secondary, embedded, or third-party WebViews (such as OAuth dialogs, sandboxed extensions, or payment gateways) to a capability set that disables all native system permissions and restricts custom commands.
- Code MUST verify incoming window context in Rust command handlers using `window.label()` or `tauri::ipc::Request` as defense-in-depth whenever commands handle sensitive business logic or cryptographic keys.
- WebViews loading remote URLs (`remote: { "urls": [...] }`) MUST NEVER share capability definitions with local frontend assets (`index.html`) or have access to native device storage APIs.

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

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Using wildcard `windows: ['*']` binds sensitive filesystem, shell, and biometric permissions globally. If an unprivileged WebView or OAuth window is spawned dynamically, an attacker injecting script can invoke these native commands to access private files or trigger host execution.
```typescript
// src-tauri/capabilities/default.json (Anti-Pattern)
// Exposing critical system permissions to all windows across the mobile runtime
export const insecureCapability = {
  $schema: '../gen/schemas/desktop-schema.json',
  identifier: 'default-all-windows',
  description: 'Shared capability with wildcard window scoping',
  windows: ['*'], // VULNERABILITY: Any newly spawned window inherits full access
  permissions: [
    'core:default',
    'fs:allow-read-file',
    'fs:allow-write-file',
    'shell:allow-execute',
    'biometric:allow-authenticate'
  ]
};
```

#### Production Standard (Correct)
> **Standard**: Capabilities are strictly partitioned by window labels. The primary window retains minimal necessary native permissions, while auxiliary/external frames are confined to event passing without filesystem or shell execution rights.
```typescript
// src-tauri/capabilities/main-window.json (Production Fix: Explicitly bound to 'main')
export const mainWindowCapability = {
  $schema: '../gen/schemas/desktop-schema.json',
  identifier: 'main-window-capability',
  description: 'Privileged capability scoped strictly to the primary authenticated window',
  windows: ['main'], // Enforce discrete identity
  permissions: [
    'core:default',
    'fs:allow-read-text-file',
    'biometric:allow-authenticate'
  ]
};

// src-tauri/capabilities/sandbox-window.json (Production Fix: Isolated auxiliary window)
export const sandboxWindowCapability = {
  $schema: '../gen/schemas/desktop-schema.json',
  identifier: 'sandbox-window-capability',
  description: 'Restricted capability for auxiliary or external content frames',
  windows: ['auth-oauth', 'preview-*'],
  permissions: [
    'core:event:allow-emit',
    'core:event:allow-listen'
  ]
};
```

### Dynamic Window Instantiation with Explicit Identity & Scoped IPC

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Creating a WebView with remote external content without strict capability confinement allows arbitrary third-party web content or redirected pages to execute native IPC commands granted under global capability scopes.
```typescript
import { WebviewWindow } from '@tauri-apps/api/webviewWindow';

// Anti-pattern: Spawns a secondary window with undefined or default labeling
// If capabilities use wildcard matching, this untrusted page gains full IPC access
export async function openAuthDialog(oauthUrl: string) {
  const authWindow = new WebviewWindow('unscoped-auth', {
    url: oauthUrl,
    title: 'Provider Login',
  });
  return authWindow;
}
```

#### Production Standard (Correct)
> **Standard**: The dynamic window is given an explicit identity ('auth-oauth') matching the restricted 'sandboxWindowCapability'. It inherits only event-passing privileges, disallowing any direct filesystem, biometric, or command execution.
```typescript
import { WebviewWindow } from '@tauri-apps/api/webviewWindow';

// Production standard: Strict label prefixing matching sandbox capability ACL
export async function openAuthDialog(oauthUrl: string): Promise<WebviewWindow> {
  const authWindow = new WebviewWindow('auth-oauth', {
    url: oauthUrl,
    title: 'Provider Login',
    incognito: true,
    // Remote content must not bridge to sensitive internals
    proxyUrl: undefined
  });

  authWindow.once('tauri://error', (error) => {
    console.error('Failed to initialize isolated auth webview:', error);
  });

  return authWindow;
}
```

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-Window IPC Capability Scoping and Window Isolation Guardrail

Tauri 2.0 Multi-Window IPC Capability Scoping and Window Isolation Guardrail defines an industrial-grade behavioral standard for mobile engineering. Enforces strict isolation of Tauri 2.0 IPC capabilities across multi-window and mobile WebView contexts by prohibiting wildcard window targeting. Ensures that plugin and native capabilities are explicitly bound to distinct window labels with least-privilege ACL scopes, preventing privilege escalation and unauthorized command invocation from sandboxed, auxiliary, or third-party WebViews. 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 Window Scoping Exposing Privileged IPC Handlers to Untrusted 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 DriftWildcard Capability Window Scoping Exposing Privileged IPC Handlers to Untrusted 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 Tauri 2.0 capabilities into dedicated JSON files per window tier (e.g., `main-caps.json`, `auth-caps.json`) and explicitly declare the target window labels via `windows

Engineers MUST ALWAYS isolate Tauri 2.0 capabilities into dedicated JSON files per window tier (e.g., `main-caps.json`, `auth-caps.json`) and explicitly declare the target window labels via `windows: ["label-name"]`.

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 window bindings (`"windows"

Engineers MUST NOT use wildcard window bindings (`"windows": ["*"]`) in any capability file granting core, plugin, or sensitive native permissions.

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 isolate secondary, embedded, or third-party WebViews (such as OAuth dialogs, sandboxed extensions, or payment gateways) to a capability set that disables all native system permissions and restricts custom commands.

Engineers MUST isolate secondary, embedded, or third-party WebViews (such as OAuth dialogs, sandboxed extensions, or payment gateways) to a capability set that disables all native system permissions and restricts custom 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.
4

Code MUST verify incoming window context in Rust command handlers using `window.label()` or `tauri

Code MUST verify incoming window context in Rust command handlers using `window.label()` or `tauri::ipc::Request` as defense-in-depth whenever commands handle sensitive business logic or cryptographic keys.

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

WebViews loading remote URLs (`remote

WebViews loading remote URLs (`remote: { "urls": [...] }`) MUST NEVER share capability definitions with local frontend assets (`index.html`) or have access to native device storage APIs.

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 Scoping and Window Isolation Guardrail critical for AI coding assistants?

Enforces strict isolation of Tauri 2.0 IPC capabilities across multi-window and mobile WebView contexts by prohibiting wildcard window targeting. Ensures that plugin and native capabilities are explicitly bound to distinct window labels with least-privilege ACL scopes, preventing privilege escalation and unauthorized command invocation from sandboxed, auxiliary, or third-party WebViews. 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 Window Scoping Exposing Privileged IPC Handlers to Untrusted 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