This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
mobilecritical PriorityID: tauri2-mobile-origin-acl-deep-link-guardrail

Tauri 2.0 Mobile Webview Origin ACL & Cryptographic Deep Link Guardrail

Mandates strict Origin Access Control Lists (ACLs) and cryptographic payload verification for OS-level deep link intents in Tauri 2.0 mobile architectures. Enforces zero-trust payload sanitization and signature verification before forwarding external custom scheme triggers to the Rust backend core to eliminate arbitrary remote command execution, privilege escalation, and cross-origin webview spoofing.

Prohibited Anti-Pattern: Blindly dispatching unauthenticated OS deep link parameters directly into Tauri native IPC invoke commands.

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Mobile Webview Origin ACL & Cryptographic Deep Link Guardrail - Mandates strict Origin Access Control Lists (ACLs) and cryptographic payload verification for OS-level deep link intents in Tauri 2.0 mobile architectures. Enforces zero-trust payload sanitization and signature verification before forwarding external custom scheme triggers to the Rust backend core to eliminate arbitrary remote command execution, privilege escalation, and cross-origin webview spoofing.
globs: src-tauri/src/**/*.rs, src-tauri/tauri.conf.json, src-tauri/capabilities/**/*.json, src/**/*.{ts,tsx}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tauri2-mobile-origin-acl-deep-link-guardrail"
---

# Tauri 2.0 Mobile Webview Origin ACL & Cryptographic Deep Link Guardrail

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Blindly dispatching unauthenticated OS deep link parameters directly into Tauri native IPC invoke commands.

## System Constraints
You are a Principal Software Architect enforcing the Tauri 2.0 Native Webview Origin ACL & Deep Link Interception Guardrail. In Tauri 2.0 mobile architectures (Android Intents and iOS Custom URL Schemes), incoming OS signals represent untrusted external boundaries. You must strictly forbid any pattern where external URIs dynamically determine IPC command names or execute native core functions without cryptographic intent verification, capability scoping, and cryptographic nonce validation.

## Strict Guidelines
- Engineers MUST ALWAYS configure strict Tauri 2.0 capability files with fine-grained permission scopes, never exposing wildcard (*) commands to webview contexts.
- Engineers MUST NOT allow dynamic string-based IPC dispatching (e.g., `invoke(urlParam.action)`) derived from incoming deep link URLs.
- Code MUST validate deep link authenticity using pre-shared state tokens, PKCE code verifiers, or asymmetric cryptographic signatures before mutating state or triggering native operations.
- Services MUST route all incoming OS custom schemes through a dedicated native Rust intent-sanitizer command that enforces scheme, host, and payload schema invariants.
- Components NEVER execute state mutations or privileged side effects directly from unauthenticated deep link listener callbacks.

## Bad vs Good Implementations
### Unvalidated Deep Link Dynamic Invocation vs. Cryptographically Verified Intent Dispatch

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Parsing dynamic command names and arbitrary payloads directly from an incoming OS deep link URL and forwarding them to `invoke()` allows any application on the device to execute arbitrary native core commands, completely bypassing Tauri's permission boundary.
```typescript
import { onOpenUrl } from '@tauri-apps/plugin-deep-link';
import { invoke } from '@tauri-apps/api/core';

// CRITICAL VULNERABILITY: Blind dynamic dispatch of OS-level custom scheme triggers
onOpenUrl(async (urls) => {
  for (const rawUrl of urls) {
    const parsed = new URL(rawUrl);
    const command = parsed.searchParams.get('cmd');
    const payload = JSON.parse(parsed.searchParams.get('payload') || '{}');

    if (command) {
      // Remote malicious apps can trigger arbitrary native Rust commands
      await invoke(command, payload);
    }
  }
});
```

#### Production Standard (Correct)
> **Standard**: Enforces strict protocol checking, structural schema validation via Zod, and delegates execution exclusively to an explicit, non-dynamic Rust command (`process_verified_deep_link`) which cryptographically validates state nonces and digital signatures before acting.
```typescript
import { onOpenUrl } from '@tauri-apps/plugin-deep-link';
import { invoke } from '@tauri-apps/api/core';
import { z } from 'zod';

const DeepLinkIntentSchema = z.object({
  route: z.enum(['oauth/callback', 'workspace/join']),
  stateNonce: z.string().uuid(),
  signature: z.string().min(64),
  payload: z.record(z.string(), z.string().max(256))
});

type ValidatedIntent = z.infer<typeof DeepLinkIntentSchema>;

onOpenUrl(async (urls) => {
  for (const rawUrl of urls) {
    try {
      const parsed = new URL(rawUrl);
      if (parsed.protocol !== 'myapp:') {
        console.warn('Rejected invalid scheme intent:', parsed.protocol);
        continue;
      }

      const rawPayload = parsed.searchParams.get('p');
      const candidate = {
        route: parsed.pathname.replace(/^\/\//, ''),
        stateNonce: parsed.searchParams.get('state'),
        signature: parsed.searchParams.get('sig'),
        payload: rawPayload ? JSON.parse(rawPayload) : {}
      };

      const validatedIntent: ValidatedIntent = DeepLinkIntentSchema.parse(candidate);

      // Dispatch exclusively to a locked-down, single-purpose Rust verification pipeline
      await invoke('process_verified_deep_link', { intent: validatedIntent });
    } catch (err) {
      console.error('Dropped untrusted deep link activation:', err);
    }
  }
});
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Tauri 2.0 Mobile Webview Origin ACL & Cryptographic Deep Link Guardrail

Tauri 2.0 Mobile Webview Origin ACL & Cryptographic Deep Link Guardrail defines an industrial-grade behavioral standard for mobile engineering. Mandates strict Origin Access Control Lists (ACLs) and cryptographic payload verification for OS-level deep link intents in Tauri 2.0 mobile architectures. Enforces zero-trust payload sanitization and signature verification before forwarding external custom scheme triggers to the Rust backend core to eliminate arbitrary remote command execution, privilege escalation, and cross-origin webview spoofing. 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: Blindly dispatching unauthenticated OS deep link parameters directly into Tauri native IPC invoke commands. 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 DriftBlindly dispatching unauthenticated OS deep link parameters directly into Tauri native IPC invoke commands.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 configure strict Tauri 2.0 capability files with fine-grained permission scopes, never exposing wildcard (*) commands to webview contexts.

Engineers MUST ALWAYS configure strict Tauri 2.0 capability files with fine-grained permission scopes, never exposing wildcard (*) commands to webview 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.
2

Engineers MUST NOT allow dynamic string-based IPC dispatching (e.g., `invoke(urlParam.action)`) derived from incoming deep link URLs.

Engineers MUST NOT allow dynamic string-based IPC dispatching (e.g., `invoke(urlParam.action)`) derived from incoming deep link 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.
3

Code MUST validate deep link authenticity using pre-shared state tokens, PKCE code verifiers, or asymmetric cryptographic signatures before mutating state or triggering native operations.

Code MUST validate deep link authenticity using pre-shared state tokens, PKCE code verifiers, or asymmetric cryptographic signatures before mutating state or triggering native 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.
4

Services MUST route all incoming OS custom schemes through a dedicated native Rust intent-sanitizer command that enforces scheme, host, and payload schema invariants.

Services MUST route all incoming OS custom schemes through a dedicated native Rust intent-sanitizer command that enforces scheme, host, and payload schema invariants.

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 execute state mutations or privileged side effects directly from unauthenticated deep link listener callbacks.

Components NEVER execute state mutations or privileged side effects directly from unauthenticated deep link listener callbacks.

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 Webview Origin ACL & Cryptographic Deep Link Guardrail critical for AI coding assistants?

Mandates strict Origin Access Control Lists (ACLs) and cryptographic payload verification for OS-level deep link intents in Tauri 2.0 mobile architectures. Enforces zero-trust payload sanitization and signature verification before forwarding external custom scheme triggers to the Rust backend core to eliminate arbitrary remote command execution, privilege escalation, and cross-origin webview spoofing. 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 (Blindly dispatching unauthenticated OS deep link parameters directly into Tauri native IPC invoke commands.) 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