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

Tauri 2.0 Deep-Link Cryptographic Origin Attestation & IPC Boundary Standard

Enforces cryptographic attestation, ephemeral state verification, and strict origin validation on all deep-link scheme payloads at the Tauri 2.0 native Rust boundary before dispatching events across the inner IPC bus. Defends against custom URI scheme hijacking and intent interception on mobile operating systems where malicious applications register identical schemes.

Prohibited Anti-Pattern: Direct Forwarding of Unverified Custom Scheme Payloads to Tauri IPC Bus

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Tauri 2.0 Deep-Link Cryptographic Origin Attestation & IPC Boundary Standard - Enforces cryptographic attestation, ephemeral state verification, and strict origin validation on all deep-link scheme payloads at the Tauri 2.0 native Rust boundary before dispatching events across the inner IPC bus. Defends against custom URI scheme hijacking and intent interception on mobile operating systems where malicious applications register identical schemes.
globs: src-tauri/src/**/*.rs, src-tauri/Cargo.toml, src-tauri/tauri.conf.json, src/services/**/*.{ts,tsx}, src/hooks/**/*.{ts,tsx}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/tauri-v2-deep-link-origin-attestation"
---

# Tauri 2.0 Deep-Link Cryptographic Origin Attestation & IPC Boundary Standard

> **Severity**: CRITICAL | **Category**: mobile
> **Anti-Pattern Warning**: Direct Forwarding of Unverified Custom Scheme Payloads to Tauri IPC Bus

## System Constraints
You are a Principal Security Architect enforcing the Tauri 2.0 Deep-Link Origin Cryptographic Attestation Standard. On Android and iOS, custom URL schemes can be registered and hijacked by rogue applications on the same device. You must guarantee that all deep-link payloads entering the native Rust host are strictly validated against active cryptographic sessions (e.g., PKCE, signed JWTs with pinned public keys, or platform attestation tokens) before any payload reaches the frontend WebView via Tauri's inner IPC bus (app.emit or window.emit).

## Strict Guidelines
- Engineers MUST ALWAYS validate custom scheme payloads in Rust native space before forwarding events to the WebView.
- Engineers MUST NOT forward raw, unparsed, or unverified deep-link URLs directly across the Tauri IPC bus (e.g., using app.emit("deep-link", url)).
- Native handlers MUST verify an ephemeral cryptographic nonce (such as a high-entropy PKCE state or Ed25519 payload signature) stored in memory or a secure enclave prior to executing any associated deep-link action.
- Tauri 2.0 configurations MUST prioritize Universal Links (iOS) and Android App Links with verified domain associations over custom schemes wherever possible.
- Frontend listeners MUST NEVER assume incoming deep-link events are authentic; they MUST receive only structured, pre-validated payloads emitted from verified Rust commands.
- Deep-link routing logic MUST drop and audit-log any payload that fails signature validation, replay-detection checks, or schema verification.

## Bad vs Good Implementations
### Tauri 2.0 Rust Native Deep-Link Handler with Cryptographic Attestation

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Custom URI schemes on mobile (e.g., myapp://) lack ownership enforcement; rogue apps can hijack the scheme or trigger intent redirection. Emitting raw URLs directly to the IPC bus allows arbitrary cross-app command injection or authorization code theft.
```rust
// VULNERABLE: Direct forward of unvalidated deep link from plugin to webview
use tauri_plugin_deep_link::DeepLinkExt;

pub fn setup_deep_links(app: &mut tauri::App) -> Result<(), Box<dyn std::error::Error>> {
    app.deep_link().on_open_url(|event| {
        for url in event.urls() {
            // Forwarding unverified custom-scheme payload directly to IPC bus
            let _ = app.emit("deep-link-received", url.as_str());
        }
    });
    Ok(())
}
```

#### Production Standard (Correct)
> **Standard**: Validates the deep-link in native Rust before the WebView IPC is notified. It validates single-use ephemeral nonces and checks cryptographic signatures against pinned public keys, mitigating scheme squatting and intent hijacking.
```rust
// SECURE: Intercept, parse, and cryptographically verify nonce and signature before IPC emission
use ring::signature;
use tauri::{AppHandle, Emitter, Manager};
use tauri_plugin_deep_link::DeepLinkExt;
use url::Url;

#[derive(Clone, serde::Serialize)]
pub struct VerifiedDeepLinkPayload {
    pub action: String,
    pub payload: String,
}

pub fn setup_deep_links(app: &mut tauri::App) -> Result<(), Box<dyn std::error::Error>> {
    let handle = app.handle().clone();
    app.deep_link().on_open_url(move |event| {
        for url in event.urls() {
            if let Err(err) = process_and_attest_link(&handle, &url) {
                log::warn!("Rejected unauthorized deep link {}: {}", url, err);
            }
        }
    });
    Ok(())
}

fn process_and_attest_link(app: &AppHandle, raw_url: &Url) -> Result<(), &'static str> {
    let query: std::collections::HashMap<_, _> = raw_url.query_pairs().into_owned().collect();
    let nonce = query.get("state").ok_or("Missing state nonce")?;
    let sig = query.get("sig").ok_or("Missing payload signature")?;
    let payload = query.get("data").ok_or("Missing payload data")?;

    // Verify ephemeral state stored in managed Rust state to thwart replay/hijack
    let state_manager = app.state::<crate::auth::ActiveNonceStore>();
    if !state_manager.validate_and_consume(nonce) {
        return Err("Invalid or expired replay-prevention nonce");
    }

    // Verify asymmetric signature of the payload using pinned public key
    crate::crypto::verify_ed25519_signature(payload.as_bytes(), sig)?;

    let verified = VerifiedDeepLinkPayload {
        action: raw_url.path().to_string(),
        payload: payload.to_string(),
    };

    app.emit("secure:deep-link", verified)
        .map_err(|_| "IPC emission failure")?;
    Ok(())
}
```

### TypeScript Frontend Safe Event Binding

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: The frontend processes raw URL strings emitted without cryptographic verification, trusting parameters passed by potentially malicious third-party apps invoking the custom scheme.
```typescript
// VULNERABLE: Listening to raw, untrusted deep-link strings and routing unconditionally
import { listen } from '@tauri-apps/api/event';

listen<string>('deep-link-received', (event) => {
  const url = new URL(event.payload);
  const token = url.searchParams.get('token');
  // Storing unverified token leaked from hijacked scheme
  if (token) {
    localStorage.setItem('auth_token', token);
  }
});
```

#### Production Standard (Correct)
> **Standard**: Frontend only binds to the cryptographically attested internal channel ('secure:deep-link') which receives pre-validated, typed data produced after native Rust attestation.
```typescript
// SECURE: Bind strictly to attested events emitting structured, verified payloads
import { listen, type UnlistenFn } from '@tauri-apps/api/event';

interface VerifiedDeepLink {
  action: string;
  payload: string;
}

export async function registerSecureDeepLinkHandler(
  onAction: (data: VerifiedDeepLink) => void
): Promise<UnlistenFn> {
  return listen<VerifiedDeepLink>('secure:deep-link', (event) => {
    // Payload has already undergone cryptographic attestation in Rust native host
    onAction(event.payload);
  });
}
```

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 Deep-Link Cryptographic Origin Attestation & IPC Boundary Standard

Tauri 2.0 Deep-Link Cryptographic Origin Attestation & IPC Boundary Standard defines an industrial-grade behavioral standard for mobile engineering. Enforces cryptographic attestation, ephemeral state verification, and strict origin validation on all deep-link scheme payloads at the Tauri 2.0 native Rust boundary before dispatching events across the inner IPC bus. Defends against custom URI scheme hijacking and intent interception on mobile operating systems where malicious applications register identical schemes. 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: Direct Forwarding of Unverified Custom Scheme Payloads to Tauri IPC Bus 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 DriftDirect Forwarding of Unverified Custom Scheme Payloads to Tauri IPC BusCritical
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 validate custom scheme payloads in Rust native space before forwarding events to the WebView.

Engineers MUST ALWAYS validate custom scheme payloads in Rust native space before forwarding events to the WebView.

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 forward raw, unparsed, or unverified deep-link URLs directly across the Tauri IPC bus (e.g., using app.emit("deep-link", url)).

Engineers MUST NOT forward raw, unparsed, or unverified deep-link URLs directly across the Tauri IPC bus (e.g., using app.emit("deep-link", url)).

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

Native handlers MUST verify an ephemeral cryptographic nonce (such as a high-entropy PKCE state or Ed25519 payload signature) stored in memory or a secure enclave prior to executing any associated deep-link action.

Native handlers MUST verify an ephemeral cryptographic nonce (such as a high-entropy PKCE state or Ed25519 payload signature) stored in memory or a secure enclave prior to executing any associated deep-link action.

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

Tauri 2.0 configurations MUST prioritize Universal Links (iOS) and Android App Links with verified domain associations over custom schemes wherever possible.

Tauri 2.0 configurations MUST prioritize Universal Links (iOS) and Android App Links with verified domain associations over custom schemes wherever possible.

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

Frontend listeners MUST NEVER assume incoming deep-link events are authentic

Frontend listeners MUST NEVER assume incoming deep-link events are authentic; they MUST receive only structured, pre-validated payloads emitted from verified Rust commands.

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

Deep-link routing logic MUST drop and audit-log any payload that fails signature validation, replay-detection checks, or schema verification.

Deep-link routing logic MUST drop and audit-log any payload that fails signature validation, replay-detection checks, or schema verification.

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 Deep-Link Cryptographic Origin Attestation & IPC Boundary Standard critical for AI coding assistants?

Enforces cryptographic attestation, ephemeral state verification, and strict origin validation on all deep-link scheme payloads at the Tauri 2.0 native Rust boundary before dispatching events across the inner IPC bus. Defends against custom URI scheme hijacking and intent interception on mobile operating systems where malicious applications register identical schemes. 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 (Direct Forwarding of Unverified Custom Scheme Payloads to Tauri IPC Bus) 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