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

Tauri 2.0 Granular IPC Capability & Scoped Permission Contract

Enforces strict compile-time remote procedure call capability binding and path/process scoping in Tauri 2.0. Eliminates arbitrary command execution, directory traversal, and unauthorized system access resulting from compromised or injected WebView scripts.

Prohibited Anti-Pattern: Wildcard Plugin Permissions and Unscoped Dynamic Shell/FS Invocations

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Granular IPC Capability & Scoped Permission Contract - Enforces strict compile-time remote procedure call capability binding and path/process scoping in Tauri 2.0. Eliminates arbitrary command execution, directory traversal, and unauthorized system access resulting from compromised or injected WebView scripts.
globs: src-tauri/capabilities/**/*.json, src-tauri/capabilities/**/*.toml, 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-granular-ipc-capability-contract"
---

# Tauri 2.0 Granular IPC Capability & Scoped Permission Contract

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Wildcard Plugin Permissions and Unscoped Dynamic Shell/FS Invocations

## System Constraints
You are a Principal Security Architect enforcing the Tauri 2.0 Security and Capability Contract. Tauri 2.0 replaces monolithic allowlists with granular compile-time capabilities, access control lists (ACLs), and scopes. You must strictly disallow wildcard permissions, raw shell execution primitives with caller-controlled arguments, and unrestricted filesystem access from WebView contexts. Mandate that every capability file strictly restricts target windows, permissions, and directory/executable scopes. Ensure all frontend-to-backend IPC passes through custom, validated Rust commands rather than direct unconstrained plugin calls.

## Strict Guidelines
- Engineers MUST ALWAYS isolate permissions into modular capability files under `src-tauri/capabilities/` mapped explicitly to declared window labels.
- Engineers MUST NOT grant wildcard or umbrella permissions such as `fs:default`, `shell:default`, `shell:allow-open`, or unconstrained `shell:allow-execute`.
- Filesystem permissions MUST define strict path scopes using Tauri path variables (e.g., `["$APPDATA/exports/*"]`) rather than arbitrary system paths.
- Shell executions MUST NEVER accept arbitrary shell strings (`sh -c`, `cmd.exe /c`); all external binaries must be registered with exact binary names and rigid argument schemas.
- Frontend components MUST NEVER invoke dangerous system operations directly via generic plugin APIs; all sensitive actions must be encapsulated within bespoke, typed `#[tauri::command]` handlers that validate all inputs in Rust.

## Bad vs Good Implementations
### Tauri 2.0 Capability and Safe Typed IPC Invariant

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Directly exposing raw shell execution with dynamic arguments and arbitrary filesystem writes from the frontend invalidates Tauri's process isolation model. If the WebView context is compromised via XSS or dependency poisoning, the attacker achieves arbitrary command execution.
```typescript
// BAD: Direct execution via generic shell plugin with attacker-controllable arguments
import { Command } from '@tauri-apps/plugin-shell';
import { writeFile, BaseDirectory } from '@tauri-apps/plugin-fs';

export async function runUserBackup(outputPath: string, scriptArgs: string) {
  // Anti-pattern: Relies on unrestricted fs:default or shell:all capabilities.
  // An XSS vulnerability allows full remote code execution and arbitrary disk overwrites.
  await writeFile(outputPath, new Uint8Array([1, 2, 3]), {
    baseDir: BaseDirectory.Home,
  });

  const cmd = Command.create('run-backup-tool', ['--custom-exec', scriptArgs]);
  return await cmd.execute();
}
```

#### Production Standard (Correct)
> **Standard**: Bypasses frontend shell and filesystem plugin exposure. The action is mediated by a custom Rust command registered within a dedicated Tauri 2.0 capability file that restricts permissions to explicit windows and validated file paths.
```typescript
// GOOD: Strongly typed IPC with domain-specific Rust command and scoped capability
import { invoke } from '@tauri-apps/api/core';

interface BackupResult {
  readonly success: boolean;
  readonly exportPath: string;
  readonly checksum: string;
}

export async function runUserBackup(reportId: string): Promise<BackupResult> {
  // Invariant: The frontend passes only business identifiers to an audited Rust command.
  // Rust validates the reportId format, resolves the exact file path within $APPDATA/backups,
  // and executes only pre-configured binaries without dynamic command-line injection.
  return await invoke<BackupResult>('create_secure_backup', {
    payload: {
      reportId: reportId.trim(),
    },
  });
}
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Tauri 2.0 Granular IPC Capability & Scoped Permission Contract

Tauri 2.0 Granular IPC Capability & Scoped Permission Contract defines an industrial-grade behavioral standard for security engineering. Enforces strict compile-time remote procedure call capability binding and path/process scoping in Tauri 2.0. Eliminates arbitrary command execution, directory traversal, and unauthorized system access resulting from compromised or injected WebView scripts. 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 Plugin Permissions and Unscoped Dynamic Shell/FS Invocations 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 Plugin Permissions and Unscoped Dynamic Shell/FS InvocationsCritical
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 permissions into modular capability files under `src-tauri/capabilities/` mapped explicitly to declared window labels.

Engineers MUST ALWAYS isolate permissions into modular capability files under `src-tauri/capabilities/` mapped explicitly to declared window labels.

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 or umbrella permissions such as `fs

Engineers MUST NOT grant wildcard or umbrella permissions such as `fs:default`, `shell:default`, `shell:allow-open`, or unconstrained `shell:allow-execute`.

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

Filesystem permissions MUST define strict path scopes using Tauri path variables (e.g., `["$APPDATA/exports/*"]`) rather than arbitrary system paths.

Filesystem permissions MUST define strict path scopes using Tauri path variables (e.g., `["$APPDATA/exports/*"]`) rather than arbitrary system paths.

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

Shell executions MUST NEVER accept arbitrary shell strings (`sh -c`, `cmd.exe /c`)

Shell executions MUST NEVER accept arbitrary shell strings (`sh -c`, `cmd.exe /c`); all external binaries must be registered with exact binary names and rigid argument schemas.

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

Frontend components MUST NEVER invoke dangerous system operations directly via generic plugin APIs

Frontend components MUST NEVER invoke dangerous system operations directly via generic plugin APIs; all sensitive actions must be encapsulated within bespoke, typed `#[tauri::command]` handlers that validate all inputs in Rust.

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 & Scoped Permission Contract critical for AI coding assistants?

Enforces strict compile-time remote procedure call capability binding and path/process scoping in Tauri 2.0. Eliminates arbitrary command execution, directory traversal, and unauthorized system access resulting from compromised or injected WebView scripts. 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 Plugin Permissions and Unscoped Dynamic Shell/FS Invocations) 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