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

Tauri 2.0 Mobile Capability-Based IPC Permission Fence & Origin ACLs

Enforces granular, zero-trust IPC capability manifests in Tauri 2.0 mobile environments by strictly binding privileged native device APIs to validated webview identifiers and cryptographically pinned origins. Prohibits global wildcard capabilities and ambient native bridge exposure across mobile application boundaries.

Prohibited Anti-Pattern: Ambient Wildcard Capabilities Exposing Privileged Mobile Device APIs to Unverified Webviews

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Mobile Capability-Based IPC Permission Fence & Origin ACLs - Enforces granular, zero-trust IPC capability manifests in Tauri 2.0 mobile environments by strictly binding privileged native device APIs to validated webview identifiers and cryptographically pinned origins. Prohibits global wildcard capabilities and ambient native bridge exposure across mobile application boundaries.
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/tauri2-mobile-capability-ipc-permission-fence"
---

# Tauri 2.0 Mobile Capability-Based IPC Permission Fence & Origin ACLs

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Ambient Wildcard Capabilities Exposing Privileged Mobile Device APIs to Unverified Webviews

## System Constraints
You are a Principal Security Architect enforcing Tauri 2.0 Mobile Capability-Based IPC Permission Fences. You mandate zero-trust hardware capability segregation, explicit origin whitelisting, and strict separation between non-privileged UI webviews and sensitive native bridge commands (biometrics, secure enclave, hardware sensors). Prevent any ambient or wildcard permission assignments in mobile manifests.

## Strict Guidelines
- Manifests MUST define isolated capabilities under `src-tauri/capabilities/` targeting explicit mobile webviews rather than universal wildcards (`*`).
- Engineers MUST NOT grant high-privilege mobile permissions (biometrics, secure-storage, camera, filesystem) within a global or default capability manifest.
- Capabilities MUST pin remote origins using exact HTTPS schemes and specific subdomains when mobile webviews load remote assets.
- Rust command handlers MUST evaluate the invoking `tauri::ipc::Invoke` origin and webview label prior to executing native hardware calls.
- Frontend IPC invokers MUST be strongly typed and bound to explicit capability scopes, preventing dynamic, unvalidated command execution strings.

## Bad vs Good Implementations
### Tauri 2.0 Granular Capability Manifest Configuration

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Using wildcard window selectors ('*') and combining high-privilege hardware permissions (biometric, secure-storage) with the default capability allows untrusted iframes or hijacked webview origins to invoke native secure enclave routines without restriction.
```typescript
// src-tauri/capabilities/default.json (Anti-Pattern)
// Exposing sensitive mobile permissions globally with wildcard window targeting
const invalidCapability = {
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "default-capability",
  "description": "Broad wildcard capability exposing biometric auth to all contexts",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "biometric:allow-authenticate",
    "secure-storage:default"
  ]
};
```

#### Production Standard (Correct)
> **Standard**: Restricts biometric authentication to explicit webview identifiers and enforces an origin-based ACL ('tauri://localhost'), ensuring remote injected scripts or secondary webviews cannot dispatch IPC commands to the native authenticator.
```typescript
// src-tauri/capabilities/mobile-auth.json (Production Invariant)
// Zero-trust permission fence isolating biometric access to an authenticated webview
const validCapability = {
  "$schema": "../gen/schemas/mobile-schema.json",
  "identifier": "mobile-auth-capability",
  "description": "Restricted capability granting biometric auth exclusively to the secured main mobile view",
  "windows": ["main"],
  "webviews": ["main-auth-view"],
  "permissions": [
    "core:default",
    {
      "identifier": "biometric:allow-authenticate",
      "allow": [
        {
          "origin": "tauri://localhost"
        }
      ]
    }
  ]
};
```

### Frontend Type-Safe IPC Bridge with Origin Verification

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Bypasses frontend runtime defense-in-depth, triggering the native command without verifying that the current window context matches the expected secure capability target.
```typescript
import { invoke } from '@tauri-apps/api/core';

// Anti-pattern: Ambient, dynamically assembled invocation without webview/origin assertions
export async function unlockVault(accountNumber: string): Promise<string> {
  // Raw invocation vulnerable to origin spoofing if executed in an unvalidated context
  return await invoke<string>('authenticate_and_read_vault', { account: accountNumber });
}
```

#### Production Standard (Correct)
> **Standard**: Verifies that the calling webview label matches the capability-fenced target prior to IPC dispatch, passing cryptographic origin assertions down to the Rust native layer.
```typescript
import { invoke } from '@tauri-apps/api/core';
import { getCurrentWebview } from '@tauri-apps/api/webview';

interface VaultPayload {
  readonly account: string;
  readonly originAssertion: string;
}

// Production Invariant: Runtime assertion of webview boundary prior to invoking fenced native capabilities
export async function unlockVault(accountNumber: string): Promise<string> {
  const currentWebview = getCurrentWebview();
  
  if (currentWebview.label !== 'main-auth-view') {
    throw new Error(`Security Exception: Context '${currentWebview.label}' unauthorized for secure vault IPC`);
  }

  const payload: VaultPayload = {
    account: accountNumber,
    originAssertion: window.location.origin
  };

  return await invoke<string>('authenticate_and_read_vault', { payload });
}
```

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 Capability-Based IPC Permission Fence & Origin ACLs

Tauri 2.0 Mobile Capability-Based IPC Permission Fence & Origin ACLs defines an industrial-grade behavioral standard for mobile engineering. Enforces granular, zero-trust IPC capability manifests in Tauri 2.0 mobile environments by strictly binding privileged native device APIs to validated webview identifiers and cryptographically pinned origins. Prohibits global wildcard capabilities and ambient native bridge exposure across mobile application boundaries. 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: Ambient Wildcard Capabilities Exposing Privileged Mobile Device APIs to Unverified 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 DriftAmbient Wildcard Capabilities Exposing Privileged Mobile Device APIs to Unverified 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

Manifests MUST define isolated capabilities under `src-tauri/capabilities/` targeting explicit mobile webviews rather than universal wildcards (`*`).

Manifests MUST define isolated capabilities under `src-tauri/capabilities/` targeting explicit mobile webviews rather than universal wildcards (`*`).

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 high-privilege mobile permissions (biometrics, secure-storage, camera, filesystem) within a global or default capability manifest.

Engineers MUST NOT grant high-privilege mobile permissions (biometrics, secure-storage, camera, filesystem) within a global or default 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

Capabilities MUST pin remote origins using exact HTTPS schemes and specific subdomains when mobile webviews load remote assets.

Capabilities MUST pin remote origins using exact HTTPS schemes and specific subdomains when mobile webviews load remote assets.

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

Rust command handlers MUST evaluate the invoking `tauri

Rust command handlers MUST evaluate the invoking `tauri::ipc::Invoke` origin and webview label prior to executing native hardware calls.

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 be strongly typed and bound to explicit capability scopes, preventing dynamic, unvalidated command execution strings.

Frontend IPC invokers MUST be strongly typed and bound to explicit capability scopes, preventing dynamic, unvalidated command execution strings.

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 Capability-Based IPC Permission Fence & Origin ACLs critical for AI coding assistants?

Enforces granular, zero-trust IPC capability manifests in Tauri 2.0 mobile environments by strictly binding privileged native device APIs to validated webview identifiers and cryptographically pinned origins. Prohibits global wildcard capabilities and ambient native bridge exposure across mobile application boundaries. 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 (Ambient Wildcard Capabilities Exposing Privileged Mobile Device APIs to Unverified 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