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

Tauri 2.0 Granular IPC Capability Mapping and Webview Scope Pinning

Mandates explicit, least-privilege capability manifests and strict webview context targeting in Tauri 2.0 desktop and mobile shells. Forbids wildcard window targeting and permissive IPC command exposure to secondary or remote webview contexts to eliminate cross-origin privilege escalation and remote code execution vulnerabilities.

Prohibited Anti-Pattern: Permissive Wildcard Window Capabilities Permitting Arbitrary IPC Execution Across Multi-Webview Shells

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Granular IPC Capability Mapping and Webview Scope Pinning - Mandates explicit, least-privilege capability manifests and strict webview context targeting in Tauri 2.0 desktop and mobile shells. Forbids wildcard window targeting and permissive IPC command exposure to secondary or remote webview contexts to eliminate cross-origin privilege escalation and remote code execution vulnerabilities.
globs: 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-granular-ipc-capability-scope-pinning"
---

# Tauri 2.0 Granular IPC Capability Mapping and Webview Scope Pinning

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Permissive Wildcard Window Capabilities Permitting Arbitrary IPC Execution Across Multi-Webview Shells

## System Constraints
You are a Principal Security Architect specializing in Tauri 2.0 multi-webview architectures. You enforce strict capability-based access control, preventing cross-webview privilege escalation and insecure IPC exposure. Every IPC boundary must be scoped to specific window/webview labels, forbid wildcard selectors, and enforce input validation and domain pinning.

## Strict Guidelines
- Engineers MUST ALWAYS isolate high-privilege permissions (e.g., filesystem, shell, system notifications) to distinct capability files targeted strictly at the primary, trusted webview window label (e.g., 'main').
- Engineers MUST NOT use wildcard selectors ('*') in the 'windows' or 'webviews' arrays inside any Tauri 2.0 capability manifest.
- Code MUST explicitly validate the calling webview label and origin inside frontend invocation wrappers before dispatching Tauri IPC events or commands.
- Services MUST configure granular plugin scopes (e.g., restricting 'fs' access to specific AppData subdirectories instead of recursive base access) in capability permission files.
- Components NEVER instantiate secondary or external webviews (such as OAuth flows or third-party web content) with inherited default capabilities or unrestricted IPC access.

## Bad vs Good Implementations
### Secondary Webview Creation and IPC Invocation Safeguards

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Creating webviews without isolating their capability profiles allows external/secondary webviews to inherit global IPC privileges if capabilities use wildcard selectors ('*'). Invoking sensitive native operations without verifying context integrity exposes the host shell to command injection and unauthorized IPC invocation.
```typescript
import { WebviewWindow } from '@tauri-apps/api/webviewWindow';
import { invoke } from '@tauri-apps/api/core';

// ANTI-PATTERN: Spawning secondary webview with global access and invoking un-scoped commands
export async function openAuthModal(authUrl: string) {
  const webview = new WebviewWindow('auth-window', {
    url: authUrl,
    // Inherits global capability pool when capabilities use ["*"]
  });

  // Any webview context can execute arbitrary native commands without validation
  return await invoke('execute_system_command', { cmd: 'sync-tokens' });
}
```

#### Production Standard (Correct)
> **Standard**: Verifies that the calling webview strictly matches the authorized window label ('main') before spawning child windows or issuing native IPC invocations. Enforces origin verification for remote URLs and depends on a corresponding capability file in Tauri 2.0 that strictly binds 'plugin:auth|verify_and_sync' exclusively to the 'main' window.
```typescript
import { WebviewWindow } from '@tauri-apps/api/webviewWindow';
import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow';
import { invoke } from '@tauri-apps/api/core';

// PRODUCTION FIX: Pinned context verification and strict domain boundary constraints
const TRUSTED_WINDOW_LABEL = 'main' as const;

export async function openIsolatedAuthModal(authUrl: string): Promise<void> {
  const currentWindow = getCurrentWebviewWindow();
  if (currentWindow.label !== TRUSTED_WINDOW_LABEL) {
    throw new Error(`Security Violation: Unauthorized IPC caller '${currentWindow.label}'`);
  }

  const parsed = new URL(authUrl);
  if (parsed.protocol !== 'https:' || !parsed.hostname.endsWith('auth.production.com')) {
    throw new Error(`Security Violation: Untrusted target origin '${parsed.origin}'`);
  }

  // Window 'auth-window' must be explicitly mapped in capabilities/auth.json with zero native permissions
  new WebviewWindow('auth-window', {
    url: authUrl,
    incognito: true,
    acceptFirstMouse: false,
  });
}

export async function invokePrivilegedSync(authToken: string): Promise<{ success: boolean }> {
  const current = getCurrentWebviewWindow();
  if (current.label !== TRUSTED_WINDOW_LABEL) {
    throw new Error(`Privilege Escalation Blocked: Execution rejected for label '${current.label}'`);
  }

  return await invoke<{ success: boolean }>('plugin:auth|verify_and_sync', {
    token: authToken,
  });
}
```

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 Granular IPC Capability Mapping and Webview Scope Pinning

Tauri 2.0 Granular IPC Capability Mapping and Webview Scope Pinning defines an industrial-grade behavioral standard for mobile engineering. Mandates explicit, least-privilege capability manifests and strict webview context targeting in Tauri 2.0 desktop and mobile shells. Forbids wildcard window targeting and permissive IPC command exposure to secondary or remote webview contexts to eliminate cross-origin privilege escalation and remote code execution vulnerabilities. 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: Permissive Wildcard Window Capabilities Permitting Arbitrary IPC Execution Across Multi-Webview Shells 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 DriftPermissive Wildcard Window Capabilities Permitting Arbitrary IPC Execution Across Multi-Webview ShellsCritical
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 high-privilege permissions (e.g., filesystem, shell, system notifications) to distinct capability files targeted strictly at the primary, trusted webview window label (e.g., 'main').

Engineers MUST ALWAYS isolate high-privilege permissions (e.g., filesystem, shell, system notifications) to distinct capability files targeted strictly at the primary, trusted webview window label (e.g., 'main').

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 selectors ('*') in the 'windows' or 'webviews' arrays inside any Tauri 2.0 capability manifest.

Engineers MUST NOT use wildcard selectors ('*') in the 'windows' or 'webviews' arrays inside any Tauri 2.0 capability manifest.

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

Code MUST explicitly validate the calling webview label and origin inside frontend invocation wrappers before dispatching Tauri IPC events or commands.

Code MUST explicitly validate the calling webview label and origin inside frontend invocation wrappers before dispatching Tauri IPC events or 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

Services MUST configure granular plugin scopes (e.g., restricting 'fs' access to specific AppData subdirectories instead of recursive base access) in capability permission files.

Services MUST configure granular plugin scopes (e.g., restricting 'fs' access to specific AppData subdirectories instead of recursive base access) in capability permission files.

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 instantiate secondary or external webviews (such as OAuth flows or third-party web content) with inherited default capabilities or unrestricted IPC access.

Components NEVER instantiate secondary or external webviews (such as OAuth flows or third-party web content) with inherited default capabilities or unrestricted IPC access.

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 Granular IPC Capability Mapping and Webview Scope Pinning critical for AI coding assistants?

Mandates explicit, least-privilege capability manifests and strict webview context targeting in Tauri 2.0 desktop and mobile shells. Forbids wildcard window targeting and permissive IPC command exposure to secondary or remote webview contexts to eliminate cross-origin privilege escalation and remote code execution vulnerabilities. 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 (Permissive Wildcard Window Capabilities Permitting Arbitrary IPC Execution Across Multi-Webview Shells) 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