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

Tauri 2.0 Granular IPC Command Capability Scoping & Shell Sandboxing

Enforces granular, least-privilege capability manifests in Tauri 2.0 to eliminate Remote Code Execution (RCE) vectors from compromised webview contexts. Mandates strict argument validation regexes, explicit window bindings, and forbids ambient or wildcard shell permissions.

Prohibited Anti-Pattern: Wildcard shell permissions and unbounded command execution via Tauri IPC.

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Granular IPC Command Capability Scoping & Shell Sandboxing - Enforces granular, least-privilege capability manifests in Tauri 2.0 to eliminate Remote Code Execution (RCE) vectors from compromised webview contexts. Mandates strict argument validation regexes, explicit window bindings, and forbids ambient or wildcard shell permissions.
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-ipc-granular-capability-scoping"
---

# Tauri 2.0 Granular IPC Command Capability Scoping & Shell Sandboxing

> **Severity**: CRITICAL | **Category**: security
> **Anti-Pattern Warning**: Wildcard shell permissions and unbounded command execution via Tauri IPC.

## System Constraints
You are a Principal Security Architect enforcing Tauri 2.0 Granular IPC Command Capability Scoping. Mandate invariants that prevent webview XSS-to-RCE pivots. Enforce explicit capability files under `src-tauri/capabilities/` with exact program paths, regex-bounded argument scopes, and isolated window targets. Forbid wildcard permissions (e.g., `shell:default`, `core:default`) and untyped raw string execution.

## Strict Guidelines
- Engineers MUST ALWAYS isolate native shell capabilities into specific manifest files under `src-tauri/capabilities/` targeted exclusively to designated window labels.
- Engineers MUST NOT grant broad plugin permissions such as `shell:default` or `shell:allow-execute` without strict argument array and regex constraints.
- Code MUST explicitly specify each allowed command, binary name, and regex-validated argument list in capability JSON manifests.
- Services MUST sanitize and strictly validate all dynamic arguments inside Rust-side custom IPC commands rather than passing arbitrary user input directly to `tauri_plugin_shell`.
- Components NEVER invoke shell commands directly from the frontend using raw strings or unsanitized external URIs via `open` or `execute` APIs.

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

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Grants ambient wildcard shell execution to all windows without command scoping or argument validation. Any Cross-Site Scripting (XSS) vulnerability immediately escalates to arbitrary Remote Code Execution (RCE).
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "main-capability",
  "description": "Insecure default shell access across all windows",
  "windows": ["*"],
  "permissions": [
    "core:default",
    "shell:default",
    "shell:allow-execute"
  ]
}
```

#### Production Standard (Correct)
> **Standard**: Scopes execution strictly to the 'main' window, restricts the binary to 'git', fixes permissible arguments, and bounds dynamic parameters with deterministic regular expressions.
```json
{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "main-capability",
  "description": "Least-privilege scoped git status command for main window",
  "windows": ["main"],
  "permissions": [
    "core:default",
    {
      "identifier": "shell:allow-execute",
      "allow": [
        {
          "name": "run-git-status",
          "cmd": "git",
          "args": ["status", "--porcelain"]
        },
        {
          "name": "run-git-log",
          "cmd": "git",
          "args": [
            "log",
            {
              "validator": "^-[nN] [0-9]{1,2}$"
            }
          ]
        }
      ]
    }
  ]
}
```

### Rust Custom IPC Command with Backend Validation

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Spawns an interactive shell process ('sh -c') taking unvalidated string input from the webview, leading directly to shell injection and arbitrary code execution.
```rust
// Insecure: passes untrusted string directly to system command execution
#[tauri::command]
pub async fn run_diagnostic(subcommand: String) -> Result<String, String> {
    let output = std::process::Command::new("sh")
        .arg("-c")
        .arg(format!("diagnostics {}", subcommand))
        .output()
        .map_err(|e| e.to_string())?;
    Ok(String::from_utf8_lossy(&output.stdout).to_string())
}
```

#### Production Standard (Correct)
> **Standard**: Uses strongly typed Rust enums to eliminate string concatenation, invokes absolute binary paths directly without intermediate shells, and enforces deterministic command arguments.
```rust
// Secure: typed enum input with strict allowlist and argument decoupling
#[derive(serde::Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum DiagnosticTarget {
    Network,
    Memory,
    Disk,
}

#[tauri::command]
pub async fn run_diagnostic(target: DiagnosticTarget) -> Result<String, String> {
    let arg = match target {
        DiagnosticTarget::Network => "--net",
        DiagnosticTarget::Memory => "--mem",
        DiagnosticTarget::Disk => "--disk",
    };

    let output = std::process::Command::new("/usr/local/bin/diagnostics-tool")
        .arg(arg)
        .output()
        .map_err(|e| format!("Execution failed: {e}"))?;

    Ok(String::from_utf8_lossy(&output.stdout).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 Granular IPC Command Capability Scoping & Shell Sandboxing

Tauri 2.0 Granular IPC Command Capability Scoping & Shell Sandboxing defines an industrial-grade behavioral standard for security engineering. Enforces granular, least-privilege capability manifests in Tauri 2.0 to eliminate Remote Code Execution (RCE) vectors from compromised webview contexts. Mandates strict argument validation regexes, explicit window bindings, and forbids ambient or wildcard shell permissions. 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 shell permissions and unbounded command execution via Tauri IPC. 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 shell permissions and unbounded command execution via Tauri IPC.Critical
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 native shell capabilities into specific manifest files under `src-tauri/capabilities/` targeted exclusively to designated window labels.

Engineers MUST ALWAYS isolate native shell capabilities into specific manifest files under `src-tauri/capabilities/` targeted exclusively to designated 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 broad plugin permissions such as `shell

Engineers MUST NOT grant broad plugin permissions such as `shell:default` or `shell:allow-execute` without strict argument array and regex constraints.

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 explicitly specify each allowed command, binary name, and regex-validated argument list in capability JSON manifests.

Code MUST explicitly specify each allowed command, binary name, and regex-validated argument list in capability JSON manifests.

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 sanitize and strictly validate all dynamic arguments inside Rust-side custom IPC commands rather than passing arbitrary user input directly to `tauri_plugin_shell`.

Services MUST sanitize and strictly validate all dynamic arguments inside Rust-side custom IPC commands rather than passing arbitrary user input directly to `tauri_plugin_shell`.

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 invoke shell commands directly from the frontend using raw strings or unsanitized external URIs via `open` or `execute` APIs.

Components NEVER invoke shell commands directly from the frontend using raw strings or unsanitized external URIs via `open` or `execute` APIs.

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 Granular IPC Command Capability Scoping & Shell Sandboxing critical for AI coding assistants?

Enforces granular, least-privilege capability manifests in Tauri 2.0 to eliminate Remote Code Execution (RCE) vectors from compromised webview contexts. Mandates strict argument validation regexes, explicit window bindings, and forbids ambient or wildcard shell permissions. 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 shell permissions and unbounded command execution via Tauri IPC.) 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