Status: accepted (2026-11-09); revised 2026-11-10, proposed; decision 8 revised 2026-11-12, after WebKit's IPC handler was found in a frame: the plugin is the Tauri adapter of hosting CompMD: it compiles the app's bundle into the app, serves it and the pack store on a scheme, and gives the page the origin (decisions 2 to 7 and 11; what changes from 0.6.0). How a Tauri app shows CompMD documents: tauri-plugin-compmd, and an example app in this repository that uses it and checks itself in a real webview, as a guide for hosts and as a test CI runs before every release.
A Tauri app's pages come from its own scheme (tauri://localhost on macOS and Linux, http://tauri.localhost on Windows and Android), which Tauri serves from the app's bundle. The sandbox's frames need an origin of their own, apart from the app's, so that a frame's code can't reach the app's page or its commands (decision 1 of the sandbox's design). An app gets one by registering a URI scheme for the frames. What the handler of that scheme must do is the same in every app, and each detail of it matters for safety, so CompMD writes it once:
- WebKit (macOS, iOS and Linux) reads
'self'in a sandboxed frame on a custom scheme as matching nothing, so the frames' policies must name where they are served (buildFrames'ssource), or no frame loads its runtime; - WebKit caches a custom scheme's responses, so a frame document replaced at the same path can keep running its old version after the app is upgraded, and the frames and the page then speak different protocol versions;
- the frames must be served with the headers that sandbox them, and nothing else on that scheme may be served.
Each of these, and whatever a platform or Tauri changes later, is then found and fixed in one place, for every app that uses the plugin.
-
A crate,
tauri-plugin-compmd, incrates/tauri/of this repository, released with the implementation's version, by the same release workflow ascompmd(releases, decision 5). It depends ontauriandcompmd-host(hosting, decision 1), not on the processor: an app that processes documents in its page, with@compmd/processor, uses the plugin as well as one that processes them in Rust. It is outside the main Cargo workspace (its ownCargo.tomland lock file), socargo make cidoesn't build Tauri; its tests run in the Tauri check (decision 9). -
The plugin is the Tauri adapter, and nothing more (revised 2026-11-10). What every host does is shared (hosting): the configuration (
compmd.config.json), the bundle (@compmd/vite, from the@compmd/sandboxthe page imports), the pack store, the serving contract (compmd-host'srespond) and the check. The plugin does the four things only Tauri can: it compiles the bundle into the app, registers the scheme and passes its requests torespond, gives the page the origin, and gives the store a folder. It brings no frames of its own: a page's frames always come from the page's own package. -
Two calls, in
build.rsand inmain. The app'sbuild.rscallstauri_plugin_compmd::build::bundle("compmd")(the crate as a build dependency, with itsbuildfeature), which reads the bundle'smanifest.jsonin that folder, writes the Rust that embeds its files withinclude_bytes!intoOUT_DIR, and tells Cargo to build again when the manifest changes. The app'smainpasses it to the plugin:.plugin(tauri_plugin_compmd::init(tauri_plugin_compmd::include_bundle!())). The binary carries its bundle: no resource to bundle, no file read at startup.build::bundlerefuses a manifest of a format it doesn't know, with what to upgrade; a checkout that didn't build the bundle compiles with a warning and serves nothing, which the page reports (error). Tests make a bundle of their own,Bundle::from_files, socargo testneeds no JavaScript build. -
The scheme serves the contract, through
compmd-host'srespond(hosting, decision 8):frames/<hash>/from the bundle,packs/<place>from the bundle or the store, with the contract's methods, paths, refusals and headers. The plugin adds nothing to it and changes nothing in it: a header the check needs, or a rule WebKit wants, is fixed inrespond, for every host. -
The page gets the origin from an initialization script, and the rest from its own bundle (hosting, decision 9): the script (the app's own pages, main frame only) sets
globalThis.__COMPMD__ = { origin },<scheme>://localhost, orhttp://<scheme>.localhoston Windows and Android, where Tauri serves custom schemes over http.createSandbox({ ...sandbox, page: "host" }), withsandboxfromvirtual:compmd, reads it. The page makes no call: the plugin has no command and no permission to grant. Rust code gets the origin and the manifest fromapp.compmd(). -
The scheme is the one the bundle was built for. WebKit needs the frames' policies to name where they are served (above), so the bundle is built with the custom-scheme form as its
source(compmd({ source: "compmd://localhost/" })in the app's Vite configuration), which the manifest records; the plugin registers the scheme the manifest names, so the two can't disagree. The scheme is the app's choice (compmdif it has no reason for another). On Windows and Android, where'self'already matches, the source names nothing there and is harmless, so one bundle serves every platform. -
The page's content security policy is
cspForof the origin (hosting, decision 10), pasted intoapp.security.cspintauri.conf.json, which the plugin can't write (Tauri compiles it from the file). An app without one, as Tauri's template is, adds nothing. Both forms of the origin go in:frame-srcthe scheme,script-srcandconnect-src<origin>/frames/,script-src'wasm-unsafe-eval'for highlighting with Oniguruma, never<origin>/packs/, andframe-ancestors 'none'. -
No frame reaches a Tauri command, since no frame has Tauri's invoke key (revised 2026-11-09, when the example's test found that a capability doesn't do it). Tauri counts a page on any scheme the app registers as one of the app's own (
is_local_url, on macOS and Linux), so the capability of the frames' window covers the frames' scheme too: listing it or not changes nothing. What keeps a frame's code from the app's commands is Tauri's invoke key: every call must carry it, and Tauri puts it only into the main frame's IPC script (for_main_frame_only), which a frame, an opaque origin in another document, can't read. The tests show both halves: a call from the scheme without the key is refused, and in the real webview the strict component in the example finds no Tauri in its frame (no__TAURI_INTERNALS__). On WebKit a frame does have Tauri's IPC message handler,window.webkit.messageHandlers.ipc(decided 2026-11-12, the research): WebKit gives it to every frame of the page, and Tauri's answer to that is the invoke key itself, which it added for sub-frames (GHSA-57fm-592m-34r7). So the check doesn't fail on the handler being there; it fails if a frame's call through it runs a command. An app must also declare its own commands (tauri_build::AppManifest) and grant them in its capability, so they are allowed only as the capability says. Keeping custom schemes out of Tauri'slocalwould be a second barrier, asked of Tauri upstream. -
The example app is the plugin's test, in a real webview (
crates/tauri/examples/tauri-app/): the smallest app that shows onecomp.mdwith a Mermaid diagram (the@comp-markdown/mermaidpack, installed as a bundled pack), a highlighted code block and a small JSX component in a strict frame, processed in Rust with thecompmdcrate and rendered by@compmd/sandboxin host mode. It uses CompMD exactly as an app outside this repository does (use), at the versions in this repository, so a release checks what hosts will get. With--checkit runs hosting's check (decision 11), with__TAURI_INTERNALS__as the host API a frame must not see, and exits0or1with what failed; with--check-brokenit serves a bundle whose runtime is missing and expects the sandbox's error for it.cargo make tauri-checkruns both. Its README is the guide for a host. -
CI runs the check on Linux, with WebKitGTK under
xvfb-run, in a workflow of its own that runs whennpm-packages/sandbox/,npm-packages/render/,crates/processor/,npm-packages/vite/,npm-packages/registry/,crates/host/orcrates/tauri/(the example app among it) change, and on release tags: a release waits for it. WebKitGTK has WebKit's'self'and its cache, so it catches what matters here; macOS (WKWebView) is checked by hand before a release with the same command, since a macOS runner costs about ten times the minutes. -
The store's folder is the app's data folder (hosting, decisions 4 and 5): registry packs a document imports, fetched when it needs them, are kept under
compmd/packs/inapp.path().app_data_dir(), by integrity and place, and served from there atpacks/<place>like a bundled pack; compiled code is kept beside them (compmd/compiled/, hosting, decision 6). The app fetches them, not its page: an app that processes in Rust resolves and fetches throughcompmd-host(H1 there); one that processes in its page has the plugin serveregistry/as the proxy on the scheme, withfetch: "host", so the plugin keeps what passes through. Either way a version is fetched once per device, and every document and view after loads it from the scheme. Built so far (2026-11-26): the store's folder in the app's data folder, read and served atpacks/<place>, and given to the processor (app.compmd().packs()); and theregistry/proxy on the scheme,compmd-host'sregistry::Proxy, for the registries the bundle's manifest names (registries,fetch,maxPackSize, which@compmd/vitewrites), answered on a thread of its own. AsregistryProxydoes, it passes metadata and tarballs on, and the page checks them and hands their files to frames as blobs. Not yet: anything that fills the folder (keeping what passes through, for every host at once), and nocompmd/compiled/.
An app that shows CompMD documents, with the Mermaid pack installed and the frames on the scheme compmd:
// package.json
"dependencies": { "@compmd/sandbox": "0.7.0", "@compmd/vite": "0.7.0", "@comp-markdown/mermaid": "0.1.0" }// vite.config.js: the bundle, into the Rust project
import { compmd } from "@compmd/vite";
export default { plugins: [compmd({ out: "src-tauri/compmd", source: "compmd://localhost/" })] };// compmd.config.json: what documents get; every installed pack is there, strict
{ "registries": { "*": "https://registry.npmjs.org/" } }# src-tauri/Cargo.toml
[dependencies]
tauri-plugin-compmd = "0.7.0"
compmd = "0.7.0" # when it processes documents in Rust
[build-dependencies]
tauri-plugin-compmd = { version = "0.7.0", features = ["build"] }// src-tauri/build.rs
fn main() {
tauri_plugin_compmd::build::bundle("compmd");
tauri_build::build();
}
// src-tauri/src/main.rs
tauri::Builder::default()
.plugin(tauri_plugin_compmd::init(tauri_plugin_compmd::include_bundle!()))// the page
import { sandbox } from "virtual:compmd";
const view = createSandbox({ ...sandbox, page: "host" }).open(container, { components: processed.hostComponents });
view.render(processed.expanded);And, when it processes documents in Rust, the packs come from the store, which compmd-host gives as the processor's Packs, with the policy and the ambient packs of the bundle's manifest (audit S19), so deny, imports: "listed" and refused hold in Rust as on the page's path:
let packs = app.compmd().packs().expect("a bundle"); // the bundle's packs, then the store's
let (policy, ambient) = (packs.policy()?, packs.ambient());
let processor = Processor::new(path, text)
.parse(&ParseOptions::default())
.resolve_with((), packs, &ambient, &policy);src-tauri/compmd/ is the bundle, the build's output: the app's .gitignore lists it.
The plugin and the packages change together, in 0.7.0, with hosting's changes:
build::bundle,include_bundle!andinit(bundle)in place ofinit()andBuilder; the scheme from the manifest.- No frames of its own:
build.rs's embedding,tauri/frames/,cargo make tauri-framesand their packaging go, and so does publishing the crate with--allow-dirty(releases). - No
frames_dir, nobasecommand, no permissions: the page gets the origin from the initialization script. - The handler is
compmd-host'srespond: the headers of 0.6.0's decision 4 with today's fixes (Access-Control-Expose-Headers: *on files,Access-Control-Allow-Origin: *on refusals), andpacks/<place>. - The store in the app's data folder, and
registry/for apps that process in the page (decision 11; what passes through isn't kept yet). - The example app uses CompMD as use shows:
@compmd/vitewith the Mermaid pack installed, the plugin's two calls, andapp.compmd().packs()in place ofpacks/mermaid/read from disk and the?rawimport. - The docs: the plugin's README, the example's README, and the guides' chapter on hosting.
| Decision | Case | What happens |
|---|---|---|
| 2 | An app wants its own handler for one extra path on the scheme | It registers a scheme of its own for it; the frames' scheme serves the contract and nothing else, or a frame could load what the app put there. |
| 3 | cargo test in a fresh clone, with no JavaScript build |
The build warns, the binary has no bundle, and the tests make theirs with Bundle::from_files. |
| 3 | A manifest written by a newer @compmd/vite |
build::bundle stops the build with the format it found and the plugin version that reads it. |
| 3 | The UI rebuilds the bundle in tauri dev |
The manifest changed, so Cargo builds again and the app restarts with it. |
| 4 | WebKit needs one more header | Added to respond, released; every adapter gets it. |
| 5 | The page renders before the initialization script ran | It can't: Tauri runs initialization scripts before the page's own. |
| 5 | A frame reads __COMPMD__ |
The script runs in the main frame only; a frame has no such global, and nothing in it is secret anyway. |
| 6 | The app registers compmd but the bundle was built for myframes |
Impossible: the scheme comes from the manifest. |
| 6 | Two apps on one machine both use the scheme compmd |
Each app's webview has its own schemes; they don't meet. |
| 7 | The app's CSP lacks <origin>/frames/ |
Code blocks and math show as text in host mode, and the check fails on highlighting. |
| 8 | A strict frame's code calls fetch("ipc://localhost/…") with a guessed key |
Blocked twice: the frame's policy allows no fetch, and Tauri checks the key. |
| 8 | A strict frame's code posts to window.webkit.messageHandlers.ipc |
The handler is there on WebKit (macOS, and Linux): Tauri drops the message, which has no invoke key, and logs it. The example's check posts such a call to a command of its own and fails if it ever runs (Risks, layer 3). |
| 9 | The example app passes on Linux but a header differs on macOS | macOS is checked by hand before each release with the same command (decision 10). |
| 11 | The app is offline when a document imports a registry pack it never fetched | Pending, then F026 when the app gives up (spec §6.4); a pack fetched before loads from the store. |
| 11 | The user clears the app's data folder | The store is empty; packs are fetched again when documents need them. The bundle, in the binary, is untouched. |
- The crate brings its frames (0.6.0's decision 2): one call and no build step. But a page imports
@compmd/sandboxfrom npm anyway, so its frames came from a second place, at a version that had to match the page's, checked only when a page loaded them; an app with its own libraries or packs needed its own build too, and then carried both; and the crate was published with built files that git doesn't keep. - The app's build read from its resources when the app starts (0.6.0's
frames_dir): no build step in Rust, but a resource to bundle, and a hash known only at startup, so the page asked forbasewith a command and the app granted a permission. - Each app writes its handler. What apps did until now. Each one has to find WebKit's
'self', its cache and the headers on its own, and gets them subtly different. - The frames served from the app's own scheme (
tauri://, next to the app's page). No plugin, but the frames would share the app's origin, which the sandbox's design rules out: a frame's code could reach the app's page and its commands. - The frames at fixed paths, uncached, as a web server can serve them. No hashing, but WebKit's custom-scheme cache can't be relied on to honour
no-cacheand validators, and a stale frame after an upgrade speaks another protocol version. - A JavaScript package for the page (
@compmd/tauri), wrapping a command. With the initialization script, the page needs no call at all.
-
What keeps a frame from the app's commands, layer by layer (decision 8). Tauri's capabilities don't, since they count the frames' scheme as the app's own. What does:
- No invoke key in a frame: Tauri gives it to the main frame only, and a call without it is refused (the tests show both).
- No network in a strict frame: its policy loads and fetches nothing, so it can't reach Tauri's IPC endpoint (
ipc://localhost,http://ipc.localhost) with or without a key. A permissive frame may reach only its pack's listedhttps:origins. - The WebKit message handler: checked, and the key is what stands there (decided 2026-11-12). Tauri's IPC also has a path through a WebKit script message handler (
window.webkit.messageHandlers.ipc), which a content security policy doesn't govern. WebKit exposes it to every frame, the example's check found it in a strict frame on macOS, and wry has no setting to keep it to the main frame, so layer 2 doesn't cover it. Tauri knows and designed for it: its invoke key exists to stop sub-frames' IPC, and a message without it is logged and dropped before any command runs (the research). The check therefore tests the guard, not the handler: the example's probe posts a call through the handler to a command the example has for it, and the check fails if that command ever runs. A frame can't read the key: it is in the main frame's initialization script only, and the frame is an opaque origin in another document. - Asked of Tauri: a capability that can leave out a scheme the app registers, so a frame's call is refused by the ACL whatever it carries. Until then an app can't add this check itself: a command's
InvokeMessagedoesn't give the URL of the frame that called it (Tauri's API reference).
A change in how Tauri hands out the key (into every frame, say) would remove layer 1; the check, which looks for Tauri in a strict frame and calls a command through the handler, would catch it.
-
Tauri 2.11.1 or later (GHSA-7gmj-67g7-phm9): before it, Tauri took a remote page whose host only started with the app's scheme name (
compmd.attacker.example) for one of the app's own on Windows and Android, where the frames' origin ishttp://compmd.localhost. The plugin requires a Tauri that has the fix. -
Tauri's own changes to custom schemes: Tauri may add headers of its own, or change how a scheme is served on a platform. The check shows the headers a frame arrives with, so a change shows in CI, and it is fixed once, in
respond, for every host. -
Mobile (iOS, Android) isn't tested in CI; the plugin targets them, and its README says so.
-
The order of the two builds in development: settled (2026-11-12).
tauri devstarts the app'sbeforeDevCommandwithout waiting for it to end (waitdefaults tofalse), but runscargo runonly once the dev server atdevUrlanswers, and the Vite plugin writes the bundle as the dev server starts, before it answers. The example's--checkundertauri dev, from a checkout with no bundle, passes on macOS: the Rust compiled with the bundle there, and nothing has to be run first.build::bundlemakes Cargo build again when the bundle changes. The plugin keeps a bundle written inside the app's folder out of the dev server's watch and its dependency scan, which would otherwise reload the page while it is written and scan the frames as the app's pages.
Research of 2026-11-12, when the example's check first ran on macOS (WKWebView, Tauri 2.12, wry 0.57) and its strict component found window.webkit.messageHandlers.ipc in its frame, beside an opaque origin and no __TAURI_INTERNALS__. It settled decision 8 and the Risks' layer 3.
What was found in the webview. A strict frame's code has window.webkit.messageHandlers.ipc, the script message handler wry registers for Tauri's IPC. A script message handler belongs to the web view's content controller, so WebKit gives it to every frame of the page, and a content security policy doesn't govern posting to it. A strict frame's policy blocks Tauri's other IPC path (ipc://localhost, a request), not this one.
What wry says. Its WebViewBuilder documentation has no setting that keeps IPC to the main frame; only initialization scripts can be (with_initialization_script_for_main_only). On Linux, an iframe's message carries the main frame's URL; on Android, the iframe's origin, and about:blank for an opaque one. So a message from a frame reaches Tauri's handler, and Tauri can't always tell it from the page's own.
What Tauri decided. GHSA-57fm-592m-34r7 (CVE-2024-35222), from 2024, and the same finding in Tauri 2.0's audit by Radically Open Security (TAU2-003): remote iframes reached Tauri's IPC without the app's leave. Tauri's fix, in 2.0.0-beta.20: it stopped injecting its IPC script into iframes on macOS ("which was unintended"), and added an invoke key, __TAURI_INVOKE_KEY__, which "is only intended to block IPC access from sub-frames"; an unauthorized message "will log a warning and the potentially malicious IPC call will be ignored". The key "is not used to protect against compromised Tauri windows": a page whose own code is hostile has the key, and is out of its reach. So Tauri leaves the handler where WebKit puts it, and makes a frame's message do nothing.
What Tauri's code does. In Webview::on_message (2.11.1), every IPC message's key is compared with the app's; a different one is logged as an error, and the function returns before any command runs. There is no main-frame check besides the key. A frame on a scheme the app registers counts as local (is_local_url), so the window's capability covers it too (decision 8). The key is put only in the main frame's initialization script, kept in a closure there; a strict frame is an opaque origin in another document, and can't read it.
A second layer an app may add. Tauri's Isolation pattern sends every IPC message through a sandboxed application and encrypts it (AES-GCM, with keys made each time the app runs). Its documentation doesn't say that Core refuses a message that didn't come through it; it costs some speed, and on Windows its application can't use ES modules. It is the app's choice, not the plugin's.
A related fix to require. GHSA-7gmj-67g7-phm9 (CVE-2026-42184): is_local_url looked only at a URL's first subdomain on Windows and Android, so a remote compmd.attacker.example passed as http://compmd.localhost, the frames' origin there. Fixed in Tauri 2.11.1.
What follows.
- The handler being in a frame is how WebKit and Tauri work, not a fault of the plugin's: the check no longer fails on it.
- The guarantee is Tauri's: a frame's message without the key runs nothing. That is what the check tests: the example's probe posts a call through the handler to a command the example has for it, and the check fails if the command ever runs. If Tauri ever gave the key to frames, or stopped checking it, the check would fail.
- The plugin requires Tauri 2.11.1 or later.
- Asked of Tauri upstream, as before: a capability that can leave out a scheme the app registers, which would refuse a frame's call by the ACL whatever it carries.
Sources: GHSA-57fm-592m-34r7; GHSA-7gmj-67g7-phm9; Radically Open Security's Tauri 2.0 report; Tauri's webview/mod.rs, 2.11.1; wry's WebViewBuilder; Tauri's Isolation pattern; Apple's WKScriptMessage.