This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
mobilecritical PriorityID: tauri-2-scoped-capability-webview-sandboxing

Tauri 2.0 Scoped Capability Multi-Webview IPC Sandboxing Standard

Enforces deterministic, window-specific capability isolation across Tauri 2.0 multi-webview architectures to eliminate cross-webview privilege escalation and unauthorized native plugin execution. Prevents shared IPC bridge exposure by requiring fine-grained capability definitions scoped strictly to verified webview and window labels. Guarantees that untrusted or secondary webviews cannot invoke privileged core APIs or native mobile plugins.

Prohibited Anti-Pattern: Wildcard Window Scoping and Monolithic Capability Binding Across Heterogeneous Webviews

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Scoped Capability Multi-Webview IPC Sandboxing Standard - Enforces deterministic, window-specific capability isolation across Tauri 2.0 multi-webview architectures to eliminate cross-webview privilege escalation and unauthorized native plugin execution. Prevents shared IPC bridge exposure by requiring fine-grained capability definitions scoped strictly to verified webview and window labels. Guarantees that untrusted or secondary webviews cannot invoke privileged core APIs or native mobile plugins.
globs: src-tauri/capabilities/**/*.json, src-tauri/tauri.conf.json, src-tauri/src/**/*.rs, src/**/*.ts, src/**/*.tsx
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tauri-2-scoped-capability-webview-sandboxing"
---

# Tauri 2.0 Scoped Capability Multi-Webview IPC Sandboxing Standard

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Wildcard Window Scoping and Monolithic Capability Binding Across Heterogeneous Webviews

## System Constraints
You are a Principal Security Architect enforcing the Tauri 2.0 Scoped Capability Multi-Webview IPC Sandboxing Standard. Mandate strict window and webview label isolation across all Tauri capability manifests and IPC endpoints. Reject any configuration assigning global wildcard permissions or exposing high-privilege native mobile plugins (e.g., filesystem, biometrics, secure storage) to secondary or untrusted webviews. Verify that all IPC invocations validate caller identity and ensure capability scopes strictly delineate permissions per window boundary.

## Strict Guidelines
- Engineers MUST ALWAYS isolate permissions across distinct JSON capability files in `src-tauri/capabilities/`, mapping specific window labels explicitly in the `windows` property.
- Engineers MUST NOT use wildcard syntax (`*`) in the `windows` array of capability files containing sensitive native plugins (e.g., `fs`, `sql`, `biometric`, `http`).
- Engineers MUST explicitly restrict webview execution context by assigning unique `window` and `webview` labels upon creation in multi-webview mobile layouts.
- Code SHOULD enforce runtime label verification via `tauri::ipc::Request` or `tauri::WebviewWindow` checks in custom Rust commands handling privileged state transformations.
- Services MUST NEVER invoke un-namespaced or unrestricted invoke commands (`core:default` or global wildcard permissions) from untrusted child or authentication webviews.
- Components NEVER expose global window Tauri internals (`window.__TAURI_INTERNALS__`) into webviews rendering external or remote URLs.

## Bad vs Good Implementations
### Tauri 2.0 Capability Manifest Scoping

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Using wildcard 'windows': ['*'] grants every webview, including secondary, iframe-bearing, or auth popup windows, unrestricted access to the filesystem and biometric authentication.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "default-capability",
  "description": "Monolithic capability exposed to all windows",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:default",
    "fs:allow-read-text-file",
    "biometric:authenticate"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Explicitly restricts high-privilege native plugins and commands to the verified 'main' window label and scopes filesystem access to specific application-defined paths.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "main-window-privileged-capability",
  "description": "Strictly scoped capability for authenticated main webview",
  "windows": ["main"],
  "permissions": [
    "core:default",
    {
      "identifier": "fs:allow-read-text-file",
      "allow": [{
        "path": "$APPDATA/documents/*"
      }]
    },
    "biometric:authenticate"
  ]
}
```

### Rust IPC Command Window Identity Invariant

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Omitting window context parameters in privileged custom commands allows any compromised webview or untrusted popup capable of sending IPC messages to execute the command.
```rust
#[tauri::command]
pub async fn read_secure_vault(key: String) -> Result<String, String> {
    // Anti-pattern: Accepts invoke request from any webview caller without window verification
    let secret = fetch_vault_secret(&key).await;
    Ok(secret)
}
```

#### Production Standard (Correct)
> **Standard**: Injects WebviewWindow to extract and assert the caller's label identity, blocking unauthorized cross-webview command execution even if capability constraints are breached.
```rust
use tauri::{command, Runtime, WebviewWindow};

#[command]
pub async fn read_secure_vault<R: Runtime>(
    window: WebviewWindow<R>,
    key: String
) -> Result<String, String> {
    // Invariant: Verify IPC origin strictly belongs to the authoritative main window
    if window.label() != "main" {
        return Err("Unauthorized: Webview label forbidden from accessing secure vault".into());
    }
    
    let secret = fetch_vault_secret(&key).await;
    Ok(secret)
}
```

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 Capability Multi-Webview IPC Sandboxing Standard

Tauri 2.0 Scoped Capability Multi-Webview IPC Sandboxing Standard defines an industrial-grade behavioral standard for mobile engineering. Enforces deterministic, window-specific capability isolation across Tauri 2.0 multi-webview architectures to eliminate cross-webview privilege escalation and unauthorized native plugin execution. Prevents shared IPC bridge exposure by requiring fine-grained capability definitions scoped strictly to verified webview and window labels. Guarantees that untrusted or secondary webviews cannot invoke privileged core APIs or native mobile plugins. 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 Window Scoping and Monolithic Capability Binding Across Heterogeneous 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 Window Scoping and Monolithic Capability Binding Across Heterogeneous 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 permissions across distinct JSON capability files in `src-tauri/capabilities/`, mapping specific window labels explicitly in the `windows` property.

Engineers MUST ALWAYS isolate permissions across distinct JSON capability files in `src-tauri/capabilities/`, mapping specific window labels explicitly in the `windows` property.

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 syntax (`*`) in the `windows` array of capability files containing sensitive native plugins (e.g., `fs`, `sql`, `biometric`, `http`).

Engineers MUST NOT use wildcard syntax (`*`) in the `windows` array of capability files containing sensitive native plugins (e.g., `fs`, `sql`, `biometric`, `http`).

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 explicitly restrict webview execution context by assigning unique `window` and `webview` labels upon creation in multi-webview mobile layouts.

Engineers MUST explicitly restrict webview execution context by assigning unique `window` and `webview` labels upon creation in multi-webview mobile layouts.

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

Code SHOULD enforce runtime label verification via `tauri

Code SHOULD enforce runtime label verification via `tauri::ipc::Request` or `tauri::WebviewWindow` checks in custom Rust commands handling privileged state transformations.

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

Services MUST NEVER invoke un-namespaced or unrestricted invoke commands (`core

Services MUST NEVER invoke un-namespaced or unrestricted invoke commands (`core:default` or global wildcard permissions) from untrusted child or authentication webviews.

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

Components NEVER expose global window Tauri internals (`window.__TAURI_INTERNALS__`) into webviews rendering external or remote URLs.

Components NEVER expose global window Tauri internals (`window.__TAURI_INTERNALS__`) into webviews rendering external or remote URLs.

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

Enforces deterministic, window-specific capability isolation across Tauri 2.0 multi-webview architectures to eliminate cross-webview privilege escalation and unauthorized native plugin execution. Prevents shared IPC bridge exposure by requiring fine-grained capability definitions scoped strictly to verified webview and window labels. Guarantees that untrusted or secondary webviews cannot invoke privileged core APIs or native mobile plugins. 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 Window Scoping and Monolithic Capability Binding Across Heterogeneous 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