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

Tauri 2.0 Mobile Granular IPC Capability Scoping & Zero-Trust Command Standard

Enforces strict capability-driven security architecture for Tauri 2.0 mobile targets across Android and iOS runtimes. Mandates explicit window/webview label isolation, cryptographically validated command payloads, and fine-grained runtime permission sets to prevent arbitrary native subsystem invocation from untrusted web contexts.

Prohibited Anti-Pattern: Wildcard IPC Allowlisting and Global Plugin Permissions in Mobile WebViews

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Mobile Granular IPC Capability Scoping & Zero-Trust Command Standard - Enforces strict capability-driven security architecture for Tauri 2.0 mobile targets across Android and iOS runtimes. Mandates explicit window/webview label isolation, cryptographically validated command payloads, and fine-grained runtime permission sets to prevent arbitrary native subsystem invocation from untrusted web contexts.
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-mobile-granular-ipc-capability-scoping-standard"
---

# Tauri 2.0 Mobile Granular IPC Capability Scoping & Zero-Trust Command Standard

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Wildcard IPC Allowlisting and Global Plugin Permissions in Mobile WebViews

## System Constraints
You are a Principal Security Architect enforcing the Tauri 2.0 Mobile Granular IPC Capability Scoping Standard. Mandate zero-trust communication between WebViews and mobile native layers. Enforce absolute command scoping, eliminate wildcard permissions (`*`), ensure strict validation of mobile security origins, and isolate background threads during mobile lifecycle hooks.

## Strict Guidelines
- Engineers MUST ALWAYS declare capability files inside `src-tauri/capabilities/` targeting specific mobile platforms via the `platforms` array (e.g., `['android', 'iOS']`).
- Engineers MUST NOT use wildcard permissions (`core:default`, `fs:default`, or `*:*`) in mobile capability manifests; every command invocation must define an exact, minimal permission string.
- Engineers MUST configure explicit window and webview targeting via the `windows` array in capability definitions, ensuring untrusted views cannot execute privileged native commands.
- Native commands MUST validate caller origins and session integrity using cryptographic or state-backed token verification inside Rust command handlers before invoking Android JNI or iOS Swift/Objective-C platform channels.
- Mobile bridge invocations SHOULD pass strongly typed, schema-validated DTOs parsed via Serde with `#[serde(deny_unknown_fields)]` to mitigate prototype pollution and injection attacks.
- Components NEVER execute raw `invoke()` calls using hardcoded strings without TypeScript type barriers generated from the corresponding Rust command definitions.

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

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Uses wildcard window targeting ('*') and generic default permission groups without platform filtering, exposing sensitive native biometric and filesystem interfaces to any webview context.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-capability",
  "description": "Insecure blanket permissions for mobile webview",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:allow-read-text-file",
    "biometric:default"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Explicitly restricts platform execution to Android and iOS, targets only the verified 'main' window, grants minimum viable granular permissions, and scopes filesystem access strictly to the dedicated app data token directory.
```json
{
  "$schema": "../gen/schemas/mobile-schema.json",
  "identifier": "mobile-secure-vault-capability",
  "description": "Scoped native biometric access for authenticated mobile views",
  "platforms": ["android", "iOS"],
  "windows": ["main"],
  "permissions": [
    "biometric:allow-authenticate",
    {
      "identifier": "fs:allow-read-text-file",
      "allow": [{
        "path": "$APP_DATA_DIR/secure_tokens/*"
      }]
    }
  ]
}
```

### Rust IPC Command with Mobile Context and Type Safety

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Lacks window context, fails to validate payload structure against injection, and lacks access controls, allowing any invoked script to trigger arbitrary native calls.
```rust
use tauri::command;

#[command]
pub fn execute_biometric_action(action: String) -> Result<String, String> {
    // Insecure: No origin validation, unparsed dynamic string, unbounded execution
    platform_specific_native_call(&action);
    Ok("Success".into())
}
```

#### Production Standard (Correct)
> **Standard**: Verifies caller window identity ('main'), validates cryptographic token entropy, and parses the request into a strictly-typed DTO rejecting unknown fields prior to native mobile bridge execution.
```rust
use serde::Deserialize;
use tauri::{command, AppHandle, Runtime, WebviewWindow};

#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct BiometricAuthRequest {
    pub prompt_message: String,
    pub fallback_title: Option<String>,
    pub challenge_token: String,
}

#[command]
pub async fn execute_biometric_action<R: Runtime>(
    app: AppHandle<R>,
    window: WebviewWindow<R>,
    payload: BiometricAuthRequest,
) -> Result<bool, String> {
    if window.label() != "main" {
        return Err("Unauthorized caller context: invalid window label".into());
    }
    
    // Validate cryptographic challenge format before calling native platform bridge
    if payload.challenge_token.len() < 32 {
        return Err("Cryptographic challenge validation failed: invalid entropy".into());
    }

    tauri_plugin_biometric::BiometricExt::authenticate(&app, &payload.prompt_message)
        .await
        .map(|res| res.is_authenticated())
        .map_err(|e| format!("Native subsystem failure: {e}"))
}
```

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 Mobile Granular IPC Capability Scoping & Zero-Trust Command Standard

Tauri 2.0 Mobile Granular IPC Capability Scoping & Zero-Trust Command Standard defines an industrial-grade behavioral standard for mobile engineering. Enforces strict capability-driven security architecture for Tauri 2.0 mobile targets across Android and iOS runtimes. Mandates explicit window/webview label isolation, cryptographically validated command payloads, and fine-grained runtime permission sets to prevent arbitrary native subsystem invocation from untrusted web contexts. 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 IPC Allowlisting and Global Plugin Permissions in Mobile WebViews 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 IPC Allowlisting and Global Plugin Permissions in Mobile WebViewsCritical
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 capability files inside `src-tauri/capabilities/` targeting specific mobile platforms via the `platforms` array (e.g., `['android', 'iOS']`).

Engineers MUST ALWAYS declare capability files inside `src-tauri/capabilities/` targeting specific mobile platforms via the `platforms` array (e.g., `['android', 'iOS']`).

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 (`core

Engineers MUST NOT use wildcard permissions (`core:default`, `fs:default`, or `*:*`) in mobile capability manifests; every command invocation must define an exact, minimal permission string.

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 configure explicit window and webview targeting via the `windows` array in capability definitions, ensuring untrusted views cannot execute privileged native commands.

Engineers MUST configure explicit window and webview targeting via the `windows` array in capability definitions, ensuring untrusted views cannot execute privileged native commands.

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

Native commands MUST validate caller origins and session integrity using cryptographic or state-backed token verification inside Rust command handlers before invoking Android JNI or iOS Swift/Objective-C platform channels.

Native commands MUST validate caller origins and session integrity using cryptographic or state-backed token verification inside Rust command handlers before invoking Android JNI or iOS Swift/Objective-C platform channels.

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

Mobile bridge invocations SHOULD pass strongly typed, schema-validated DTOs parsed via Serde with `#[serde(deny_unknown_fields)]` to mitigate prototype pollution and injection attacks.

Mobile bridge invocations SHOULD pass strongly typed, schema-validated DTOs parsed via Serde with `#[serde(deny_unknown_fields)]` to mitigate prototype pollution and injection attacks.

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

Components NEVER execute raw `invoke()` calls using hardcoded strings without TypeScript type barriers generated from the corresponding Rust command definitions.

Components NEVER execute raw `invoke()` calls using hardcoded strings without TypeScript type barriers generated from the corresponding Rust command 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.
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 Mobile Granular IPC Capability Scoping & Zero-Trust Command Standard critical for AI coding assistants?

Enforces strict capability-driven security architecture for Tauri 2.0 mobile targets across Android and iOS runtimes. Mandates explicit window/webview label isolation, cryptographically validated command payloads, and fine-grained runtime permission sets to prevent arbitrary native subsystem invocation from untrusted web contexts. 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 IPC Allowlisting and Global Plugin Permissions in Mobile WebViews) 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