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

Tauri 2.0 Mobile Multi-Webview IPC Capability Boundary Isolation

Enforces strict principle-of-least-privilege IPC boundaries across multiple webviews in Tauri 2.0 mobile applications (iOS/Android). Prohibits default universal plugin scopes, wildcard command matching, and global window capability inheritance to prevent untrusted or sandboxed auxiliary webviews from escalating privileges to native hardware APIs such as camera, biometrics, secure storage, and geolocation.

Prohibited Anti-Pattern: Global Capability Broad-Casting and Ambient IPC Permission Leakage Across Mobile Webviews

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Mobile Multi-Webview IPC Capability Boundary Isolation - Enforces strict principle-of-least-privilege IPC boundaries across multiple webviews in Tauri 2.0 mobile applications (iOS/Android). Prohibits default universal plugin scopes, wildcard command matching, and global window capability inheritance to prevent untrusted or sandboxed auxiliary webviews from escalating privileges to native hardware APIs such as camera, biometrics, secure storage, and geolocation.
globs: src-tauri/capabilities/**/*.json, src-tauri/tauri.conf.json, src-tauri/src/**/*.rs, src/**/*.{ts,tsx,js,jsx}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tauri2-mobile-ipc-capability-boundary"
---

# Tauri 2.0 Mobile Multi-Webview IPC Capability Boundary Isolation

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Global Capability Broad-Casting and Ambient IPC Permission Leakage Across Mobile Webviews

## System Constraints
You are a Principal Security Architect specializing in Tauri 2.0 cross-platform mobile security. You enforce strict IPC isolation, least-privilege capability manifests, and per-webview access boundaries. Never allow auxiliary webviews, OAuth popups, or external link frames to inherit core native hardware capabilities (biometrics, secure storage, camera, sensors, filesystem). Reject any capability configuration that employs wildcard window definitions or universal plugin allowances.

## Strict Guidelines
- Engineers MUST ALWAYS isolate distinct mobile webviews using dedicated capability JSON files under `src-tauri/capabilities/` targeting explicit window/webview labels.
- Engineers MUST NOT use wildcard window matchers (`windows: ["*"]`) in capabilities that expose sensitive hardware plugins (e.g., `biometric`, `camera`, `fs`, `sql`, `stronghold`).
- Code SHOULD enforce strict payload schema validation inside custom Rust commands invoked over IPC, validating the origin window label via `tauri::Webview` before execution.
- Services MUST explicitly designate untrusted or external-content webviews (such as OAuth or checkout flows) to a sandboxed capability with no plugin permissions or an empty `permissions: []` array.
- Components NEVER execute unchecked raw `invoke()` calls from auxiliary webviews without verifying that the command is scoped to that webview's security context.

## Bad vs Good Implementations
### Tauri 2.0 Capability Manifest Isolation (JSON)

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Using wildcard window selector 'windows: ["*"]' grants native hardware plugins (biometrics, camera, secure storage) to every webview in the app, allowing untrusted auxiliary webviews (e.g., OAuth or in-app browsers) to execute sensitive hardware commands.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-all-capabilities",
  "description": "Global capability granting access to all mobile views",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "biometric:allow-authenticate",
    "camera:allow-capture",
    "secure-storage:default"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Explicitly targets the verified 'main' window and 'main-view' webview label. Any secondary or third-party webviews created at runtime are strictly denied access to the biometric and secure storage IPC commands.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "main-authenticated-capabilities",
  "description": "Strict hardware capability restricted exclusively to the authenticated root mobile webview",
  "windows": ["main"],
  "webviews": ["main-view"],
  "permissions": [
    "core:default",
    "biometric:allow-authenticate",
    "secure-storage:default"
  ]
}
```

### Rust Custom IPC Command Contextual Validation

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The Rust command assumes that any incoming IPC invoke is from a trusted context, ignoring the originating Webview instance and opening the door to malicious invocations if capability scoping is misconfigured.
```rust
// Insecure: Executes hardware-adjacent action without verifying webview identity
#[tauri::command]
pub async fn write_sensitive_token(token: String) -> Result<(), String> {
    // Directly writing token assuming caller is legitimate
    crate::secure_store::set("auth_token", &token).map_err(|e| e.to_string())
}
```

#### Production Standard (Correct)
> **Standard**: Inspects the `tauri::Webview` caller metadata inside the command handler, ensuring defense-in-depth even in the event of capability manifest misconfiguration.
```rust
// Secure: Validates that the calling webview label strictly matches authorized context
#[tauri::command]
pub async fn write_sensitive_token(
    webview: tauri::Webview,
    token: String
) -> Result<(), String> {
    if webview.label() != "main-view" {
        return Err("Unauthorized: IPC origin boundary violation".into());
    }
    crate::secure_store::set("auth_token", &token).map_err(|e| e.to_string())
}
```

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 Multi-Webview IPC Capability Boundary Isolation

Tauri 2.0 Mobile Multi-Webview IPC Capability Boundary Isolation defines an industrial-grade behavioral standard for mobile engineering. Enforces strict principle-of-least-privilege IPC boundaries across multiple webviews in Tauri 2.0 mobile applications (iOS/Android). Prohibits default universal plugin scopes, wildcard command matching, and global window capability inheritance to prevent untrusted or sandboxed auxiliary webviews from escalating privileges to native hardware APIs such as camera, biometrics, secure storage, and geolocation. 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: Global Capability Broad-Casting and Ambient IPC Permission Leakage Across 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 DriftGlobal Capability Broad-Casting and Ambient IPC Permission Leakage Across 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 distinct mobile webviews using dedicated capability JSON files under `src-tauri/capabilities/` targeting explicit window/webview labels.

Engineers MUST ALWAYS isolate distinct mobile webviews using dedicated capability JSON files under `src-tauri/capabilities/` targeting explicit window/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 use wildcard window matchers (`windows

Engineers MUST NOT use wildcard window matchers (`windows: ["*"]`) in capabilities that expose sensitive hardware plugins (e.g., `biometric`, `camera`, `fs`, `sql`, `stronghold`).

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

Code SHOULD enforce strict payload schema validation inside custom Rust commands invoked over IPC, validating the origin window label via `tauri

Code SHOULD enforce strict payload schema validation inside custom Rust commands invoked over IPC, validating the origin window label via `tauri::Webview` before execution.

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 explicitly designate untrusted or external-content webviews (such as OAuth or checkout flows) to a sandboxed capability with no plugin permissions or an empty `permissions

Services MUST explicitly designate untrusted or external-content webviews (such as OAuth or checkout flows) to a sandboxed capability with no plugin permissions or an empty `permissions: []` array.

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 execute unchecked raw `invoke()` calls from auxiliary webviews without verifying that the command is scoped to that webview's security context.

Components NEVER execute unchecked raw `invoke()` calls from auxiliary webviews without verifying that the command is scoped to that webview's security context.

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 Multi-Webview IPC Capability Boundary Isolation critical for AI coding assistants?

Enforces strict principle-of-least-privilege IPC boundaries across multiple webviews in Tauri 2.0 mobile applications (iOS/Android). Prohibits default universal plugin scopes, wildcard command matching, and global window capability inheritance to prevent untrusted or sandboxed auxiliary webviews from escalating privileges to native hardware APIs such as camera, biometrics, secure storage, and geolocation. 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 (Global Capability Broad-Casting and Ambient IPC Permission Leakage Across 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