This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
mobilecritical PriorityID: tauri-2-granular-capability-permission-scoping

Tauri 2.0 Granular Capability Permission Scoping & IPC Isolation

Enforces compile-time privilege minimization and scoped IPC boundaries across native plugins to completely block arbitrary command execution from webviews. Tauri 2.0 capability manifests must restrict plugin commands to discrete JSON schema-validated scopes, rejecting wildcard permissions and monolithic execution contexts. All IPC invocations on iOS and Android targets must validate parameter schemas and origin contexts to prevent privilege escalation via webview compromise.

Prohibited Anti-Pattern: Monolithic Capability Wildcarding and Unscoped Native IPC Execution

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Granular Capability Permission Scoping & IPC Isolation - Enforces compile-time privilege minimization and scoped IPC boundaries across native plugins to completely block arbitrary command execution from webviews. Tauri 2.0 capability manifests must restrict plugin commands to discrete JSON schema-validated scopes, rejecting wildcard permissions and monolithic execution contexts. All IPC invocations on iOS and Android targets must validate parameter schemas and origin contexts to prevent privilege escalation via webview compromise.
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-granular-capability-permission-scoping"
---

# Tauri 2.0 Granular Capability Permission Scoping & IPC Isolation

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Monolithic Capability Wildcarding and Unscoped Native IPC Execution

## System Constraints
You are a Principal Security Architect enforcing Tauri 2.0 Granular Capability Permission Scoping on mobile and desktop runtimes. You must prohibit wildcard permissions ('*'), blanket plugin allowlists ('core:default', 'fs:default'), and unscoped native invoke boundaries. Enforce explicit capabilities definitions per window/webview label with path-restricted scopes and compile-time Rust command permission checks.

## Strict Guidelines
- Engineers MUST ALWAYS isolate capabilities into separate JSON/TOML manifest files inside `src-tauri/capabilities/` and assign them to explicit window labels.
- Engineers MUST NOT grant catch-all or default permissions such as `core:default`, `fs:allow-all`, or `shell:allow-execute` in production manifests.
- Engineers MUST ALWAYS scope filesystem and network plugins to explicit deterministic paths and endpoints using the `scope` configuration attribute.
- Custom Rust commands MUST validate typed payloads using `serde::Deserialize` and enforce application invariants before delegating to privileged native logic.
- Frontend IPC calls via `@tauri-apps/api/core` invoke() MUST ALWAYS use strictly typed request/response contracts and MUST NEVER execute arbitrary command names passed dynamically.
- Mobile targets (iOS/Android) MUST specify per-platform capability sets to prevent desktop-only permissions (such as process spawning or global shortcuts) from bundling into mobile binary assets.

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

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Grants global wildcard window access and carte-blanche defaults for filesystem, HTTP, and arbitrary shell command execution. An XSS or malicious dependency in the webview gains complete native code execution.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "main-capability",
  "description": "Insecure capability with wildcard permissions",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:default",
    "shell:allow-execute",
    "http:default"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Defines explicit window targeting, restricts the platform targets to mobile, and uses scoped permission objects restricting file read/write operations exclusively to subpaths inside $APPDATA/documents/.
```json
{
  "$schema": "../gen/schemas/mobile-schema.json",
  "identifier": "mobile-document-capability",
  "description": "Scoped filesystem access restricted strictly to app documents directory",
  "windows": ["main"],
  "platforms": ["iOS", "android"],
  "permissions": [
    "core:event:allow-listen",
    "core:event:allow-emit",
    {
      "identifier": "fs:allow-read-file",
      "allow": [{
        "path": "$APPDATA/documents/**"
      }]
    },
    {
      "identifier": "fs:allow-write-file",
      "allow": [{
        "path": "$APPDATA/documents/**"
      }]
    }
  ]
}
```

### Strict Frontend IPC Contract Invocation

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Exposing a generic pass-through invoke wrapper allows any compromised caller to query unlisted native plugins or arbitrary Tauri internal commands.
```typescript
import { invoke } from '@tauri-apps/api/core';

// ANTI-PATTERN: Dynamically invoking arbitrary native commands with untyped payloads
export async function executeNativePlugin(commandName: string, payload: Record<string, unknown>): Promise<unknown> {
  return await invoke(commandName, payload);
}
```

#### Production Standard (Correct)
> **Standard**: Enforces static command naming, strongly typed schemas, and pre-IPC sanitization preventing path traversal attempts before the Rust boundary is touched.
```typescript
import { invoke } from '@tauri-apps/api/core';

interface SecureDocumentReadRequest {
  readonly relativePath: string;
}

interface SecureDocumentReadResponse {
  readonly content: string;
  readonly checksumSha256: string;
}

export async function readScopedDocument(request: SecureDocumentReadRequest): Promise<SecureDocumentReadResponse> {
  // Invariant: Path traversal characters must be rejected before crossing IPC
  if (request.relativePath.includes('..') || request.relativePath.startsWith('/')) {
    throw new Error('SecurityError: Path traversal or absolute paths are strictly forbidden.');
  }
  return await invoke<SecureDocumentReadResponse>('read_document_scoped', {
    payload: request,
  });
}
```

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 Permission Scoping & IPC Isolation

Tauri 2.0 Granular Capability Permission Scoping & IPC Isolation defines an industrial-grade behavioral standard for mobile engineering. Enforces compile-time privilege minimization and scoped IPC boundaries across native plugins to completely block arbitrary command execution from webviews. Tauri 2.0 capability manifests must restrict plugin commands to discrete JSON schema-validated scopes, rejecting wildcard permissions and monolithic execution contexts. All IPC invocations on iOS and Android targets must validate parameter schemas and origin contexts to prevent privilege escalation via webview compromise. 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: Monolithic Capability Wildcarding and Unscoped Native IPC Execution 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 DriftMonolithic Capability Wildcarding and Unscoped Native IPC ExecutionCritical
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 capabilities into separate JSON/TOML manifest files inside `src-tauri/capabilities/` and assign them to explicit window labels.

Engineers MUST ALWAYS isolate capabilities into separate JSON/TOML manifest files inside `src-tauri/capabilities/` and assign them to explicit 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 catch-all or default permissions such as `core

Engineers MUST NOT grant catch-all or default permissions such as `core:default`, `fs:allow-all`, or `shell:allow-execute` in production 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.
3

Engineers MUST ALWAYS scope filesystem and network plugins to explicit deterministic paths and endpoints using the `scope` configuration attribute.

Engineers MUST ALWAYS scope filesystem and network plugins to explicit deterministic paths and endpoints using the `scope` configuration attribute.

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

Custom Rust commands MUST validate typed payloads using `serde

Custom Rust commands MUST validate typed payloads using `serde::Deserialize` and enforce application invariants before delegating to privileged native 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.
5

Frontend IPC calls via `@tauri-apps/api/core` invoke() MUST ALWAYS use strictly typed request/response contracts and MUST NEVER execute arbitrary command names passed dynamically.

Frontend IPC calls via `@tauri-apps/api/core` invoke() MUST ALWAYS use strictly typed request/response contracts and MUST NEVER execute arbitrary command names passed dynamically.

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

Mobile targets (iOS/Android) MUST specify per-platform capability sets to prevent desktop-only permissions (such as process spawning or global shortcuts) from bundling into mobile binary assets.

Mobile targets (iOS/Android) MUST specify per-platform capability sets to prevent desktop-only permissions (such as process spawning or global shortcuts) from bundling into mobile binary assets.

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 Permission Scoping & IPC Isolation critical for AI coding assistants?

Enforces compile-time privilege minimization and scoped IPC boundaries across native plugins to completely block arbitrary command execution from webviews. Tauri 2.0 capability manifests must restrict plugin commands to discrete JSON schema-validated scopes, rejecting wildcard permissions and monolithic execution contexts. All IPC invocations on iOS and Android targets must validate parameter schemas and origin contexts to prevent privilege escalation via webview compromise. 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 (Monolithic Capability Wildcarding and Unscoped Native IPC Execution) 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