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

Tauri 2.0 Granular Mobile IPC Scope Capability Standard

Mandates cryptographically enforced capability schemas and granular command permissions across Tauri 2.0 IPC boundaries on iOS and Android. Prohibits global command enablement, wildcard file/network access scopes, and unvalidated WebView invocations across mobile target platforms. Invariant enforcement guarantees zero-trust boundaries between client-side JavaScript execution and the native Rust backend.

Prohibited Anti-Pattern: Overprivileged Mobile Capabilities and Unscoped IPC Invocations Across Native Boundaries

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Granular Mobile IPC Scope Capability Standard - Mandates cryptographically enforced capability schemas and granular command permissions across Tauri 2.0 IPC boundaries on iOS and Android. Prohibits global command enablement, wildcard file/network access scopes, and unvalidated WebView invocations across mobile target platforms. Invariant enforcement guarantees zero-trust boundaries between client-side JavaScript execution and the native Rust backend.
globs: src-tauri/src/**/*.rs, src-tauri/capabilities/**/*.json, src-tauri/tauri.conf.json, src/**/*.ts, src/**/*.tsx
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tauri-v2-granular-ipc-scope-capability-standard"
---

# Tauri 2.0 Granular Mobile IPC Scope Capability Standard

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Overprivileged Mobile Capabilities and Unscoped IPC Invocations Across Native Boundaries

## System Constraints
You are a Principal Software Architect enforcing the Tauri 2.0 Granular IPC Scope Capability Standard. You must rigorously reject any permissive, wildcard, or default-allow capability configurations (`core:default`, `*:*`, or root filesystem scopes) on mobile targets (iOS and Android). Ensure all Tauri commands exposed via `invoke()` enforce explicit argument validation, scope boundaries, and context-aware origin verification in Rust. Mandate distinct capability definitions tailored per mobile window and platform context.

## Strict Guidelines
- Engineers MUST ALWAYS isolate mobile capabilities into dedicated JSON/TOML manifests inside `src-tauri/capabilities/` scoped strictly to target platform identifiers (e.g., `"platforms": ["iOS", "android"]`).
- Engineers MUST NEVER permit global command wildcards or assign the unrestricted `core:default` capability without explicit, audited permission sets in mobile distributions.
- Engineers MUST ALWAYS declare strict parameter scopes (e.g., `fs:scope` limited to `$APPDATA` or `$RESOURCE`) rather than enabling arbitrary filesystem access for mobile runtimes.
- Rust command handlers MUST ALWAYS validate payload constraints and state guarantees using strongly typed Tauri `State` and deserialization targets prior to invoking mobile OS APIs via JNI/Obj-C bridges.
- Frontend IPC calls MUST ALWAYS use typed wrapper functions wrapping `@tauri-apps/api/core.invoke` with compile-time checked argument signatures to prevent payload tampering and prototype injection.

## Bad vs Good Implementations
### Mobile IPC Capability Configuration (Anti-Pattern vs Strict Scoping)

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Assigning global default bundles and wildcards ('*') grants full filesystem and HTTP access to the WebView, completely bypassing zero-trust sandboxing on mobile platforms.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-capability-all",
  "description": "Enables all plugins and commands with wildcards for mobile",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:default",
    "http:default"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Restricts capability permissions exclusively to iOS and Android, targets only the 'main' window, scopes file reads strictly to '$APPDATA/secure_cache/**', and explicitly enumerates permissions.
```json
{
  "$schema": "../gen/schemas/mobile-schema.json",
  "identifier": "mobile-restricted-vault-capability",
  "description": "Enforces granular least-privilege IPC access for mobile encrypted cache",
  "windows": ["main"],
  "platforms": ["iOS", "android"],
  "permissions": [
    "core:path:default",
    {
      "identifier": "fs:allow-read-text-file",
      "allow": [
        {
          "path": "$APPDATA/secure_cache/**"
        }
      ]
    },
    "secure-store:allow-read-key"
  ]
}
```

### Tauri Command Definition with Scoped Validation in Rust

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The command accepts arbitrary string paths without validating app-data isolation, allowing path traversal attacks from compromised WebView components.
```rust
// Overly permissive command with unsanitized native bridge call
#[tauri::command]
pub fn read_mobile_token(path: String) -> Result<String, String> {
    // Direct filesystem read without checking caller window, scope, or platform constraints
    std::fs::read_to_string(path).map_err(|e| e.to_string())
}
```

#### Production Standard (Correct)
> **Standard**: Validates payload alphanumeric constraints, constructs a canonical path rooted strictly inside app data storage, and verifies boundary containment before disk operations.
```rust
use tauri::{command, AppHandle, Manager, Runtime};
use std::path::PathBuf;

#[derive(serde::Deserialize)]
pub struct TokenFetchRequest {
    pub token_identifier: String,
}

#[command]
pub async fn read_mobile_token<R: Runtime>(
    app: AppHandle<R>,
    payload: TokenFetchRequest,
) -> Result<String, String> {
    // Validate identifier format to prevent traversal
    if !payload.token_identifier.chars().all(|c| c.is_ascii_alphanumeric() || c == '_') {
        return Err("Invalid token identifier format".into());
    }

    let app_dir = app.path().app_data_dir().map_err(|e| e.to_string())?;
    let safe_path: PathBuf = app_dir.join("tokens").join(format!("{}.vault", payload.token_identifier));

    if !safe_path.starts_with(&app_dir) {
        return Err("Security Violation: Path traversal detected".into());
    }

    tokio::fs::read_to_string(safe_path)
        .await
        .map_err(|e| format!("Failed to read secure token: {}", e))
}
```

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Tauri 2.0 Granular Mobile IPC Scope Capability Standard

Tauri 2.0 Granular Mobile IPC Scope Capability Standard defines an industrial-grade behavioral standard for mobile engineering. Mandates cryptographically enforced capability schemas and granular command permissions across Tauri 2.0 IPC boundaries on iOS and Android. Prohibits global command enablement, wildcard file/network access scopes, and unvalidated WebView invocations across mobile target platforms. Invariant enforcement guarantees zero-trust boundaries between client-side JavaScript execution and the native Rust backend. 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: Overprivileged Mobile Capabilities and Unscoped IPC Invocations Across Native Boundaries 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 DriftOverprivileged Mobile Capabilities and Unscoped IPC Invocations Across Native BoundariesCritical
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 mobile capabilities into dedicated JSON/TOML manifests inside `src-tauri/capabilities/` scoped strictly to target platform identifiers (e.g., `"platforms"

Engineers MUST ALWAYS isolate mobile capabilities into dedicated JSON/TOML manifests inside `src-tauri/capabilities/` scoped strictly to target platform identifiers (e.g., `"platforms": ["iOS", "android"]`).

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 NEVER permit global command wildcards or assign the unrestricted `core

Engineers MUST NEVER permit global command wildcards or assign the unrestricted `core:default` capability without explicit, audited permission sets in mobile distributions.

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 declare strict parameter scopes (e.g., `fs

Engineers MUST ALWAYS declare strict parameter scopes (e.g., `fs:scope` limited to `$APPDATA` or `$RESOURCE`) rather than enabling arbitrary filesystem access for mobile runtimes.

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

Rust command handlers MUST ALWAYS validate payload constraints and state guarantees using strongly typed Tauri `State` and deserialization targets prior to invoking mobile OS APIs via JNI/Obj-C bridges.

Rust command handlers MUST ALWAYS validate payload constraints and state guarantees using strongly typed Tauri `State` and deserialization targets prior to invoking mobile OS APIs via JNI/Obj-C bridges.

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 MUST ALWAYS use typed wrapper functions wrapping `@tauri-apps/api/core.invoke` with compile-time checked argument signatures to prevent payload tampering and prototype injection.

Frontend IPC calls MUST ALWAYS use typed wrapper functions wrapping `@tauri-apps/api/core.invoke` with compile-time checked argument signatures to prevent payload tampering and prototype injection.

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 Mobile IPC Scope Capability Standard critical for AI coding assistants?

Mandates cryptographically enforced capability schemas and granular command permissions across Tauri 2.0 IPC boundaries on iOS and Android. Prohibits global command enablement, wildcard file/network access scopes, and unvalidated WebView invocations across mobile target platforms. Invariant enforcement guarantees zero-trust boundaries between client-side JavaScript execution and the native Rust backend. 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 (Overprivileged Mobile Capabilities and Unscoped IPC Invocations Across Native Boundaries) 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