Skip to content

Lesson 3 of 9 · 27m

Capabilities, CSP, and Remote Content Without Self-Deception

Use Tauri v2 capabilities, CSP, window scoping, and remote-content rules to keep renderer compromise from becoming workstation compromise.

Tauri's security model is not a magic aura around Rust. It is a set of explicit gates: which windows can use which APIs, what frontend content can load, where network requests may go, and which commands the renderer is allowed to invoke. Most real-world failures happen because a team enables a convenient permission globally and never revisits it.

Capabilities are authorization policy

In Tauri v2, capabilities live under src-tauri/capabilities/ and describe what a window or webview may use:

{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "main-window-capability",
  "windows": ["main"],
  "permissions": ["core:default", "fs:allow-read-text-file", "dialog:allow-open"]
}

The important detail is scoping. windows: ["main"] is a decision. windows: ["*"] is often a shortcut that future-you regrets when a settings window, updater window, or OAuth popup starts inheriting the same power.

Broad filesystem permissions are command bypasses

Suppose your Rust command carefully restricts project reads, but the frontend also has broad filesystem access. The command boundary no longer matters because the renderer can go around it. fs:allow-read-text-file, fs:allow-read-dir, and fs:allow-write-file are very different decisions, and scoped path allowlists are different again. Review generated permission schemas rather than memorizing names; plugin versions change.

CSP is for renderer blast-radius reduction

A content security policy cannot make malicious JavaScript safe, but it can make injection less useful. Tauri configuration can define a CSP such as:

{"app":{"security":{"csp":"default-src 'self'; connect-src 'self' https://api.internal.example; img-src 'self' data:; style-src 'self' 'unsafe-inline'"}}}

A tight policy is painful when you first enable it, which is exactly why teams postpone it forever. Start with the policy during initial development, while violations are small. Retrofitting CSP after a UI framework, analytics loader, font CDN, and markdown renderer have accumulated is archaeology.

Remote content changes the threat model

Loading https://app.vendor.example inside a Tauri window is not inherently wrong, but it means the remote site now sits inside your desktop privilege context. If that remote frontend is compromised, hostile content may try to invoke desktop capabilities. For remote windows:

separate window label
separate capability file
minimum permissions
no broad filesystem/shell/dialog access
strict CSP connect-src

A local-first app and a thin shell around a remote web app are different products. Do not copy permissions from one to the other.

Dangerous capability combinations

Individual permissions can look harmless in isolation. Threat-model combinations instead: external URL opening plus shell access, arbitrary file reads plus network upload, arbitrary writes plus update execution, clipboard reads plus persistence. A renderer that can read files and make arbitrary network requests is an exfiltration primitive even if neither permission looks dramatic alone.

Field notes

  • Review capabilities in every dependency upgrade; plugin permission identifiers and defaults can change.
  • Keep a deny-by-default posture for new windows. Convenience windows accumulate power silently.
  • CSP reporting is useful in development, but desktop apps often lack a report endpoint; console violations are still valuable.
  • Test production builds. Dev servers often require looser policies and can hide what the packaged app will actually enforce.

Was this lesson helpful?

Sign in to rate