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

Tauri 2.0 Scoped IPC Capability ACL and Origin Sandboxing Invariant

Enforces strict origin-bound Access Control List (ACL) manifests and capability isolation in Tauri 2.0 mobile and desktop runtimes. Prohibits wildcard command permissions and unrestricted remote URL IPC invocation to prevent Arbitrary Code Execution (ACE) via webview compromised contexts or cross-origin script injection.

Prohibited Anti-Pattern: Wildcard Capability Mapping and Unsandboxed Remote Origin IPC Invocation

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Scoped IPC Capability ACL and Origin Sandboxing Invariant - Enforces strict origin-bound Access Control List (ACL) manifests and capability isolation in Tauri 2.0 mobile and desktop runtimes. Prohibits wildcard command permissions and unrestricted remote URL IPC invocation to prevent Arbitrary Code Execution (ACE) via webview compromised contexts or cross-origin script injection.
globs: src-tauri/capabilities/**/*.json, src-tauri/tauri.conf.json, src-tauri/src/**/*.rs, src/**/*.{ts,tsx,js}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tauri-v2-scoped-ipc-capability-acl-origin-sandboxing"
---

# Tauri 2.0 Scoped IPC Capability ACL and Origin Sandboxing Invariant

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Wildcard Capability Mapping and Unsandboxed Remote Origin IPC Invocation

## System Constraints
You are a Principal Security Architect enforcing the Tauri 2.0 Scoped IPC Capability ACL and Origin Sandboxing Invariant. Mandate that every IPC command exposed from the Rust core is explicitly bounded by targeted capability files, granular permission sets, and verified webview origins. Reject all configurations using catch-all wildcards, unisolated remote webview URLs, or unvalidated native command invocations.

## Strict Guidelines
- Engineers MUST ALWAYS isolate distinct functional domains into modular capability files under `src-tauri/capabilities/*.json` rather than monolithic global permissions.
- Engineers MUST NEVER use wildcard commands (`*`) or global fallback scopes (`core:default` with unconstrained execution) in production capability manifests.
- Engineers MUST ALWAYS bind capabilities strictly to explicit window labels and exact cryptographically verified origins, strictly forbidding remote wildcards like `https://*`.
- Code executing sensitive operations (file system, process spawning, native keychain) MUST inspect the calling `tauri::ipc::InvokeResolver` or `tauri::Webview` identity within Rust to verify state isolation.
- Services interacting with remote web content on mobile (Android Webview / iOS WKWebView) MUST run remote views in an isolated window context stripped of all core system capabilities.
- Frontend invoke calls MUST use strictly typed command signatures that map 1:1 with declared capability permission identifiers.

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

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Grants arbitrary windows and any remote HTTPS webview full filesystem and shell execution capabilities. An attacker exploiting an XSS on any loaded remote page gains complete host system compromise via Tauri IPC.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "all-access-capability",
  "description": "Insecure capability giving broad permissions to any window",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:default",
    "shell:allow-execute"
  ],
  "remote": {
    "urls": ["https://*"]
  }
}
```

#### Production Standard (Correct)
> **Standard**: Constrains permissions strictly to the 'main' window label, restricts file read access to a granular sub-path under $APPDATA/logs, and explicitly locks remote invocation to a verified internal subdomain.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "isolated-audit-capability",
  "description": "Granular capability restricted strictly to the primary window and local assets",
  "windows": ["main"],
  "permissions": [
    "core:path:default",
    {
      "identifier": "fs:allow-read-text-file",
      "allow": [{
        "path": "$APPDATA/logs/*"
      }]
    }
  ],
  "remote": {
    "urls": ["https://secure.app.internal/*"]
  }
}
```

### Rust Core IPC Command Origin and State Validation

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Bypasses Tauri 2.0's managed state and security context; does not accept Tauri webview references or inspect caller capabilities, allowing any webview with command-level access to write arbitrary host files.
```rust
// Insecure: Blindly trusts the invoke payload without webview or origin verification
#[tauri::command]
pub async fn write_sensitive_audit(path: String, content: String) -> Result<(), String> {
    std::fs::write(path, content).map_err(|e| e.to_string())
}
```

#### Production Standard (Correct)
> **Standard**: Validates caller origin via `Webview<R>`, strictly prevents path traversal via path sanitation and managed path resolution (`app.path().app_data_dir()`), ensuring strict execution invariants.
```rust
use tauri::{command, AppHandle, Runtime, Webview};
use std::path::PathBuf;

#[command]
pub async fn write_sensitive_audit<R: Runtime>(
    _app: AppHandle<R>,
    webview: Webview<R>,
    filename: String,
    content: String,
) -> Result<(), String> {
    // Invariant: Verify command invocation context originates exclusively from internal schemes
    let url = webview.url();
    if url.scheme() != "tauri" && url.host_str() != Some("localhost") {
        return Err("Unauthorized IPC execution origin".into());
    }

    // Invariant: Sanitize inputs to prevent path traversal outside designated sandbox
    if filename.contains("..") || filename.starts_with('/') || filename.starts_with('\\') {
        return Err("Path traversal detected".into());
    }

    let app_dir = _app.path().app_data_dir().map_err(|e| e.to_string())?;
    let safe_target = app_dir.join("logs").join(filename);

    std::fs::write(safe_target, content.as_bytes()).map_err(|e| e.to_string())?;
    Ok(())
}
```

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 Scoped IPC Capability ACL and Origin Sandboxing Invariant

Tauri 2.0 Scoped IPC Capability ACL and Origin Sandboxing Invariant defines an industrial-grade behavioral standard for mobile engineering. Enforces strict origin-bound Access Control List (ACL) manifests and capability isolation in Tauri 2.0 mobile and desktop runtimes. Prohibits wildcard command permissions and unrestricted remote URL IPC invocation to prevent Arbitrary Code Execution (ACE) via webview compromised contexts or cross-origin script injection. 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 Capability Mapping and Unsandboxed Remote Origin IPC Invocation 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 Capability Mapping and Unsandboxed Remote Origin IPC InvocationCritical
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 distinct functional domains into modular capability files under `src-tauri/capabilities/*.json` rather than monolithic global permissions.

Engineers MUST ALWAYS isolate distinct functional domains into modular capability files under `src-tauri/capabilities/*.json` rather than monolithic global permissions.

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 use wildcard commands (`*`) or global fallback scopes (`core

Engineers MUST NEVER use wildcard commands (`*`) or global fallback scopes (`core:default` with unconstrained execution) in production capability 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 bind capabilities strictly to explicit window labels and exact cryptographically verified origins, strictly forbidding remote wildcards like `https

Engineers MUST ALWAYS bind capabilities strictly to explicit window labels and exact cryptographically verified origins, strictly forbidding remote wildcards like `https://*`.

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

Code executing sensitive operations (file system, process spawning, native keychain) MUST inspect the calling `tauri

Code executing sensitive operations (file system, process spawning, native keychain) MUST inspect the calling `tauri::ipc::InvokeResolver` or `tauri::Webview` identity within Rust to verify state isolation.

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

Services interacting with remote web content on mobile (Android Webview / iOS WKWebView) MUST run remote views in an isolated window context stripped of all core system capabilities.

Services interacting with remote web content on mobile (Android Webview / iOS WKWebView) MUST run remote views in an isolated window context stripped of all core system 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.
6

Frontend invoke calls MUST use strictly typed command signatures that map 1

Frontend invoke calls MUST use strictly typed command signatures that map 1:1 with declared capability permission identifiers.

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 Scoped IPC Capability ACL and Origin Sandboxing Invariant critical for AI coding assistants?

Enforces strict origin-bound Access Control List (ACL) manifests and capability isolation in Tauri 2.0 mobile and desktop runtimes. Prohibits wildcard command permissions and unrestricted remote URL IPC invocation to prevent Arbitrary Code Execution (ACE) via webview compromised contexts or cross-origin script injection. 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 Capability Mapping and Unsandboxed Remote Origin IPC Invocation) 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