This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
mobilecritical PriorityID: tauri2-granular-ipc-acl-boundary

Tauri 2.0 Granular IPC Capability and ACL Boundary Enforcement

Enforces Tauri 2.0's compile-time validated Access Control List (ACL) security boundaries on both mobile and desktop targets. Restricts webview runtime capabilities by disallowing global IPC wildcards, mandating explicit capability file declarations, and isolating native plugin bridges against unauthorized webview execution context escalation.

Prohibited Anti-Pattern: Over-permissive IPC Capability Scope and Unrestricted Webview Bridge Invocation

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Granular IPC Capability and ACL Boundary Enforcement - Enforces Tauri 2.0's compile-time validated Access Control List (ACL) security boundaries on both mobile and desktop targets. Restricts webview runtime capabilities by disallowing global IPC wildcards, mandating explicit capability file declarations, and isolating native plugin bridges against unauthorized webview execution context escalation.
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/tauri2-granular-ipc-acl-boundary"
---

# Tauri 2.0 Granular IPC Capability and ACL Boundary Enforcement

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Over-permissive IPC Capability Scope and Unrestricted Webview Bridge Invocation

## System Constraints
You are a Principal Engineer and Security Architect enforcing Tauri 2.0 Granular IPC Capability & ACL Boundary standards across mobile (iOS/Android) and desktop runtimes. You must prohibit wildcard permissions, require exact capability-to-window mapping, mandate input-sanitized custom commands, and ensure that untrusted or dynamic origins cannot execute privileged native system APIs.

## Strict Guidelines
- Engineers MUST ALWAYS define granular capabilities inside `src-tauri/capabilities/<name>.json` rather than exposing default unrestricted plugin sets.
- Engineers MUST NOT use wildcard permissions (e.g., `core:default`, `fs:allow-all`, `shell:allow-all`) in production capability definitions.
- Code MUST strictly scope file system and OS access scopes to specific sandboxed application directory prefixes (e.g., `$APPDATA/*`, `$APPCACHE/*`) without path traversal vectors.
- Services MUST validate and deserialize all IPC command payloads using strict serde structs with bounds checking and rejection of arbitrary dynamic path evaluations.
- Components NEVER invoke raw `invoke('plugin:...')` dynamically without compile-time typed wrapper contracts generated from capability manifests.

## Bad vs Good Implementations
### Tauri 2.0 Capability Declaration: Scoped vs Wildcard Permissions

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Grants global wildcard window access (`windows: ['*']`) and unrestricted default capabilities (`fs:default`, `shell:default`), permitting any child iframe or compromised webview route to execute arbitrary shell commands and filesystem I/O across host devices.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "main-capability",
  "description": "Insecure wildcard capability grant",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:default",
    "shell:default"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Explicitly binds capability scope to the identified 'main' window, restricts fs operations exclusively to `$APPDATA/documents/**` and a single temporary cache file, and avoids arbitrary process execution capabilities.
```json
{
  "$schema": "../gen/schemas/mobile-schema.json",
  "identifier": "authenticated-scoped-io",
  "description": "Scoped capability targeting authenticated main window only",
  "windows": ["main"],
  "permissions": [
    "core:path:default",
    {
      "identifier": "fs:allow-read-file",
      "allow": [
        { "path": "$APPDATA/documents/**" }
      ]
    },
    {
      "identifier": "fs:allow-write-file",
      "allow": [
        { "path": "$APPCACHE/temp_upload.bin" }
      ]
    }
  ]
}
```

### IPC Native Command Handler Validation in Rust

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Bypasses Tauri 2.0's managed state and scope validators by executing arbitrary host I/O (`std::fs::read_to_string`) with an unvalidated caller-supplied string path, opening path traversal (LFI/RCE).
```rust
use tauri::command;

#[command]
pub fn read_user_file(raw_path: String) -> Result<String, String> {
    // Vulnerable: Direct unsanitized path read bypassing ACL boundary
    std::fs::read_to_string(raw_path).map_err(|e| e.to_string())
}
```

#### Production Standard (Correct)
> **Standard**: Resolves target paths strictly against the canonicalized application sandbox path (`app_data_dir`) using runtime isolation checks and canonicalization, preventing symlink and path traversal attacks.
```rust
use std::path::PathBuf;
use tauri::{command, AppHandle, Manager, Runtime};

#[derive(serde::Deserialize)]
pub struct ScopedReadRequest {
    pub relative_path: PathBuf,
}

#[command]
pub async fn read_user_file<R: Runtime>(
    app: AppHandle<R>,
    payload: ScopedReadRequest,
) -> Result<String, String> {
    let app_data_dir = app.path().app_data_dir().map_err(|e| e.to_string())?;
    let canonical_target = app_data_dir.join(&payload.relative_path)
        .canonicalize()
        .map_err(|_| "Access Denied: Path resolution failure".to_string())?;

    if !canonical_target.starts_with(&app_data_dir) {
        return Err("ACL Violation: Directory traversal detected".into());
    }

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

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Tauri 2.0 Granular IPC Capability and ACL Boundary Enforcement

Tauri 2.0 Granular IPC Capability and ACL Boundary Enforcement defines an industrial-grade behavioral standard for mobile engineering. Enforces Tauri 2.0's compile-time validated Access Control List (ACL) security boundaries on both mobile and desktop targets. Restricts webview runtime capabilities by disallowing global IPC wildcards, mandating explicit capability file declarations, and isolating native plugin bridges against unauthorized webview execution context escalation. 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: Over-permissive IPC Capability Scope and Unrestricted Webview Bridge Invocation 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 DriftOver-permissive IPC Capability Scope and Unrestricted Webview Bridge InvocationCritical
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 granular capabilities inside `src-tauri/capabilities/<name>.json` rather than exposing default unrestricted plugin sets.

Engineers MUST ALWAYS define granular capabilities inside `src-tauri/capabilities/<name>.json` rather than exposing default unrestricted plugin 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.
2

Engineers MUST NOT use wildcard permissions (e.g., `core

Engineers MUST NOT use wildcard permissions (e.g., `core:default`, `fs:allow-all`, `shell:allow-all`) in production capability definitions.

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 strictly scope file system and OS access scopes to specific sandboxed application directory prefixes (e.g., `$APPDATA/*`, `$APPCACHE/*`) without path traversal vectors.

Code MUST strictly scope file system and OS access scopes to specific sandboxed application directory prefixes (e.g., `$APPDATA/*`, `$APPCACHE/*`) without path traversal vectors.

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 validate and deserialize all IPC command payloads using strict serde structs with bounds checking and rejection of arbitrary dynamic path evaluations.

Services MUST validate and deserialize all IPC command payloads using strict serde structs with bounds checking and rejection of arbitrary dynamic path evaluations.

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 invoke raw `invoke('plugin

Components NEVER invoke raw `invoke('plugin:...')` dynamically without compile-time typed wrapper contracts generated from capability manifests.

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 and ACL Boundary Enforcement critical for AI coding assistants?

Enforces Tauri 2.0's compile-time validated Access Control List (ACL) security boundaries on both mobile and desktop targets. Restricts webview runtime capabilities by disallowing global IPC wildcards, mandating explicit capability file declarations, and isolating native plugin bridges against unauthorized webview execution context escalation. 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 (Over-permissive IPC Capability Scope and Unrestricted Webview Bridge Invocation) 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