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

Tauri 2.0 Granular Capability-Scoped IPC Channel Isolation

Enforces Tauri 2.0 compile-time capability isolation to strictly restrict mobile OS-level API bridge commands. Guarantees that untrusted webview contexts and cross-origin mobile scripts cannot invoke unauthorized host OS interfaces or execute arbitrary native procedures. Eliminates privilege escalation vectors caused by wildcard permissions and unsegmented window capabilities.

Prohibited Anti-Pattern: Over-privileged IPC bridges exposing OS-level shell, filesystem, and native APIs via unsegmented wildcard capabilities.

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Granular Capability-Scoped IPC Channel Isolation - Enforces Tauri 2.0 compile-time capability isolation to strictly restrict mobile OS-level API bridge commands. Guarantees that untrusted webview contexts and cross-origin mobile scripts cannot invoke unauthorized host OS interfaces or execute arbitrary native procedures. Eliminates privilege escalation vectors caused by wildcard permissions and unsegmented window capabilities.
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-capability-ipc-isolation-guardrail"
---

# Tauri 2.0 Granular Capability-Scoped IPC Channel Isolation

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Over-privileged IPC bridges exposing OS-level shell, filesystem, and native APIs via unsegmented wildcard capabilities.

## System Constraints
You are a Principal Security Architect enforcing Tauri 2.0 Capability-Scoped IPC Channel Isolation on mobile platforms. You must ensure that all native command bridges, OS plugins, and window capabilities are explicitly constrained to least-privilege compile-time capability manifests. Under no circumstances should wildcards, default-allow patterns, or untyped cross-origin invoke channels be introduced.

## Strict Guidelines
- Engineers MUST ALWAYS declare isolated capability configuration files in `src-tauri/capabilities/` targeting specific window labels rather than relying on global defaults.
- Engineers MUST NOT use wildcard permissions (`*` or unconstrained plugin sets like `fs:default`) in mobile capabilities.
- Code SHOULD enforce strict path and action scoping for native subsystems (e.g., restricting `fs` scopes to `$APPDATA` or `$RESOURCE` paths).
- Services MUST isolate remote or dynamic webview origins from critical native commands by explicitly omitting sensitive capabilities for untrusted window labels.
- Components NEVER execute raw `invoke` calls with unvalidated, dynamically generated command names in frontend code.

## Bad vs Good Implementations
### Tauri 2.0 Mobile Capability Definition: Wildcard vs Granular IPC Scope

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Assigning global wildcards (`*`) to windows and granting broad access scopes (`fs:allow-all`, `shell:default`) permits any script running inside a webview container to execute arbitrary OS commands and access the full mobile filesystem.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-capability",
  "description": "Broad access capability for mobile view",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:allow-all",
    "shell:default"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Restricts capability attachment strictly to the 'main' window label, explicitly declares fine-grained permission identifiers, and restricts file read access exclusively to a sandboxed app-data cache path.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-capability-scoped",
  "description": "Least-privilege capability scoped to primary mobile webview",
  "windows": ["main"],
  "permissions": [
    "core:event:allow-listen",
    "core:event:allow-emit",
    {
      "identifier": "fs:allow-read-file",
      "allow": [
        {
          "path": "$APPDATA/cache/**"
        }
      ]
    }
  ]
}
```

### Frontend IPC Invocations: Untyped Dynamic Invocation vs Type-Safe Bridge Contract

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Exposing an unrestricted dynamic `invoke` wrapper allows injected client-side scripts to probe and execute any host command permissible under the active capability.
```typescript
import { invoke } from '@tauri-apps/api/core';

// Flaw: Arbitrary dynamic command invocation directly exposed to execution
export async function executeNativeBridge(commandName: string, payload: unknown) {
  return await invoke(commandName, { payload });
}
```

#### Production Standard (Correct)
> **Standard**: Defines an explicit, non-dynamic IPC bridge contract, enforcing strict input regex sanitation before passing parameters across the Tauri FFI boundary.
```typescript
import { invoke } from '@tauri-apps/api/core';

interface SafeCacheReadPayload {
  fileName: string;
}

// Safe: Bounded, compile-time verified command dispatch with strict parameter validation
export async function readSandboxedCache(payload: SafeCacheReadPayload): Promise<string> {
  if (!/^[a-zA-Z0-9_-]+\.json$/.test(payload.fileName)) {
    throw new Error('Invalid file identifier specified');
  }
  return await invoke<string>('plugin:cache|read_entry', { fileName: payload.fileName });
}
```

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 Granular Capability-Scoped IPC Channel Isolation

Tauri 2.0 Granular Capability-Scoped IPC Channel Isolation defines an industrial-grade behavioral standard for mobile engineering. Enforces Tauri 2.0 compile-time capability isolation to strictly restrict mobile OS-level API bridge commands. Guarantees that untrusted webview contexts and cross-origin mobile scripts cannot invoke unauthorized host OS interfaces or execute arbitrary native procedures. Eliminates privilege escalation vectors caused by wildcard permissions and unsegmented window capabilities. 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-privileged IPC bridges exposing OS-level shell, filesystem, and native APIs via unsegmented wildcard capabilities. 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-privileged IPC bridges exposing OS-level shell, filesystem, and native APIs via unsegmented wildcard capabilities.Critical
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 isolated capability configuration files in `src-tauri/capabilities/` targeting specific window labels rather than relying on global defaults.

Engineers MUST ALWAYS declare isolated capability configuration files in `src-tauri/capabilities/` targeting specific window labels rather than relying on global defaults.

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 (`*` or unconstrained plugin sets like `fs

Engineers MUST NOT use wildcard permissions (`*` or unconstrained plugin sets like `fs:default`) in mobile 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 SHOULD enforce strict path and action scoping for native subsystems (e.g., restricting `fs` scopes to `$APPDATA` or `$RESOURCE` paths).

Code SHOULD enforce strict path and action scoping for native subsystems (e.g., restricting `fs` scopes to `$APPDATA` or `$RESOURCE` 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

Services MUST isolate remote or dynamic webview origins from critical native commands by explicitly omitting sensitive capabilities for untrusted window labels.

Services MUST isolate remote or dynamic webview origins from critical native commands by explicitly omitting sensitive capabilities for untrusted 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.
5

Components NEVER execute raw `invoke` calls with unvalidated, dynamically generated command names in frontend code.

Components NEVER execute raw `invoke` calls with unvalidated, dynamically generated command names in frontend code.

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 Capability-Scoped IPC Channel Isolation critical for AI coding assistants?

Enforces Tauri 2.0 compile-time capability isolation to strictly restrict mobile OS-level API bridge commands. Guarantees that untrusted webview contexts and cross-origin mobile scripts cannot invoke unauthorized host OS interfaces or execute arbitrary native procedures. Eliminates privilege escalation vectors caused by wildcard permissions and unsegmented window capabilities. 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-privileged IPC bridges exposing OS-level shell, filesystem, and native APIs via unsegmented wildcard capabilities.) 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