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

Tauri 2.0 Scoped Mobile IPC Capability Sandboxing Standard

Enforces strict compile-time permission scoping and origin boundary verification for Tauri 2.0 mobile applications. Prevents arbitrary native execution by restricting IPC capabilities to designated local webview windows and prohibiting wildcard plugin grants. Guarantees that external web content and deep links cannot invoke privileged Android/iOS bridge APIs.

Prohibited Anti-Pattern: Over-privileged Wildcard Capabilities and Remote Origin IPC Invocation Vulnerabilities

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Scoped Mobile IPC Capability Sandboxing Standard - Enforces strict compile-time permission scoping and origin boundary verification for Tauri 2.0 mobile applications. Prevents arbitrary native execution by restricting IPC capabilities to designated local webview windows and prohibiting wildcard plugin grants. Guarantees that external web content and deep links cannot invoke privileged Android/iOS bridge APIs.
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-mobile-scoped-ipc-sandboxing-standard"
---

# Tauri 2.0 Scoped Mobile IPC Capability Sandboxing Standard

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Over-privileged Wildcard Capabilities and Remote Origin IPC Invocation Vulnerabilities

## System Constraints
You are a Principal Mobile Security Architect enforcing Tauri 2.0 Scoped Mobile IPC Capability Sandboxing. You mandate zero-trust compile-time capabilities, explicit window scoping, granular filesystem/network command boundaries, and strict validation against remote origin execution on Android and iOS webviews.

## Strict Guidelines
- Engineers MUST ALWAYS define granular capabilities in `src-tauri/capabilities/*.json` with explicit `windows` and `webviews` arrays rather than relying on global defaults.
- Engineers MUST NOT grant wildcard permissions (such as `core:default`, `fs:default`, or `*:*`) in mobile capability manifests.
- Engineers MUST scope filesystem access to explicit path prefixes using variables like `$APP_DATA`, `$APP_CACHE`, or `$TEMP` to maintain Android scoped storage and iOS container compliance.
- Webviews rendering remote URLs or handling untrusted user input MUST NOT be granted access to IPC commands or privileged plugins.
- Engineers MUST enforce the Principle of Least Privilege by separating foreground UI capabilities from background tasks or worker contexts.
- All native Rust commands exposed to mobile webviews MUST validate incoming arguments against explicit domain schemas before executing system calls.
- Engineers MUST configure Content Security Policy (CSP) in `tauri.conf.json` preventing script injection and unauthorized native IPC bridge exposure.

## Bad vs Good Implementations
### Granular Scoped IPC Invocations vs Unrestricted Native Execution

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Directly passing untrusted paths to generic plugin commands without application-level validation or capability scopes allows directory traversal and arbitrary device read vulnerabilities if the webview executes malicious script.
```typescript
import { invoke } from '@tauri-apps/api/core';

// ANTI-PATTERN: Blindly trusting caller-provided paths and relying on broad ambient permissions.
// This allows arbitrary file traversal or native execution if injected into a compromised webview.
export async function readSensitiveFile(untrustedPath: string): Promise<string> {
  // Insecure: invoking un-scoped FS commands without validating origin or path constraints
  return await invoke<string>('plugin:fs|read_text_file', {
    path: untrustedPath,
  });
}

// ANTI-PATTERN: Dynamically delegating arbitrary native plugin commands
export async function executePluginCommand(command: string, payload: unknown) {
  return await invoke(`plugin:${command}`, { payload });
}
```

#### Production Standard (Correct)
> **Standard**: Validates inputs strictly against injection/traversal attacks, pins directory access to BaseDirectory.AppData, and leverages Tauri 2.0 scoped compile-time permissions to enforce hardware-backed mobile sandbox boundaries.
```typescript
import { invoke } from '@tauri-apps/api/core';
import { BaseDirectory } from '@tauri-apps/api/path';

interface SecureReadRequest {
  filename: string;
}

// PRODUCTION INVARIANT: Use typed, bounded commands constrained to $APP_DATA
// Sandboxed via capability file: permissions ["fs:allow-app-read-recursive"]
const SAFE_FILENAME_REGEX = /^[a-zA-Z0-9_-]+\.[a-zA-Z0-9]+$/;

export async function readUserDocument(filename: string): Promise<string> {
  if (!SAFE_FILENAME_REGEX.test(filename)) {
    throw new Error('Invalid filename: Path traversal characters rejected');
  }

  // Explicitly constrain base directory to Mobile AppData sandbox
  return await invoke<string>('plugin:fs|read_text_file', {
    path: filename,
    options: {
      baseDir: BaseDirectory.AppData,
    },
  });
}
```

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 Mobile IPC Capability Sandboxing Standard

Tauri 2.0 Scoped Mobile IPC Capability Sandboxing Standard defines an industrial-grade behavioral standard for mobile engineering. Enforces strict compile-time permission scoping and origin boundary verification for Tauri 2.0 mobile applications. Prevents arbitrary native execution by restricting IPC capabilities to designated local webview windows and prohibiting wildcard plugin grants. Guarantees that external web content and deep links cannot invoke privileged Android/iOS bridge APIs. 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: Over-privileged Wildcard Capabilities and Remote Origin IPC Invocation Vulnerabilities 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 DriftOver-privileged Wildcard Capabilities and Remote Origin IPC Invocation VulnerabilitiesCritical
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 define granular capabilities in `src-tauri/capabilities/*.json` with explicit `windows` and `webviews` arrays rather than relying on global defaults.

Engineers MUST ALWAYS define granular capabilities in `src-tauri/capabilities/*.json` with explicit `windows` and `webviews` arrays rather than relying on global defaults.

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 wildcard permissions (such as `core

Engineers MUST NOT grant wildcard permissions (such as `core:default`, `fs:default`, or `*:*`) in mobile 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 scope filesystem access to explicit path prefixes using variables like `$APP_DATA`, `$APP_CACHE`, or `$TEMP` to maintain Android scoped storage and iOS container compliance.

Engineers MUST scope filesystem access to explicit path prefixes using variables like `$APP_DATA`, `$APP_CACHE`, or `$TEMP` to maintain Android scoped storage and iOS container compliance.

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

Webviews rendering remote URLs or handling untrusted user input MUST NOT be granted access to IPC commands or privileged plugins.

Webviews rendering remote URLs or handling untrusted user input MUST NOT be granted access to IPC commands or privileged plugins.

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

Engineers MUST enforce the Principle of Least Privilege by separating foreground UI capabilities from background tasks or worker contexts.

Engineers MUST enforce the Principle of Least Privilege by separating foreground UI capabilities from background tasks or worker contexts.

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

All native Rust commands exposed to mobile webviews MUST validate incoming arguments against explicit domain schemas before executing system calls.

All native Rust commands exposed to mobile webviews MUST validate incoming arguments against explicit domain schemas before executing system calls.

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.
7

Engineers MUST configure Content Security Policy (CSP) in `tauri.conf.json` preventing script injection and unauthorized native IPC bridge exposure.

Engineers MUST configure Content Security Policy (CSP) in `tauri.conf.json` preventing script injection and unauthorized native IPC bridge exposure.

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

Enforces strict compile-time permission scoping and origin boundary verification for Tauri 2.0 mobile applications. Prevents arbitrary native execution by restricting IPC capabilities to designated local webview windows and prohibiting wildcard plugin grants. Guarantees that external web content and deep links cannot invoke privileged Android/iOS bridge APIs. 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 (Over-privileged Wildcard Capabilities and Remote Origin IPC Invocation Vulnerabilities) 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