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

Tauri 2.0 Mobile IPC Capability ACL Sandboxing

Enforces principle-of-least-privilege Access Control Lists (ACL) and compile-time capability sandboxing for Tauri 2.0 mobile bridges. Restricts hybrid WebView IPC access to prevent cross-context script injection and unauthorized native capability invocation on iOS and Android targets.

Prohibited Anti-Pattern: Exposing Wildcard IPC Capabilities or Global Plugin Grants to Mobile WebViews

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Mobile IPC Capability ACL Sandboxing - Enforces principle-of-least-privilege Access Control Lists (ACL) and compile-time capability sandboxing for Tauri 2.0 mobile bridges. Restricts hybrid WebView IPC access to prevent cross-context script injection and unauthorized native capability invocation on iOS and Android targets.
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-ipc-capability-acl-sandboxing"
---

# Tauri 2.0 Mobile IPC Capability ACL Sandboxing

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Exposing Wildcard IPC Capabilities or Global Plugin Grants to Mobile WebViews

## System Constraints
You are a Principal Mobile Security Architect enforcing Tauri 2.0 IPC sandboxing and Capability ACLs. You must ensure zero wildcard native command access, enforce strict compile-time window/webview targeting in capability sets, mandate granular permission scoping on mobile bridges, and neutralize cross-origin injection surfaces.

## Strict Guidelines
- Engineers MUST ALWAYS isolate mobile capabilities into dedicated JSON definitions under `src-tauri/capabilities/` scoped exclusively to explicit window labels (e.g., `windows: ["main"]`).
- Engineers MUST NOT grant wildcard permissions (`*:*`, `core:default`, or unconstrained plugin roots like `fs:default` or `shell:default`) in mobile capabilities.
- Engineers MUST ALWAYS scope filesystem, network, and hardware permissions to explicit path prefixes and host whitelists using granular permission objects rather than blanket flags.
- Code SHOULD enforce strict type-safe wrappers around `@tauri-apps/api/core` `invoke()` calls to prevent arbitrary string command invocation from the DOM.
- Services MUST validate IPC caller origins and reject dynamic command execution or string evaluation received from hybrid WebView events.
- Components NEVER expose native bridge invocation primitives directly to the global `window` object or accept unvalidated postMessage payloads.

## Bad vs Good Implementations
### Tauri 2.0 IPC Capability Scoping and Invocation

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Exposing an untyped dynamic bridge execution function to the global window allows any injected script (via XSS or third-party web content) to invoke any enabled native command, bypassing frontend sandboxing controls.
```typescript
// Bad: Exposing an unrestricted, dynamic bridge call that accepts arbitrary commands
// and relies on broad, unscoped backend capabilities without client validation.
import { invoke } from '@tauri-apps/api/core';

declare global {
  interface Window {
    __NATIVE_BRIDGE__: { execute: (cmd: string, payload: unknown) => Promise<unknown> };
  }
}

// Exposing raw invoke on window enables XSS to escalate to native RCE
window.__NATIVE_BRIDGE__ = {
  execute: async (cmd: string, payload: unknown) => {
    return await invoke(cmd, { payload });
  },
};
```

#### Production Standard (Correct)
> **Standard**: Restricts IPC communication to a compile-time closed command manifest with strict types, preventing arbitrary string execution and aligning directly with least-privilege capability files in src-tauri/capabilities.
```typescript
// Good: Strongly typed, closed-set command wrapper mapped directly to scoped ACLs
import { invoke } from '@tauri-apps/api/core';

type SecureMobileCommandMap = {
  'read_secure_storage': { key: string; result: string | null };
  'capture_biometric_auth': { reason: string; result: boolean };
};

export async function invokeMobileIpc<K extends keyof SecureMobileCommandMap>(
  command: K,
  payload: Omit<SecureMobileCommandMap[K], 'result'>
): Promise<SecureMobileCommandMap[K]['result']> {
  // Backend capabilities must mirror this with strict scoped permissions:
  // e.g., 'permissions': ['secure-storage:allow-read-key', 'biometric-auth:allow-authenticate']
  try {
    return await invoke<SecureMobileCommandMap[K]['result']>(command, payload);
  } catch (error) {
    console.error(`Secure IPC execution rejected for command ${command}:`, error);
    throw new Error('Native IPC invocation denied by mobile ACL policy');
  }
}
```

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 IPC Capability ACL Sandboxing

Tauri 2.0 Mobile IPC Capability ACL Sandboxing defines an industrial-grade behavioral standard for mobile engineering. Enforces principle-of-least-privilege Access Control Lists (ACL) and compile-time capability sandboxing for Tauri 2.0 mobile bridges. Restricts hybrid WebView IPC access to prevent cross-context script injection and unauthorized native capability invocation on iOS and Android targets. 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: Exposing Wildcard IPC Capabilities or Global Plugin Grants to 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 DriftExposing Wildcard IPC Capabilities or Global Plugin Grants to 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 isolate mobile capabilities into dedicated JSON definitions under `src-tauri/capabilities/` scoped exclusively to explicit window labels (e.g., `windows

Engineers MUST ALWAYS isolate mobile capabilities into dedicated JSON definitions under `src-tauri/capabilities/` scoped exclusively to explicit window labels (e.g., `windows: ["main"]`).

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

Engineers MUST NOT grant wildcard permissions (`*:*`, `core:default`, or unconstrained plugin roots like `fs:default` or `shell:default`) in mobile 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.
3

Engineers MUST ALWAYS scope filesystem, network, and hardware permissions to explicit path prefixes and host whitelists using granular permission objects rather than blanket flags.

Engineers MUST ALWAYS scope filesystem, network, and hardware permissions to explicit path prefixes and host whitelists using granular permission objects rather than blanket flags.

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 SHOULD enforce strict type-safe wrappers around `@tauri-apps/api/core` `invoke()` calls to prevent arbitrary string command invocation from the DOM.

Code SHOULD enforce strict type-safe wrappers around `@tauri-apps/api/core` `invoke()` calls to prevent arbitrary string command invocation from the DOM.

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 MUST validate IPC caller origins and reject dynamic command execution or string evaluation received from hybrid WebView events.

Services MUST validate IPC caller origins and reject dynamic command execution or string evaluation received from hybrid WebView events.

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 expose native bridge invocation primitives directly to the global `window` object or accept unvalidated postMessage payloads.

Components NEVER expose native bridge invocation primitives directly to the global `window` object or accept unvalidated postMessage payloads.

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 ACL Sandboxing critical for AI coding assistants?

Enforces principle-of-least-privilege Access Control Lists (ACL) and compile-time capability sandboxing for Tauri 2.0 mobile bridges. Restricts hybrid WebView IPC access to prevent cross-context script injection and unauthorized native capability invocation on iOS and Android targets. 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 (Exposing Wildcard IPC Capabilities or Global Plugin Grants to 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