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

Tauri 2.0 Multi-Window IPC Capability Isolation & Sandboxing Standard

Enforces strict capability scoping and explicit label sandboxing for dynamically spawned secondary webviews in Tauri 2.0. Prevents privilege escalation and remote code execution by ensuring dynamic windows, preview contexts, and untrusted frames cannot inherit wildcard native Rust IPC commands or system dialog access.

Prohibited Anti-Pattern: Assigning Wildcard Window Capabilities or Spawning Unrestricted WebviewWindows for Untrusted Content

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Multi-Window IPC Capability Isolation & Sandboxing Standard - Enforces strict capability scoping and explicit label sandboxing for dynamically spawned secondary webviews in Tauri 2.0. Prevents privilege escalation and remote code execution by ensuring dynamic windows, preview contexts, and untrusted frames cannot inherit wildcard native Rust IPC commands or system dialog access.
globs: src/**/*.{ts,tsx}, src-tauri/capabilities/**/*.json, src-tauri/tauri.conf.json
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tauri-v2-multiwindow-ipc-capability-scoping"
---

# Tauri 2.0 Multi-Window IPC Capability Isolation & Sandboxing Standard

> **Severity**: CRITICAL | **Category**: frontend
> **Anti-Pattern Warning**: Assigning Wildcard Window Capabilities or Spawning Unrestricted WebviewWindows for Untrusted Content

## System Constraints
You are a Principal Security Architect and Tauri Specialist enforcing Tauri 2.0 Multi-Window IPC Capability Scoping. In Tauri 2.0, IPC access is bound to window labels through capabilities. You must mandate strict least-privilege capability manifests and enforce defensive frontend window-creation patterns to ensure dynamically spawned windows, popups, and preview frames cannot execute unauthorized Rust commands, access filesystem dialogs, or abuse native plugins.

## Strict Guidelines
- Engineers MUST ALWAYS enforce strict window label naming conventions (e.g., `sandbox-preview-*` or `auth-popup-*`) matching discrete capability files in `src-tauri/capabilities/`.
- Engineers MUST NOT configure capability manifests with wildcard windows (`"windows": ["*"]`) when exposing native core commands, dialog plugins, or filesystem APIs.
- Frontend window creation via `@tauri-apps/api/webviewWindow` or `@tauri-apps/api/webview` MUST explicitly set `proxyUrl`, disable dangerous webview flags, and assign deterministic window labels bound to restricted capabilities.
- Services MUST route communication between secondary/untrusted windows and the core backend through message-passing or structured parent-window proxies rather than granting direct IPC invoke permissions.
- Components NEVER execute `@tauri-apps/api/core::invoke` inside preview frames or secondary windows without verifying that the window label matches an authenticated, privileged execution context.

## Bad vs Good Implementations
### Insecure Dynamic Window Creation vs. Sandboxed Capability Scoping

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Creating a secondary webview with arbitrary naming when global wildcard capabilities exist enables the loaded content (which may be untrusted, third-party, or compromise-prone) to call all registered native Tauri plugins and Rust invoke commands, resulting in potential privilege escalation.
```typescript
import { WebviewWindow } from '@tauri-apps/api/webviewWindow';

// ANTI-PATTERN: Spawning secondary window with arbitrary label and full native access
export async function openDocumentPreview(docId: string, url: string) {
  const previewWindow = new WebviewWindow(`preview_${docId}`, {
    url,
    // Dangerous: Window will match 'windows: ["*"]' capabilities
    // and gain full access to invoke('save_to_disk'), dialogs, shell, etc.
    title: 'Document Preview'
  });

  await previewWindow.once('tauri://created', () => {
    console.log('Preview window created with inherited default permissions');
  });
}
```

#### Production Standard (Correct)
> **Standard**: Enforces a strict, sanitized window-label prefix (`isolated-preview-*`) that matches a dedicated capability manifest configured with zero IPC access or only read-only event listeners. Untrusted secondary views are denied access to native invoke commands and high-risk system dialogs.
```typescript
import { WebviewWindow } from '@tauri-apps/api/webviewWindow';
import { emitTo } from '@tauri-apps/api/event';

// PRODUCTION INVARIANT: Restricted window label prefix bound to isolated capability manifest
const SANDBOX_PREFIX = 'isolated-preview-';

export async function openDocumentPreview(docId: string, externalUrl: string): Promise<WebviewWindow> {
  // Deterministic label strictly matched in src-tauri/capabilities/preview-sandbox.json
  const safeLabel = `${SANDBOX_PREFIX}${docId.replace(/[^a-zA-Z0-9-]/g, '')}`;

  const previewWindow = new WebviewWindow(safeLabel, {
    url: externalUrl,
    title: 'Document Preview',
    // Disable dangerous native webview features
    focus: true,
    skipTaskbar: false,
    dragDropEnabled: false,
    incognito: true
  });

  await previewWindow.once('tauri://created', async () => {
    // Restrict direct IPC: orchestrate via safe event emissions from the host
    await emitTo(safeLabel, 'preview-initialized', { docId });
  });

  previewWindow.once('tauri://error', (e) => {
    console.error(`Failed to securely initialize window ${safeLabel}:`, e);
  });

  return previewWindow;
}
```

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 Isolation & Sandboxing Standard

Tauri 2.0 Multi-Window IPC Capability Isolation & Sandboxing Standard defines an industrial-grade behavioral standard for frontend engineering. Enforces strict capability scoping and explicit label sandboxing for dynamically spawned secondary webviews in Tauri 2.0. Prevents privilege escalation and remote code execution by ensuring dynamic windows, preview contexts, and untrusted frames cannot inherit wildcard native Rust IPC commands or system dialog access. 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 Wildcard Window Capabilities or Spawning Unrestricted WebviewWindows for Untrusted Content 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 Wildcard Window Capabilities or Spawning Unrestricted WebviewWindows for Untrusted ContentCritical
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 enforce strict window label naming conventions (e.g., `sandbox-preview-*` or `auth-popup-*`) matching discrete capability files in `src-tauri/capabilities/`.

Engineers MUST ALWAYS enforce strict window label naming conventions (e.g., `sandbox-preview-*` or `auth-popup-*`) matching discrete capability files in `src-tauri/capabilities/`.

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 configure capability manifests with wildcard windows (`"windows"

Engineers MUST NOT configure capability manifests with wildcard windows (`"windows": ["*"]`) when exposing native core commands, dialog plugins, or filesystem 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.
3

Frontend window creation via `@tauri-apps/api/webviewWindow` or `@tauri-apps/api/webview` MUST explicitly set `proxyUrl`, disable dangerous webview flags, and assign deterministic window labels bound to restricted capabilities.

Frontend window creation via `@tauri-apps/api/webviewWindow` or `@tauri-apps/api/webview` MUST explicitly set `proxyUrl`, disable dangerous webview flags, and assign deterministic window labels bound to restricted capabilities.

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 route communication between secondary/untrusted windows and the core backend through message-passing or structured parent-window proxies rather than granting direct IPC invoke permissions.

Services MUST route communication between secondary/untrusted windows and the core backend through message-passing or structured parent-window proxies rather than granting direct IPC invoke 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.
5

Components NEVER execute `@tauri-apps/api/core

Components NEVER execute `@tauri-apps/api/core::invoke` inside preview frames or secondary windows without verifying that the window label matches an authenticated, privileged execution 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.
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 Isolation & Sandboxing Standard critical for AI coding assistants?

Enforces strict capability scoping and explicit label sandboxing for dynamically spawned secondary webviews in Tauri 2.0. Prevents privilege escalation and remote code execution by ensuring dynamic windows, preview contexts, and untrusted frames cannot inherit wildcard native Rust IPC commands or system dialog access. 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 Wildcard Window Capabilities or Spawning Unrestricted WebviewWindows for Untrusted Content) 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 FRONTEND Rules

View all rules →
frontend
119

SolidStart 1.0 Server Functions & Async Boundaries Production Standard

SolidStart 1.0 relies on the Vinxi bundler to split `server$` closures into independent HTTP POST RPC endpoints. Direct lexical closure over client signals within `server$` scopes or failure to demarcate async boundaries with `<Suspense>` causes silent serialization failures, client-bundle secret leaks, and SSR hydration mismatches. Enforcing strict parameter passing, runtime input validation, and Solid async primitives maintains security and fine-grained reactivity across network boundaries.

frontend
119

Astro 5 Actions & Content Layer Production Standard

Enforces strict type safety and architectural correctness for Astro 5 Server Actions and the zero-waterfall Content Layer API. Prevents runtime contract mismatches, hydration mismatches, and unhandled mutation exceptions across dynamic and prerendered boundaries. Failure to follow these patterns leads to silent data fetching waterfalls, build-time cache corruptions, and unhandled server action exceptions.

frontend
51

Nuxt 4 Nitro Server Engine & Shared Directory Production Standard

Nuxt 4 enforces strict boundary segregation between client UI in the app/ directory, backend endpoints in server/, and universal contracts in shared/. Violating cross-boundary isolation or maintaining module-scoped state in Nitro server handlers causes catastrophic cross-request data corruption and hydration mismatches under concurrent production traffic. Architects must enforce request-isolated H3 event contexts, universal serialization schemas, and strict path-alias boundaries.

1 Rule in Stack

Tauri