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-manifest-enforcement

Tauri 2.0 Scoped Mobile IPC Capability Manifest Enforcement

Enforces principle-of-least-privilege IPC capabilities across mobile WebView contexts in Tauri 2.0. Prohibits global wildcards, unisolated capabilities, and unconstrained native plugin bindings by mandating granular, window-scoped capability manifests with strict parameter validation.

Prohibited Anti-Pattern: Wildcard or Unscoped Native Plugin Permissions in Tauri 2.0 Mobile WebViews

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Scoped Mobile IPC Capability Manifest Enforcement - Enforces principle-of-least-privilege IPC capabilities across mobile WebView contexts in Tauri 2.0. Prohibits global wildcards, unisolated capabilities, and unconstrained native plugin bindings by mandating granular, window-scoped capability manifests with strict parameter validation.
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-manifest-enforcement"
---

# Tauri 2.0 Scoped Mobile IPC Capability Manifest Enforcement

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Wildcard or Unscoped Native Plugin Permissions in Tauri 2.0 Mobile WebViews

## System Constraints
You are a Principal Security Architect enforcing Tauri 2.0 Scoped Mobile IPC Capability Manifest Enforcement. Tauri 2.0 introduces a capability-driven permission model replacing global allowlists. Mobile platforms (iOS and Android) run WebViews that must never receive ambient or wildcard access to native APIs. Mandate granular window-scoped capability files, enforce strict type guards and runtime payload schema checks before calling invoke(), and eliminate wildcard native permissions across all capability manifests.

## Strict Guidelines
- Engineers MUST ALWAYS isolate mobile capabilities into dedicated manifest files (e.g., `src-tauri/capabilities/mobile.json`) strictly targeting mobile window labels.
- Engineers MUST NOT grant wildcard permissions (`*:*`, `shell:allow-all`, or broad unconstrained plugin defaults) in any production capability manifest.
- Code SHOULD validate all IPC payloads on the frontend with runtime schema validation (e.g., Zod) prior to dispatching `invoke()` calls across the native bridge.
- Services MUST configure filesystem, keystore, and biometric permissions with explicit path or identifier scopes rather than full native surface access.
- Components NEVER execute raw or dynamic string command invocations (`invoke(dynamicCmd, payload)`) without compile-time type safety and static command name literals.

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

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The frontend invoke uses unvalidated external parameters to access raw plugin functions, while the capability manifest applies global window wildcards ('*') and unbounded filesystem read permissions without restricting mobile sandbox paths.
```typescript
// Frontend: Arbitrary string invocation with unvalidated payload
import { invoke } from '@tauri-apps/api/core';

export async function readUserData(userPath: string): Promise<unknown> {
  // Anti-pattern: dynamic command execution without runtime schema validation
  return await invoke('plugin:fs|read_text_file', { path: userPath });
}

/* Anti-pattern in src-tauri/capabilities/default.json:
{
  "identifier": "default",
  "description": "Allows unrestricted native access",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:allow-read-text-file",
    "shell:allow-open"
  ]
}
*/
```

#### Production Standard (Correct)
> **Standard**: Frontend payloads are strictly parsed and validated against regex-enforced schemas prior to bridge transit. The Tauri 2.0 capability manifest explicitly isolates mobile platforms, targets the specific 'main' window, and constrains the native file reader to the app-scoped '$APPDATA/secure_profiles/*' directory.
```typescript
// Frontend: Strictly typed IPC wrapper with Zod schema validation
import { invoke } from '@tauri-apps/api/core';
import { z } from 'zod';

const SafeReadPayloadSchema = z.object({
  fileName: z.string().regex(/^[a-zA-Z0-9_-]+\.json$/,
    'Invalid filename format: alphanumeric JSON files only'
  )
});

type SafeReadPayload = z.infer<typeof SafeReadPayloadSchema>;

export async function readEncryptedProfile(payload: SafeReadPayload): Promise<string> {
  const validated = SafeReadPayloadSchema.parse(payload);
  return await invoke<string>('read_secure_profile', { fileName: validated.fileName });
}

/* Production standard in src-tauri/capabilities/mobile.json:
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "mobile-secure-context",
  "description": "Strictly scoped permissions for mobile WebViews",
  "windows": ["main"],
  "platforms": ["iOS", "android"],
  "permissions": [
    "core:default",
    {
      "identifier": "fs:allow-read-text-file",
      "allow": [{
        "path": "$APPDATA/secure_profiles/*"
      }]
    }
  ]
}
*/
```

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 Manifest Enforcement

Tauri 2.0 Scoped Mobile IPC Capability Manifest Enforcement defines an industrial-grade behavioral standard for mobile engineering. Enforces principle-of-least-privilege IPC capabilities across mobile WebView contexts in Tauri 2.0. Prohibits global wildcards, unisolated capabilities, and unconstrained native plugin bindings by mandating granular, window-scoped capability manifests with strict parameter validation. 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: Wildcard or Unscoped Native Plugin Permissions in Tauri 2.0 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 DriftWildcard or Unscoped Native Plugin Permissions in Tauri 2.0 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 manifest files (e.g., `src-tauri/capabilities/mobile.json`) strictly targeting mobile window labels.

Engineers MUST ALWAYS isolate mobile capabilities into dedicated manifest files (e.g., `src-tauri/capabilities/mobile.json`) strictly targeting mobile window 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 grant wildcard permissions (`*

Engineers MUST NOT grant wildcard permissions (`*:*`, `shell:allow-all`, or broad unconstrained plugin defaults) in any production capability manifest.

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 validate all IPC payloads on the frontend with runtime schema validation (e.g., Zod) prior to dispatching `invoke()` calls across the native bridge.

Code SHOULD validate all IPC payloads on the frontend with runtime schema validation (e.g., Zod) prior to dispatching `invoke()` calls across the native 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.
4

Services MUST configure filesystem, keystore, and biometric permissions with explicit path or identifier scopes rather than full native surface access.

Services MUST configure filesystem, keystore, and biometric permissions with explicit path or identifier scopes rather than full native surface access.

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 raw or dynamic string command invocations (`invoke(dynamicCmd, payload)`) without compile-time type safety and static command name literals.

Components NEVER execute raw or dynamic string command invocations (`invoke(dynamicCmd, payload)`) without compile-time type safety and static command name literals.

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 Manifest Enforcement critical for AI coding assistants?

Enforces principle-of-least-privilege IPC capabilities across mobile WebView contexts in Tauri 2.0. Prohibits global wildcards, unisolated capabilities, and unconstrained native plugin bindings by mandating granular, window-scoped capability manifests with strict parameter validation. 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 (Wildcard or Unscoped Native Plugin Permissions in Tauri 2.0 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