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

Tauri 2.0 Scope-Bound IPC Capability Sandboxing for Multi-Webview Surfaces

Enforces declarative, compile-time capability sandboxing across multi-webview surfaces in Tauri 2.0 mobile and desktop targets. Restricts low-level OS IPC bindings by guaranteeing non-primary webviews operate under least-privilege capability files without ambient system access.

Prohibited Anti-Pattern: Ambient Wildcard Capabilities and Shared IPC Contexts on Secondary Webview Surfaces

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Scope-Bound IPC Capability Sandboxing for Multi-Webview Surfaces - Enforces declarative, compile-time capability sandboxing across multi-webview surfaces in Tauri 2.0 mobile and desktop targets. Restricts low-level OS IPC bindings by guaranteeing non-primary webviews operate under least-privilege capability files without ambient system access.
globs: src-tauri/capabilities/**/*.json, src-tauri/tauri.conf.json, src/**/*.{ts,tsx}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tauri2-scope-bound-ipc-capability-sandboxing"
---

# Tauri 2.0 Scope-Bound IPC Capability Sandboxing for Multi-Webview Surfaces

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Ambient Wildcard Capabilities and Shared IPC Contexts on Secondary Webview Surfaces

## System Constraints
You are a Principal Security Architect enforcing Tauri 2.0 Scope-Bound IPC Capability Sandboxing. Secondary webview surfaces (e.g., OAuth flows, in-app browsers, third-party plugin renderers) must never inherit ambient root capabilities or execute unrestricted system calls. Mandate explicit capability configuration files with strict webview window label matching, precise permission identifiers, and runtime invoke isolation.

## Strict Guidelines
- Engineers MUST ALWAYS isolate secondary webviews by assigning explicit, non-wildcard window/webview labels in `src-tauri/capabilities/*.json`.
- Engineers MUST NOT grant core OS permissions (e.g., `fs:default`, `shell:allow-open`, `process:default`) to non-main webview windows.
- Capability configuration files MUST explicitly define granular scopes (e.g., restricting `fs:allow-read` to specific AppData subdirectories instead of full disk access).
- Frontend IPC invocations from secondary surfaces MUST route through strongly-typed, audited wrappers that gracefully catch and handle Tauri ACL permission errors (Code: `COMMAND_NOT_ALLOWED`).
- Components NEVER assume ambient plugin availability across webview boundaries without validating surface context and origin.

## Bad vs Good Implementations
### Restricting IPC Invocations to Capability-Safe Boundaries

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Directly calling high-privilege native filesystem plugins without surface context verification assumes ambient capabilities, which either creates an ACL privilege escalation vulnerability or crashes with unhandled IPC capability rejections on restricted webview targets.
```typescript
import { invoke } from '@tauri-apps/api/core';

// ANTI-PATTERN: Blindly executing high-privilege IPC commands from any webview
// surface assuming global capability grants exist across all mobile webviews.
export async function exportUserReport(payload: { reportId: string }): Promise<void> {
  // In a secondary or untrusted webview, this bypasses client-side context checks
  // and fails unpredictably if ambient permissions are loosely configured.
  await invoke('plugin:fs|write_file', {
    path: `/sdcard/Download/report_${payload.reportId}.pdf`,
    contents: []
  });
}
```

#### Production Standard (Correct)
> **Standard**: Validates the calling surface window label against compile-time capability bounds before invocation and routes through a sandboxed domain command rather than a broad ambient filesystem plugin call, safely handling capability rejections.
```typescript
import { invoke } from '@tauri-apps/api/core';
import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow';

interface SafeExportPayload {
  reportId: string;
  data: Uint8Array;
}

// PRODUCTION FIX: Webview-aware invocation bound to strict capability contracts
export async function exportUserReport(payload: SafeExportPayload): Promise<{ success: boolean; error?: string }> {
  const currentWindow = getCurrentWebviewWindow();
  
  // Invariant: Restrict privileged system actions to the verified primary shell surface
  if (currentWindow.label !== 'main') {
    console.error(`Rejected IPC call 'exportUserReport' from unauthorized webview: ${currentWindow.label}`);
    return { success: false, error: 'PERMISSION_DENIED: Webview surface not permitted.' };
  }

  try {
    // Invokes custom domain command with scope-validated capabilities defined in src-tauri/capabilities/main.json
    await invoke('save_sandboxed_report', {
      reportId: payload.reportId,
      bytes: Array.from(payload.data)
    });
    return { success: true };
  } catch (err: unknown) {
    const message = err instanceof Error ? err.message : String(err);
    return { success: false, error: `Capability execution failed: ${message}` };
  }
}
```

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 Scope-Bound IPC Capability Sandboxing for Multi-Webview Surfaces

Tauri 2.0 Scope-Bound IPC Capability Sandboxing for Multi-Webview Surfaces defines an industrial-grade behavioral standard for mobile engineering. Enforces declarative, compile-time capability sandboxing across multi-webview surfaces in Tauri 2.0 mobile and desktop targets. Restricts low-level OS IPC bindings by guaranteeing non-primary webviews operate under least-privilege capability files without ambient system access. 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 and Shared IPC Contexts on Secondary Webview Surfaces 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 and Shared IPC Contexts on Secondary Webview SurfacesCritical
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 secondary webviews by assigning explicit, non-wildcard window/webview labels in `src-tauri/capabilities/*.json`.

Engineers MUST ALWAYS isolate secondary webviews by assigning explicit, non-wildcard window/webview labels in `src-tauri/capabilities/*.json`.

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 core OS permissions (e.g., `fs

Engineers MUST NOT grant core OS permissions (e.g., `fs:default`, `shell:allow-open`, `process:default`) to non-main webview windows.

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

Capability configuration files MUST explicitly define granular scopes (e.g., restricting `fs

Capability configuration files MUST explicitly define granular scopes (e.g., restricting `fs:allow-read` to specific AppData subdirectories instead of full disk 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.
4

Frontend IPC invocations from secondary surfaces MUST route through strongly-typed, audited wrappers that gracefully catch and handle Tauri ACL permission errors (Code

Frontend IPC invocations from secondary surfaces MUST route through strongly-typed, audited wrappers that gracefully catch and handle Tauri ACL permission errors (Code: `COMMAND_NOT_ALLOWED`).

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 assume ambient plugin availability across webview boundaries without validating surface context and origin.

Components NEVER assume ambient plugin availability across webview boundaries without validating surface context and origin.

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 Scope-Bound IPC Capability Sandboxing for Multi-Webview Surfaces critical for AI coding assistants?

Enforces declarative, compile-time capability sandboxing across multi-webview surfaces in Tauri 2.0 mobile and desktop targets. Restricts low-level OS IPC bindings by guaranteeing non-primary webviews operate under least-privilege capability files without ambient system access. 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 and Shared IPC Contexts on Secondary Webview Surfaces) 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