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

Tauri 2.0 Mobile Webview IPC Capability Isolation & Permission Scoping

Enforces granular, least-privilege capability manifests in Tauri 2.0 mobile architectures by strictly mapping native permissions to explicit webview identifiers. Prohibits global wildcards across multi-webview environments to eliminate privilege escalation vectors from unverified mobile webview contexts.

Prohibited Anti-Pattern: Broadcasting Global Wildcard Permissions to All Webview Contexts via Permissive Capability Manifests

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Mobile Webview IPC Capability Isolation & Permission Scoping - Enforces granular, least-privilege capability manifests in Tauri 2.0 mobile architectures by strictly mapping native permissions to explicit webview identifiers. Prohibits global wildcards across multi-webview environments to eliminate privilege escalation vectors from unverified mobile webview contexts.
globs: src-tauri/capabilities/**/*.json, src-tauri/capabilities/**/*.toml, src-tauri/tauri.conf.json, src/**/*.{ts,tsx}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tauri-v2-mobile-ipc-capability-scoping"
---

# Tauri 2.0 Mobile Webview IPC Capability Isolation & Permission Scoping

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Broadcasting Global Wildcard Permissions to All Webview Contexts via Permissive Capability Manifests

## System Constraints
You are a Principal Security Architect enforcing Tauri 2.0 Mobile IPC Capability-Based Access Control Scoping. You must strictly mandate explicit capability boundary isolation per webview label and eliminate any wildcard permissions in capabilities manifests.

## Strict Guidelines
- Architects MUST scope capability files explicitly using precise window and webview identifiers (e.g., 'windows': ['main'], 'webviews': ['mobile-auth']) rather than wildcard targets ('*').
- Engineers MUST NOT grant blanket plugin access (such as 'fs:default', 'shell:all', or full native device bindings) to untrusted, remote, or secondary webview contexts.
- Manifests MUST define permission scoping down to individual resources using granular permission identifiers with restricted scope arrays (e.g., 'fs:allow-read-text-file' with specific authorized mobile directories).
- Frontend IPC callers MUST invoke commands using typed, validated schemas and explicitly handle capability denial errors returned by the Tauri IPC bridge.
- Build pipelines MUST NEVER bundle development-only mock permissions or permissive remote URL scopes into release mobile builds targeting Android or iOS runtimes.

## Bad vs Good Implementations
### Tauri 2.0 Capability Manifest Scoping for Mobile Webview

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Using wildcard window selectors ('*') and overly broad permission presets ('fs:default', 'camera:all') grants untrusted or secondary webview contexts unrestrained access to native mobile device subsystems.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-capabilities",
  "description": "Global capabilities applied blindly across all mobile views",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:default",
    "camera:all",
    "shell:allow-open"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Explicitly binds permissions to specific window and webview identifiers while scoping file system access to a sandboxed application data directory, preventing unauthorized IPC escalation.
```json
{
  "$schema": "../gen/schemas/mobile-schema.json",
  "identifier": "mobile-secure-vault",
  "description": "Granular native device capabilities scoped exclusively to authenticated webviews",
  "windows": ["main"],
  "webviews": ["secure-vault-webview"],
  "permissions": [
    "core:path:default",
    {
      "identifier": "fs:allow-read-text-file",
      "allow": [{
        "path": "$APPDATA/secure_documents/*"
      }]
    },
    "camera:allow-capture-image"
  ]
}
```

### TypeScript IPC Client Handling Permission Rejection

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Lacks defensive validation, path containment verification, and structured error handling for capability violations, which can cause silent failures or unhandled promise rejections on denied IPC attempts.
```typescript
import { invoke } from '@tauri-apps/api/core';

export async function captureDocument(path: string): Promise<string> {
  // Anti-pattern: Unchecked IPC call assuming blanket capability rights
  return await invoke<string>('plugin:fs|read_text_file', { path });
}
```

#### Production Standard (Correct)
> **Standard**: Validates inputs before sending across the IPC bridge and explicitly intercepts capability violation errors emitted by Tauri 2.0 when an unauthorized action is rejected.
```typescript
import { invoke } from '@tauri-apps/api/core';

interface IpcError {
  code?: string;
  message: string;
}

export async function captureDocument(relativePath: string): Promise<string> {
  if (relativePath.includes('..') || relativePath.startsWith('/')) {
    throw new Error('Directory traversal rejected prior to IPC boundary dispatch');
  }

  try {
    return await invoke<string>('plugin:fs|read_text_file', {
      path: `$APPDATA/secure_documents/${relativePath}`,
    });
  } catch (error) {
    const err = error as IpcError;
    if (err.message?.includes('capability') || err.message?.includes('denied')) {
      console.error('IPC capability violation detected:', err.message);
      throw new Error('Access denied: Native capability not authorized for this context');
    }
    throw error;
  }
}
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Tauri 2.0 Mobile Webview IPC Capability Isolation & Permission Scoping

Tauri 2.0 Mobile Webview IPC Capability Isolation & Permission Scoping defines an industrial-grade behavioral standard for mobile engineering. Enforces granular, least-privilege capability manifests in Tauri 2.0 mobile architectures by strictly mapping native permissions to explicit webview identifiers. Prohibits global wildcards across multi-webview environments to eliminate privilege escalation vectors from unverified mobile webview contexts. 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: Broadcasting Global Wildcard Permissions to All Webview Contexts via Permissive Capability Manifests 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 DriftBroadcasting Global Wildcard Permissions to All Webview Contexts via Permissive Capability ManifestsCritical
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

Architects MUST scope capability files explicitly using precise window and webview identifiers (e.g., 'windows'

Architects MUST scope capability files explicitly using precise window and webview identifiers (e.g., 'windows': ['main'], 'webviews': ['mobile-auth']) rather than wildcard targets ('*').

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 blanket plugin access (such as 'fs

Engineers MUST NOT grant blanket plugin access (such as 'fs:default', 'shell:all', or full native device bindings) to untrusted, remote, or secondary 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.
3

Manifests MUST define permission scoping down to individual resources using granular permission identifiers with restricted scope arrays (e.g., 'fs

Manifests MUST define permission scoping down to individual resources using granular permission identifiers with restricted scope arrays (e.g., 'fs:allow-read-text-file' with specific authorized mobile directories).

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

Frontend IPC callers MUST invoke commands using typed, validated schemas and explicitly handle capability denial errors returned by the Tauri IPC bridge.

Frontend IPC callers MUST invoke commands using typed, validated schemas and explicitly handle capability denial errors returned by the Tauri 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.
5

Build pipelines MUST NEVER bundle development-only mock permissions or permissive remote URL scopes into release mobile builds targeting Android or iOS runtimes.

Build pipelines MUST NEVER bundle development-only mock permissions or permissive remote URL scopes into release mobile builds targeting Android or iOS runtimes.

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 Webview IPC Capability Isolation & Permission Scoping critical for AI coding assistants?

Enforces granular, least-privilege capability manifests in Tauri 2.0 mobile architectures by strictly mapping native permissions to explicit webview identifiers. Prohibits global wildcards across multi-webview environments to eliminate privilege escalation vectors from unverified mobile webview contexts. 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 (Broadcasting Global Wildcard Permissions to All Webview Contexts via Permissive Capability Manifests) 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