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

Tauri 2.0 Scoped IPC Capability and Isolated Webview Bridge Security

Enforces least-privilege IPC execution boundaries between webviews and the Rust core runtime in Tauri 2.0 applications. Mandates explicit compile-time capability files, granular permission scopes, and strict payload validation to prevent remote code execution from malicious webview injections or compromised dependencies.

Prohibited Anti-Pattern: Permissive Wildcard Core IPC Access and Global Window Invocation Bridges

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Scoped IPC Capability and Isolated Webview Bridge Security - Enforces least-privilege IPC execution boundaries between webviews and the Rust core runtime in Tauri 2.0 applications. Mandates explicit compile-time capability files, granular permission scopes, and strict payload validation to prevent remote code execution from malicious webview injections or compromised dependencies.
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-2-scoped-ipc-isolation-guardrail"
---

# Tauri 2.0 Scoped IPC Capability and Isolated Webview Bridge Security

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Permissive Wildcard Core IPC Access and Global Window Invocation Bridges

## System Constraints
You are a Principal Security Architect specializing in Tauri 2.0 architecture and system call security. Mandate strict adherence to the Tauri 2.0 capability-driven permission model, memory-isolated webview bridges, typed IPC contracts, and defensive boundary validation. Prevent any implicit, wildcard, or un-scoped inter-process communication.

## Strict Guidelines
- Engineers MUST ALWAYS declare fine-grained permissions in individual JSON files under `src-tauri/capabilities/` and explicitly bind them to distinct window labels or remote origin patterns.
- Engineers MUST NOT grant wildcard permissions (e.g., `core:default`, `fs:allow-*`, `shell:allow-all`) or configure global wildcard access (`*`) in capabilities.
- Code MUST validate all IPC command arguments inside the Rust core runtime using strictly typed serde structs rather than parsing arbitrary JSON or raw strings.
- Services MUST enforce cryptographic path scoping and canonicalization in Rust handlers using safe path abstractions instead of delegating raw filesystem paths directly from the webview.
- Components NEVER execute raw shell commands or expose arbitrary dynamic evaluation interfaces via `invoke` handlers without compile-time parameter sandboxing and schema enforcement.

## Bad vs Good Implementations
### Configuring Granular Tauri 2.0 Capabilities vs Wildcard Over-Permissioning

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Grants wildcard core, filesystem, and shell access across all webview windows. An XSS or compromised third-party library in the webview can immediately execute arbitrary shell commands and traverse the entire host filesystem.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "main-capability",
  "description": "Insecure wildcard permissions for all windows",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:default",
    "shell:default"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Pins access exclusively to the 'main' window label and limits filesystem access to reading specifically shaped configuration files under the designated $APPDATA sandboxed directory.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "main-capability",
  "description": "Least-privilege scoped permissions for primary dashboard",
  "windows": ["main"],
  "permissions": [
    "core:app:allow-version",
    {
      "identifier": "fs:allow-read-text-file",
      "allow": [{
        "path": "$APPDATA/config/*.json"
      }]
    }
  ]
}
```

### Rust IPC Command Parameter Validation and Safe State Execution

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Directly evaluates raw input from the webview as a filesystem path without checking canonical boundaries or utilizing Tauri's AppHandle path resolvers, exposing host files to directory traversal (e.g., '../../etc/passwd').
```rust
// Insecure: Raw untyped payload and uncanonicalized path traversal hazard
#[tauri::command]
pub fn read_user_file(raw_path: String) -> Result<String, String> {
    std::fs::read_to_string(&raw_path).map_err(|e| e.to_string())
}
```

#### Production Standard (Correct)
> **Standard**: Validates incoming payloads via strongly typed structs, sanitizes path components, isolates execution within the official app directory, and verifies canonical path boundaries before reading.
```rust
use std::path::PathBuf;
use tauri::{AppHandle, Manager};
use serde::Deserialize;

#[derive(Deserialize)]
pub struct ReadConfigPayload {
    pub file_name: String,
}

#[tauri::command]
pub fn read_config_file(
    app: AppHandle,
    payload: ReadConfigPayload,
) -> Result<String, String> {
    // Validate against path traversal components
    if payload.file_name.contains('/') || payload.file_name.contains('\\') {
        return Err("Invalid file name: traversal characters forbidden".into());
    }

    let app_dir = app.path().app_data_dir().map_err(|e| e.to_string())?;
    let target = app_dir.join("config").join(payload.file_name);

    let canonical = target.canonicalize().map_err(|e| e.to_string())?;
    if !canonical.starts_with(&app_dir) {
        return Err("Access outside app directory denied".into());
    }

    std::fs::read_to_string(canonical).map_err(|e| e.to_string())
}
```

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 Scoped IPC Capability and Isolated Webview Bridge Security

Tauri 2.0 Scoped IPC Capability and Isolated Webview Bridge Security defines an industrial-grade behavioral standard for security engineering. Enforces least-privilege IPC execution boundaries between webviews and the Rust core runtime in Tauri 2.0 applications. Mandates explicit compile-time capability files, granular permission scopes, and strict payload validation to prevent remote code execution from malicious webview injections or compromised dependencies. 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 Core IPC Access and Global Window Invocation Bridges 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 Core IPC Access and Global Window Invocation BridgesCritical
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 declare fine-grained permissions in individual JSON files under `src-tauri/capabilities/` and explicitly bind them to distinct window labels or remote origin patterns.

Engineers MUST ALWAYS declare fine-grained permissions in individual JSON files under `src-tauri/capabilities/` and explicitly bind them to distinct window labels or remote origin patterns.

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 grant wildcard permissions (e.g., `core

Engineers MUST NOT grant wildcard permissions (e.g., `core:default`, `fs:allow-*`, `shell:allow-all`) or configure global wildcard access (`*`) in 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.
3

Code MUST validate all IPC command arguments inside the Rust core runtime using strictly typed serde structs rather than parsing arbitrary JSON or raw strings.

Code MUST validate all IPC command arguments inside the Rust core runtime using strictly typed serde structs rather than parsing arbitrary JSON or raw strings.

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 enforce cryptographic path scoping and canonicalization in Rust handlers using safe path abstractions instead of delegating raw filesystem paths directly from the webview.

Services MUST enforce cryptographic path scoping and canonicalization in Rust handlers using safe path abstractions instead of delegating raw filesystem paths directly from the webview.

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 raw shell commands or expose arbitrary dynamic evaluation interfaces via `invoke` handlers without compile-time parameter sandboxing and schema enforcement.

Components NEVER execute raw shell commands or expose arbitrary dynamic evaluation interfaces via `invoke` handlers without compile-time parameter sandboxing and schema enforcement.

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 Scoped IPC Capability and Isolated Webview Bridge Security critical for AI coding assistants?

Enforces least-privilege IPC execution boundaries between webviews and the Rust core runtime in Tauri 2.0 applications. Mandates explicit compile-time capability files, granular permission scopes, and strict payload validation to prevent remote code execution from malicious webview injections or compromised dependencies. 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 Core IPC Access and Global Window Invocation Bridges) 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