This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
mobilecritical PriorityID: tauri-v2-mobile-multi-origin-capability-scope-isolation

Tauri 2.0 Mobile Multi-Origin Capability Scope Isolation and IPC Boundary Enforcement

Enforces strict origin-to-capability boundary isolation in Tauri 2.0 mobile architectures. Prevents privilege escalation and unauthorized native device API invocation by segregating remote webview contexts from local application bundles through fine-grained capability descriptors and remote URL pinning.

Prohibited Anti-Pattern: Assigning Overly Permissive Wildcard Capabilities to Remote Webview Contexts Leaking Device APIs

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Mobile Multi-Origin Capability Scope Isolation and IPC Boundary Enforcement - Enforces strict origin-to-capability boundary isolation in Tauri 2.0 mobile architectures. Prevents privilege escalation and unauthorized native device API invocation by segregating remote webview contexts from local application bundles through fine-grained capability descriptors and remote URL pinning.
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-mobile-multi-origin-capability-scope-isolation"
---

# Tauri 2.0 Mobile Multi-Origin Capability Scope Isolation and IPC Boundary Enforcement

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Assigning Overly Permissive Wildcard Capabilities to Remote Webview Contexts Leaking Device APIs

## System Constraints
You are a Principal Security Architect enforcing Tauri 2.0 Mobile Multi-Origin Capability Scope Isolation. Tauri 2.0 replaces the v1 allowlist with an Access Control List (ACL) composed of permissions, sets, and capabilities. On mobile targets (iOS/Android), applications frequently spawn or redirect webviews for OAuth2 federated auth, in-app purchases, or remote microfrontends. You must mandate that remote origins NEVER inherit core local capabilities, and that native mobile plugins (biometrics, camera, secure storage, filesystem) are strictly inaccessible to untrusted or remote webview contexts. Zero-trust capability boundaries must be proven at build-time and verified at runtime.

## Strict Guidelines
- Engineers MUST declare separate, isolated capability JSON files in `src-tauri/capabilities/` for local (`tauri://localhost`) contexts versus remote (`remote: { urls: [...] }`) webview contexts.
- Engineers MUST NOT use wildcard window bindings (`windows: ["*"]`) in any capability that grants access to privileged device plugins (e.g., biometric, barcode-scanner, camera, fs, shell, or secure-storage).
- Engineers MUST define explicit `remote: { urls: ["https://..."] }` patterns using strict HTTPS subpaths for external webviews, never using wildcard hosts like `https://*` or `*`.
- Remote capabilities MUST only grant the absolute minimum required permission set (e.g., deep-link listeners or non-privileged events) and NEVER expose direct filesystem or native device execution commands.
- Frontend IPC invokers MUST NOT dynamically construct invoke commands or forward arbitrary messages from unverified `window.addEventListener('message')` events into `@tauri-apps/api/core`.
- When using `@tauri-apps/plugin-opener` or custom in-app browsers, mobile engineers MUST launch third-party URLs in dedicated external browsers or unprivileged secondary webview windows isolated from the host IPC bridge.

## Bad vs Good Implementations
### Tauri 2.0 Capability Declaration: Remote vs. Local Isolation

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Using wildcard `windows: ["*"]` combined with sensitive native mobile plugins (`biometric`, `camera`, `fs`) allows any webview instance—including embedded OAuth flows, redirects, or compromised remote URLs—to execute privileged native IPC calls on the device.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "default-capability",
  "description": "Shared capability granting broad device access across all windows",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "biometric:default",
    "camera:default",
    "fs:default",
    "opener:default"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Explicitly binds minimal permissions (`core:event:default`, `deep-link:default`) solely to the `auth-window` label and strictly constrains valid execution to the pinned origin subpath `https://auth.production.idp.internal/oauth2/*`. Sensitive native device plugins remain isolated in local capabilities.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "remote-oauth-capability",
  "description": "Restricted capability descriptor specifically scoped for remote OAuth provider webviews",
  "windows": ["auth-window"],
  "remote": {
    "urls": ["https://auth.production.idp.internal/oauth2/*"]
  },
  "permissions": [
    "core:event:default",
    "deep-link:default"
  ]
}
```

### TypeScript IPC Wrapper with Strict Window Context Validation

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Does not verify whether the active execution context is running inside the secure local origin or an injected/redirected remote webview, exposing device biometric authentication to execution from rogue or untrusted frames.
```typescript
import { invoke } from '@tauri-apps/api/core';

// Flawed: Executes native biometric verification without verifying context origin
export async function verifyUserIdentity(prompt: string): Promise<boolean> {
  return await invoke<boolean>('plugin:biometric|authenticate', { reason: prompt });
}
```

#### Production Standard (Correct)
> **Standard**: Validates the webview context against an explicit allowlist of privileged window labels before initiating the IPC call, preventing hijacked secondary frames or remote webview contexts from triggering native device credentials.
```typescript
import { invoke } from '@tauri-apps/api/core';
import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow';

const PRIVILEGED_WINDOW_LABELS = new Set(['main', 'local-dashboard']);

export async function verifyUserIdentity(prompt: string): Promise<boolean> {
  const currentWindow = getCurrentWebviewWindow();
  
  if (!PRIVILEGED_WINDOW_LABELS.has(currentWindow.label)) {
    throw new Error(
      `SecurityViolation: Window '${currentWindow.label}' is unauthorized to invoke privileged biometric APIs.`
    );
  }

  return await invoke<boolean>('plugin:biometric|authenticate', { reason: prompt });
}
```

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-Origin Capability Scope Isolation and IPC Boundary Enforcement

Tauri 2.0 Mobile Multi-Origin Capability Scope Isolation and IPC Boundary Enforcement defines an industrial-grade behavioral standard for mobile engineering. Enforces strict origin-to-capability boundary isolation in Tauri 2.0 mobile architectures. Prevents privilege escalation and unauthorized native device API invocation by segregating remote webview contexts from local application bundles through fine-grained capability descriptors and remote URL pinning. 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: Assigning Overly Permissive Wildcard Capabilities to Remote Webview Contexts Leaking Device APIs 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 DriftAssigning Overly Permissive Wildcard Capabilities to Remote Webview Contexts Leaking Device APIsCritical
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 declare separate, isolated capability JSON files in `src-tauri/capabilities/` for local (`tauri

Engineers MUST declare separate, isolated capability JSON files in `src-tauri/capabilities/` for local (`tauri://localhost`) contexts versus remote (`remote: { urls: [...] }`) webview 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.
2

Engineers MUST NOT use wildcard window bindings (`windows

Engineers MUST NOT use wildcard window bindings (`windows: ["*"]`) in any capability that grants access to privileged device plugins (e.g., biometric, barcode-scanner, camera, fs, shell, or secure-storage).

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 define explicit `remote

Engineers MUST define explicit `remote: { urls: ["https://..."] }` patterns using strict HTTPS subpaths for external webviews, never using wildcard hosts like `https://*` or `*`.

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

Remote capabilities MUST only grant the absolute minimum required permission set (e.g., deep-link listeners or non-privileged events) and NEVER expose direct filesystem or native device execution commands.

Remote capabilities MUST only grant the absolute minimum required permission set (e.g., deep-link listeners or non-privileged events) and NEVER expose direct filesystem or native device execution commands.

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

Frontend IPC invokers MUST NOT dynamically construct invoke commands or forward arbitrary messages from unverified `window.addEventListener('message')` events into `@tauri-apps/api/core`.

Frontend IPC invokers MUST NOT dynamically construct invoke commands or forward arbitrary messages from unverified `window.addEventListener('message')` events into `@tauri-apps/api/core`.

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

When using `@tauri-apps/plugin-opener` or custom in-app browsers, mobile engineers MUST launch third-party URLs in dedicated external browsers or unprivileged secondary webview windows isolated from the host IPC bridge.

When using `@tauri-apps/plugin-opener` or custom in-app browsers, mobile engineers MUST launch third-party URLs in dedicated external browsers or unprivileged secondary webview windows isolated from the host IPC bridge.

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-Origin Capability Scope Isolation and IPC Boundary Enforcement critical for AI coding assistants?

Enforces strict origin-to-capability boundary isolation in Tauri 2.0 mobile architectures. Prevents privilege escalation and unauthorized native device API invocation by segregating remote webview contexts from local application bundles through fine-grained capability descriptors and remote URL pinning. 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 (Assigning Overly Permissive Wildcard Capabilities to Remote Webview Contexts Leaking Device APIs) 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