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

Tauri 2.0 Native IPC Capability Scoping and Webview Origin Isolation

Enforces strict, least-privilege capability manifests and cryptographic webview origin isolation in Tauri 2.0 architectures. Prohibits wildcard plugin permissions, binds IPC commands to validated window labels and origins, and enforces granular resource scoping on all native boundaries.

Prohibited Anti-Pattern: Granting Wildcard Permissions or Exposing Native IPC Capabilities to Unvalidated Webview Contexts

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Native IPC Capability Scoping and Webview Origin Isolation - Enforces strict, least-privilege capability manifests and cryptographic webview origin isolation in Tauri 2.0 architectures. Prohibits wildcard plugin permissions, binds IPC commands to validated window labels and origins, and enforces granular resource scoping on all native boundaries.
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-ipc-capability-scoping-origin-isolation"
---

# Tauri 2.0 Native IPC Capability Scoping and Webview Origin Isolation

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Granting Wildcard Permissions or Exposing Native IPC Capabilities to Unvalidated Webview Contexts

## System Constraints
You are a Principal Security Architect enforcing the Tauri 2.0 Native IPC Capability Scoping and Origin Isolation Standard. Tauri 2.0 replaces coarse allowlists with an Access Control List (ACL) capability framework. You MUST mandate that every native IPC command and plugin API is constrained to explicit window labels, cryptographically scoped resource paths, and verified local origins. Deny any configuration granting global wildcards, unisolated remote URLs, or unvalidated frontend commands.

## Strict Guidelines
- Engineers MUST ALWAYS define fine-grained capabilities within `src-tauri/capabilities/*.json` targeting specific window labels rather than relying on default broad access.
- Engineers MUST NOT use wildcard permissions such as `fs:allow-all`, `shell:allow-all`, or broad scope declarations (`*`) in production capability sets.
- Capability manifests MUST explicitly restrict filesystem and network scopes to designated application directories (e.g., `$APPDATA/*`, `$APPCACHE/*`) using explicit allow/deny ACL objects.
- Webviews hosting external or remote URLs MUST NEVER be granted access to native core capabilities or sensitive system plugins (`fs`, `shell`, `process`).
- Custom Rust IPC commands exposed via `tauri::generate_handler![]` MUST validate the caller window context (`tauri::WebviewWindow`) and reject unauthorized window labels before executing privileged logic.
- Frontend invoke calls MUST target typed, explicit command interfaces, and codebases SHOULD enforce Content Security Policy (CSP) headers in `tauri.conf.json` that restrict scripts strictly to authenticated origins.

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

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Grants wildcard permissions across all windows ('*') and includes unrestricted filesystem read/write and shell execution capabilities, allowing any webview context to execute destructive OS-level operations.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "main-capability",
  "description": "Insecure capability with wildcard access",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:default",
    "fs:allow-read-all",
    "fs:allow-write-all",
    "shell:default"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Binds permissions strictly to the 'main' window label, eliminates arbitrary shell/fs execution, and restricts read/write operations precisely to structured files within the application's secure data directory.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "main-window-storage-restricted",
  "description": "Least-privilege capability strictly bound to main window and app data directory",
  "windows": ["main"],
  "permissions": [
    "core:default",
    {
      "identifier": "fs:allow-read-text-file",
      "allow": [{
        "path": "$APPDATA/reports/*"
      }]
    },
    {
      "identifier": "fs:allow-write-text-file",
      "allow": [{
        "path": "$APPDATA/reports/*.json"
      }]
    }
  ]
}
```

### Rust Custom IPC Command Context and Window Verification

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The Rust command blindly trusts frontend input parameters for filesystem destinations without checking caller window authorization or path boundaries, opening the system to path traversal and arbitrary file overwrite attacks.
```typescript
// Rust Command: #[tauri::command]
// pub async fn export_diagnostic_logs(target_path: String) -> Result<(), String> {
//     std::fs::write(target_path, "diagnostic_payload").map_err(|e| e.to_string())
// }

// Frontend TypeScript invocation without validation:
import { invoke } from '@tauri-apps/api/core';

export async function runDiagnostics(userPath: string): Promise<void> {
  // Insecure: Invoking arbitrary path writes from uncontrolled caller context
  await invoke('export_diagnostic_logs', { targetPath: userPath });
}
```

#### Production Standard (Correct)
> **Standard**: Validates the caller's WebviewWindow label in the native backend, sanitizes input to prevent path traversal, and resolves filesystem operations strictly against the isolated application data directory.
```typescript
// Rust Command: #[tauri::command]
// pub async fn export_diagnostic_logs(
//     app: tauri::AppHandle,
//     window: tauri::WebviewWindow,
//     filename: String
// ) -> Result<(), String> {
//     if window.label() != "main" {
//         return Err("Unauthorized caller window".into());
//     }
//     let safe_filename = std::path::Path::new(&filename)
//         .file_name()
//         .ok_or("Invalid filename")?;
//     let app_data = app.path().app_data_dir().map_err(|e| e.to_string())?;
//     let destination = app_data.join("logs").join(safe_filename);
//     std::fs::create_dir_all(app_data.join("logs")).map_err(|e| e.to_string())?;
//     std::fs::write(destination, "diagnostic_payload").map_err(|e| e.to_string())
// }

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

export async function runDiagnostics(safeFileName: string): Promise<void> {
  // Verified: Only sanitized file names are passed; native backend resolves path and window
  if (!/^[a-zA-Z0-9_-]+\.log$/.test(safeFileName)) {
    throw new Error('Invalid diagnostic filename format.');
  }
  await invoke('export_diagnostic_logs', { filename: safeFileName });
}
```

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 Native IPC Capability Scoping and Webview Origin Isolation

Tauri 2.0 Native IPC Capability Scoping and Webview Origin Isolation defines an industrial-grade behavioral standard for security engineering. Enforces strict, least-privilege capability manifests and cryptographic webview origin isolation in Tauri 2.0 architectures. Prohibits wildcard plugin permissions, binds IPC commands to validated window labels and origins, and enforces granular resource scoping on all native boundaries. 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: Granting Wildcard Permissions or Exposing Native IPC Capabilities to Unvalidated Webview Contexts 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 DriftGranting Wildcard Permissions or Exposing Native IPC Capabilities to Unvalidated Webview ContextsCritical
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 define fine-grained capabilities within `src-tauri/capabilities/*.json` targeting specific window labels rather than relying on default broad access.

Engineers MUST ALWAYS define fine-grained capabilities within `src-tauri/capabilities/*.json` targeting specific window labels rather than relying on default broad 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.
2

Engineers MUST NOT use wildcard permissions such as `fs

Engineers MUST NOT use wildcard permissions such as `fs:allow-all`, `shell:allow-all`, or broad scope declarations (`*`) in production capability sets.

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

Capability manifests MUST explicitly restrict filesystem and network scopes to designated application directories (e.g., `$APPDATA/*`, `$APPCACHE/*`) using explicit allow/deny ACL objects.

Capability manifests MUST explicitly restrict filesystem and network scopes to designated application directories (e.g., `$APPDATA/*`, `$APPCACHE/*`) using explicit allow/deny ACL objects.

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

Webviews hosting external or remote URLs MUST NEVER be granted access to native core capabilities or sensitive system plugins (`fs`, `shell`, `process`).

Webviews hosting external or remote URLs MUST NEVER be granted access to native core capabilities or sensitive system plugins (`fs`, `shell`, `process`).

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

Custom Rust IPC commands exposed via `tauri

Custom Rust IPC commands exposed via `tauri::generate_handler![]` MUST validate the caller window context (`tauri::WebviewWindow`) and reject unauthorized window labels before executing privileged logic.

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

Frontend invoke calls MUST target typed, explicit command interfaces, and codebases SHOULD enforce Content Security Policy (CSP) headers in `tauri.conf.json` that restrict scripts strictly to authenticated origins.

Frontend invoke calls MUST target typed, explicit command interfaces, and codebases SHOULD enforce Content Security Policy (CSP) headers in `tauri.conf.json` that restrict scripts strictly to authenticated origins.

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 Native IPC Capability Scoping and Webview Origin Isolation critical for AI coding assistants?

Enforces strict, least-privilege capability manifests and cryptographic webview origin isolation in Tauri 2.0 architectures. Prohibits wildcard plugin permissions, binds IPC commands to validated window labels and origins, and enforces granular resource scoping on all native boundaries. 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 (Granting Wildcard Permissions or Exposing Native IPC Capabilities to Unvalidated Webview Contexts) 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.

1 Rule in Stack

Tauri