This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
securitycritical PriorityID: tauri-2-per-origin-ipc-capability-scoping-standard

Tauri 2.0 Per-Origin Dynamic IPC Capability Scoping Standard

Enforces granular, cryptographically attested per-origin capability configurations and command masking in Tauri 2.0. Replaces legacy global plugin allowlists with strictly scoped window and webview capabilities to prevent Remote Code Execution (RCE) via compromised DOM contexts or subresource injection.

Prohibited Anti-Pattern: Assigning wildcard permissions or global core capabilities to arbitrary webview windows

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Per-Origin Dynamic IPC Capability Scoping Standard - Enforces granular, cryptographically attested per-origin capability configurations and command masking in Tauri 2.0. Replaces legacy global plugin allowlists with strictly scoped window and webview capabilities to prevent Remote Code Execution (RCE) via compromised DOM contexts or subresource injection.
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/tauri-2-per-origin-ipc-capability-scoping-standard"
---

# Tauri 2.0 Per-Origin Dynamic IPC Capability Scoping Standard

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Assigning wildcard permissions or global core capabilities to arbitrary webview windows

## System Constraints
You are a Principal Security Architect enforcing the Tauri 2.0 Per-Origin Dynamic IPC Capability Scoping Standard. Mandate granular capabilities, prohibit global core plugin allowances, require explicit origin binding per window, and enforce IPC command token and scope validation in Rust handlers.

## Strict Guidelines
- Engineers MUST ALWAYS isolate distinct functional contexts (e.g., main app vs. untrusted previews) into separate Tauri 2.0 capability files located in 'src-tauri/capabilities/'.
- Engineers MUST NOT use wildcard targets ('*') in the 'windows' array or permit unrestricted plugins like 'core:default', 'shell:allow-execute', or 'fs:allow-read-all' across windows.
- Code MUST restrict filesystem, shell, and network capabilities to explicit path and URL masks using precise Tauri permission scopes (e.g., '$APP_DATA/documents/**').
- Services MUST validate the calling WebviewWindow identity in native Rust commands using 'tauri::ipc::Request' or window label checks before processing privileged operations.
- Components NEVER expose ambient, un-scoped Tauri invoke wrappers ('@tauri-apps/api/core/invoke') to third-party frames or dynamic subresource evaluation contexts.

## Bad vs Good Implementations
### Tauri 2.0 Capability Declaration (Anti-Pattern vs Invariant)

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Using '*' assigns dangerous core, fs, and shell capabilities to all current and future windows. Any webview navigating to an external origin or suffering XSS gains direct filesystem and process execution access.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "default-capability",
  "description": "Insecure global capability granting core and unrestricted fs to all windows",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "fs:default",
    "shell:default"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Explicitly binds permissions to the 'main' window label and constrains filesystem access to read-only operations within a specific, variable-interpolated application directory.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "authenticated-document-viewer",
  "description": "Least-privilege capability scoped exclusively to the primary authenticated window with restricted FS paths",
  "windows": ["main"],
  "permissions": [
    "core:event:allow-listen",
    {
      "identifier": "fs:allow-read-text-file",
      "allow": [
        { "path": "$APPDATA/secure-store/**" }
      ]
    }
  ]
}
```

### Rust IPC Handler Caller Attestation (Anti-Pattern vs Invariant)

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The command does not verify which webview invoked the action, allowing any window or secondary frame with IPC access to delete arbitrary tenant records.
```rust
// Insecure: Trusting payload arguments without validating the caller window origin
#[tauri::command]
pub async fn delete_tenant_record(tenant_id: String) -> Result<(), String> {
    database::delete_tenant(&tenant_id).await.map_err(|e| e.to_string())
}
```

#### Production Standard (Correct)
> **Standard**: Guarantees caller isolation by inspecting the 'WebviewWindow' label and cross-referencing tenant execution rights against state-managed session tokens.
```rust
// Secure: Attesting calling window identity and scoping parameters to caller context
#[tauri::command]
pub async fn delete_tenant_record(
    window: tauri::WebviewWindow,
    tenant_id: String,
    session: tauri::State<'_, SessionManager>
) -> Result<(), String> {
    if window.label() != "main" {
        return Err("Unauthorized IPC caller: Window context denied".into());
    }
    
    let verified_tenant = session.get_active_tenant(&window)
        .ok_or_else(|| "Invalid session state".to_string())?;

    if verified_tenant != tenant_id {
        return Err("Cross-tenant operation rejected".into());
    }

    database::delete_tenant(&verified_tenant).await.map_err(|e| e.to_string())
}
```

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 Per-Origin Dynamic IPC Capability Scoping Standard

Tauri 2.0 Per-Origin Dynamic IPC Capability Scoping Standard defines an industrial-grade behavioral standard for security engineering. Enforces granular, cryptographically attested per-origin capability configurations and command masking in Tauri 2.0. Replaces legacy global plugin allowlists with strictly scoped window and webview capabilities to prevent Remote Code Execution (RCE) via compromised DOM contexts or subresource injection. 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: Assigning wildcard permissions or global core capabilities to arbitrary webview windows 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 DriftAssigning wildcard permissions or global core capabilities to arbitrary webview windowsCritical
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 distinct functional contexts (e.g., main app vs. untrusted previews) into separate Tauri 2.0 capability files located in 'src-tauri/capabilities/'.

Engineers MUST ALWAYS isolate distinct functional contexts (e.g., main app vs. untrusted previews) into separate Tauri 2.0 capability files located in 'src-tauri/capabilities/'.

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 targets ('*') in the 'windows' array or permit unrestricted plugins like 'core

Engineers MUST NOT use wildcard targets ('*') in the 'windows' array or permit unrestricted plugins like 'core:default', 'shell:allow-execute', or 'fs:allow-read-all' across 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

Code MUST restrict filesystem, shell, and network capabilities to explicit path and URL masks using precise Tauri permission scopes (e.g., '$APP_DATA/documents/**').

Code MUST restrict filesystem, shell, and network capabilities to explicit path and URL masks using precise Tauri permission scopes (e.g., '$APP_DATA/documents/**').

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 validate the calling WebviewWindow identity in native Rust commands using 'tauri

Services MUST validate the calling WebviewWindow identity in native Rust commands using 'tauri::ipc::Request' or window label checks before processing privileged operations.

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 expose ambient, un-scoped Tauri invoke wrappers ('@tauri-apps/api/core/invoke') to third-party frames or dynamic subresource evaluation contexts.

Components NEVER expose ambient, un-scoped Tauri invoke wrappers ('@tauri-apps/api/core/invoke') to third-party frames or dynamic subresource evaluation 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.
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 Per-Origin Dynamic IPC Capability Scoping Standard critical for AI coding assistants?

Enforces granular, cryptographically attested per-origin capability configurations and command masking in Tauri 2.0. Replaces legacy global plugin allowlists with strictly scoped window and webview capabilities to prevent Remote Code Execution (RCE) via compromised DOM contexts or subresource injection. 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 (Assigning wildcard permissions or global core capabilities to arbitrary webview windows) 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.

1 Rule in Stack

Tauri