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

Tauri 2.0 Mobile IPC Capability Sandboxing & Privilege Escalation Guardrail

Enforces Tauri 2.0 granular capability definitions and compile-time Access Control Lists (ACLs) to mitigate webview-to-native privilege escalation. Guarantees that every IPC invoke call maps to an explicitly scoped capability manifest, forbidding global allowlists and unvalidated command execution across mobile webview boundaries.

Prohibited Anti-Pattern: Pervasive IPC Permission Grants and Wildcard Capability Mapping

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Mobile IPC Capability Sandboxing & Privilege Escalation Guardrail - Enforces Tauri 2.0 granular capability definitions and compile-time Access Control Lists (ACLs) to mitigate webview-to-native privilege escalation. Guarantees that every IPC invoke call maps to an explicitly scoped capability manifest, forbidding global allowlists and unvalidated command execution across mobile webview boundaries.
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-ipc-capability-sandboxing-guardrail"
---

# Tauri 2.0 Mobile IPC Capability Sandboxing & Privilege Escalation Guardrail

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Pervasive IPC Permission Grants and Wildcard Capability Mapping

## System Constraints
You are a Principal Security Architect enforcing Tauri 2.0 Multi-Process IPC Capability Sandboxing on mobile architectures. You must guarantee that no mobile webview can execute arbitrary native operations. Reject any legacy Tauri v1 allowlist patterns, unrestricted global plugin capabilities, wildcard command execution, and unsanitized IPC commands.

## Strict Guidelines
- Engineers MUST ALWAYS isolate mobile capabilities into dedicated JSON or TOML files within 'src-tauri/capabilities/' targeting explicit window or webview labels.
- Engineers MUST NOT grant catch-all wildcard permissions (e.g., 'core:default', 'fs:default') or unconstrained native execution permissions in mobile capability files.
- Engineers MUST ALWAYS scope filesystem, shell, and native hardware capabilities to granular paths and strict input validation rules using capability permission schemas.
- Services MUST define native commands with strongly typed payload arguments via Serde and return explicit Result types, rejecting raw string evaluation and shell escaping.
- Components NEVER invoke Tauri native APIs without compile-time checked wrappers verifying matching client-side permissions against the declared capability file.

## Bad vs Good Implementations
### Tauri 2.0 Mobile Capability Sandboxing Definition

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Using wildcard windows ('*') combined with unconstrained permissions ('fs:allow-read-all', 'shell:allow-execute') exposes the underlying mobile operating system to full compromise if the webview context is vulnerable to XSS or malicious deep-link injection.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-capability",
  "description": "Anti-pattern: Global permissive mobile capability allowing unrestricted native execution",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:allow-read-all",
    "fs:allow-write-all",
    "shell:allow-execute"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Restricts execution strictly to the 'main' mobile window and explicitly confines filesystem access to the secure application cache directory ($APPCACHE), disallowing shell execution and arbitrary file manipulation.
```json
{
  "$schema": "../gen/schemas/mobile-schema.json",
  "identifier": "mobile-restricted-storage",
  "description": "Scoped native filesystem access restricted strictly to mobile app-cache directory",
  "windows": ["main"],
  "permissions": [
    "core:path:default",
    "core:event:default",
    {
      "identifier": "fs:allow-write-text-file",
      "allow": [
        {
          "path": "$APPCACHE/**"
        }
      ]
    },
    {
      "identifier": "fs:allow-read-text-file",
      "allow": [
        {
          "path": "$APPCACHE/**"
        }
      ]
    }
  ]
}
```

### Strict Type-Safe IPC Command Definition with Validation in Rust

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Invoking system execution shells or processing arbitrary raw strings directly from the webview breaks process boundaries and allows remote code execution on the host mobile platform.
```rust
// Anti-pattern: Untyped or overly permissive command accepting arbitrary native commands
#[tauri::command]
pub fn execute_mobile_command(raw_command: String) -> Result<String, String> {
    // Vulnerable: Direct execution of webview-supplied payload
    std::process::Command::new("sh")
        .arg("-c")
        .arg(raw_command)
        .output()
        .map(|out| String::from_utf8_lossy(&out.stdout).to_string())
        .map_err(|e| e.to_string())
}
```

#### Production Standard (Correct)
> **Standard**: Leverages Tauri 2.0 strongly typed IPC commands using Serde structs, strictly validating invariant boundaries before processing native operations and returning structured Results.
```rust
use serde::{Deserialize, Serialize};
use tauri::ipc::Response;

#[derive(Debug, Deserialize)]
pub struct SecureSyncPayload {
    pub transaction_id: String,
    pub record_count: u32,
}

#[derive(Debug, Serialize)]
pub struct SyncResult {
    pub processed: bool,
}

#[tauri::command]
pub async fn sync_app_data(
    payload: SecureSyncPayload,
) -> Result<SyncResult, String> {
    // Strict validation: payload is structurally typed, sanitized, and bounded
    if payload.transaction_id.is_empty() || payload.record_count > 500 {
        return Err("Invalid sync parameters: payload out of bounds".into());
    }

    // Execute isolated native domain logic without invoking shell or arbitrary FS
    Ok(SyncResult { processed: true })
}
```

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 Mobile IPC Capability Sandboxing & Privilege Escalation Guardrail

Tauri 2.0 Mobile IPC Capability Sandboxing & Privilege Escalation Guardrail defines an industrial-grade behavioral standard for mobile engineering. Enforces Tauri 2.0 granular capability definitions and compile-time Access Control Lists (ACLs) to mitigate webview-to-native privilege escalation. Guarantees that every IPC invoke call maps to an explicitly scoped capability manifest, forbidding global allowlists and unvalidated command execution across mobile webview boundaries. 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: Pervasive IPC Permission Grants and Wildcard Capability Mapping 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 DriftPervasive IPC Permission Grants and Wildcard Capability MappingCritical
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 or TOML files within 'src-tauri/capabilities/' targeting explicit window or webview labels.

Engineers MUST ALWAYS isolate mobile capabilities into dedicated JSON or TOML files within 'src-tauri/capabilities/' targeting explicit window or webview 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 wildcard permissions (e.g., 'core

Engineers MUST NOT grant catch-all wildcard permissions (e.g., 'core:default', 'fs:default') or unconstrained native execution permissions in mobile capability files.

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, shell, and native hardware capabilities to granular paths and strict input validation rules using capability permission schemas.

Engineers MUST ALWAYS scope filesystem, shell, and native hardware capabilities to granular paths and strict input validation rules using capability permission schemas.

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 define native commands with strongly typed payload arguments via Serde and return explicit Result types, rejecting raw string evaluation and shell escaping.

Services MUST define native commands with strongly typed payload arguments via Serde and return explicit Result types, rejecting raw string evaluation and shell escaping.

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 Tauri native APIs without compile-time checked wrappers verifying matching client-side permissions against the declared capability file.

Components NEVER invoke Tauri native APIs without compile-time checked wrappers verifying matching client-side permissions against the declared capability file.

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 IPC Capability Sandboxing & Privilege Escalation Guardrail critical for AI coding assistants?

Enforces Tauri 2.0 granular capability definitions and compile-time Access Control Lists (ACLs) to mitigate webview-to-native privilege escalation. Guarantees that every IPC invoke call maps to an explicitly scoped capability manifest, forbidding global allowlists and unvalidated command execution across mobile webview boundaries. 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 (Pervasive IPC Permission Grants and Wildcard Capability Mapping) 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