Expand description
DevTools policy: every Right app has no access to DevTools; ViewRight alone may inspect the HTML content it opens.
The owner’s fixed design, verbatim: every Right app has absolutely NO access to DevTools, blocked at each and every level that is possible, for the app, its shell and its own UI. The single exception is ViewRight: it opens HTML documents, and DevTools must be available INSIDE that opened HTML content only (the content frame), never for ViewRight’s own UI or shell.
Two values exist, DevToolsPolicy::Denied (the default) and DevToolsPolicy::ContentOnly
(a named allowance an app must request explicitly). Under both, every webview the shell sees is
made non-inspectable unless the app registered it as a content webview
(ContentWebview) and the policy is ContentOnly.
Layers (see README “DevTools policy” for what each can and cannot block):
guard_process_start: refuses a remote-debugging launch argument, removes the WebView2 environment overrides, and refuses a machine policy that injects debugging browser arguments (Windows).- Native per-webview settings (
apply_native):isInspectable/developerExtrasEnabled(macOS),AreDevToolsEnabled, accelerator keys and the context-menu Inspect item (Windows). - The injected hardening script (keyboard shortcuts), in
crate::harden. verify_not_remote_debuggable: a post-creation tripwire for a live remote-debugging port.
Development builds are the one deliberate hole: with the off-by-default dev-inspect cargo
feature compiled in, every webview is inspectable and the guards above stand down (see
DEV_INSPECT_COMPILED). Such a build carries DEV_INSPECT_MARKER, and right-release
refuses to seal or upload a release or update build that contains it.
Everything that decides (argument and environment scanning, registry output, content registration, capability checks) is a plain function so it is testable without a GUI.
Structs§
- Content
Webview - A webview that renders opened content and may be inspected under
DevToolsPolicy::ContentOnly. - DevTools
Gate - Which webviews are inspectable. Built once at startup and kept in Tauri state.
- Guard
Report - The result of
guard_process_start. - KeyModifiers
- The modifier keys held while a key went down.
- KeyRules
- Which groups of browser keys one webview does not act on. Each group is switched by one rule:
devtoolsby the DevTools decision (a denied webview), the others by the hardening options of the same name. A key in no active group is left to the browser. - RegValue
- One string value of a registry key.
Enums§
- DevTools
Error - A refusal. Every variant is fatal at startup; there is no inspectable fallback.
- DevTools
Policy - Who may use DevTools. Exactly two values.
- Policy
KeyOpen - What opening a policy key means for the guard, from the status
RegOpenKeyExWreturned. - Webview
Decision - What the shell does to one webview.
Constants§
- CONTENT_
ONLY_ MARKER - Bytes a binary carries when it was built with the
content-devtoolsfeature.right-releaseaccepts Tauri’s devtools code in a binary only if this marker is present and the app is on the allow-list (packages/release/devtools-policy.json). Keep identical toCONTENT_ONLY_MARKERinpackages/release/devtools-policy.mjs. - DEBUG_
PORT_ FILE - The file name Chromium writes into the user data folder when remote debugging is on.
- DEV_
INSPECT_ COMPILED - True when this build was compiled with the
dev-inspectfeature: developer inspection is active. - DEV_
INSPECT_ MARKER - Bytes that appear in every binary built with the
dev-inspectfeature, and in no other.right-releasescans Mach-O, PE and ELF files for exactly this string and refuses to seal or upload a release or update tier build that has it. Keep identical toDEV_INSPECT_MARKERinpackages/release/qa-control-scan.mjs. Code outside thedev-inspectfeature must never reference this constant at run time (it would put the string into every binary that links the shell). - OWNER_
DECISION - The owner’s decision, stated verbatim. Do not edit or soften.
Traits§
- DevTools
Switch - The native DevTools setting of one webview, as
enforce_switchneeds it.
Functions§
- apply_
native - Apply the DevTools decision to one live webview. Runs for every webview, whatever other hardening modules the app opted out of.
- argv_
violations - Launch arguments that carry a debugging switch.
- build_
gate - Validate the policy and the content registrations and build the gate.
devtools_compilediscfg!(feature = "content-devtools")in the shell; it is a parameter so tests can cover both. - build_
gate_ with build_gateplus thedev-inspectswitch (DEV_INSPECT_COMPILEDin the shell). Withdev_inspectthe registrations are still validated as before (a misconfiguration surfaces in development, not only in the release build), Tauri’s devtools count as compiled (the feature enables them), and the gate allows every webview.- capability_
granting_ ipc - The identifier of the first capability in
docthat applies to the webview and grants permissions. A capability applies when one of itswebviewspatterns matches the webview label or one of itswindowspatterns matches the label of the window that hosts the webview.webview_labelmay be a content prefix pattern (html-content-*); overlap is judged conservatively. - decode_
reg_ text - The text of a registry value from its type and raw bytes (UTF-16LE), or
Nonefor a type that holds no text (a number or binary data cannot carry a browser argument). The strings of aREG_MULTI_SZare joined with spaces; the terminating NULs are dropped. - enforce_
switch - Set the native DevTools switch for
decision. A denied webview is accepted only when the switch was set to off and reads back off; a missing settings object, a failed call or a value that is still on isDevToolsError::NativePolicyNotApplied. A webview that may be inspected is never refused here: failing to turn inspection on is not a security failure. - env_
vars_ to_ scrub - Names (as spelled in
names) of the environment variables to remove from the process. Matching ignores ASCII case: Windows environment names are case-insensitive. - expand_
env_ refs textwith every%NAME%thatenvknows replaced by its value. An unknown name and a lone%stay as they are.- forbidden_
switches_ in - The debugging switches found in
args(a command line or anAdditionalBrowserArgumentsstring): remote debugging port, pipe, address and allowed origins, auto-open DevTools, the Edge remote-debugging flag, and--js-flagsthat enable the V8 inspector. - glob_
match *matches any run,?one character: the glob subset Tauri capability patterns use.- guard_
process_ start - Process-start guard. Call it first in
main(before Tauri builds anything) to fail before any webview exists; the shell plugin also runs it when it is constructed and refuses to set up when it failed. Idempotent: the first result is returned on every call. - is_
blocked_ accelerator - Whether a webview with
rulesmust not act on this key (a Windows virtual-key code). Find, print and every key outside the active groups always pass. - is_
live_ debug_ port_ file - A port file older than the process (by more than 2 s) is a leftover of an earlier run.
- live_
debug_ port_ file - A live remote-debugging port file under any of
dirs(or under<dir>/EBWebView). - open_
content_ devtools - Open the inspector of a registered content webview. The only path from this crate to an open inspector; every other webview is refused.
- patterns_
may_ overlap - Could any label match both patterns? Conservative: patterns are compared by their literal head (the text before the first wildcard), and heads that are prefixes of one another overlap.
- policy_
user_ data_ dirs - The user data folders the WebView2
UserDataFolderpolicy names for this program, with environment references expanded. The browser writes its port file there, not in the folder the application chose, so the tripwire has to look there too. - policy_
value_ applies - Whether a WebView2 policy value named
nameapplies to the program whose executable file isexe_name: the name is*(every application) or this program’s executable file name, compared without regard to case. Every other name belongs to another program. When this program’s own file name is unknown, every value is taken to apply. - policy_
violations - Errors for every value of a policy key that injects a debugging switch. A value named for a different application is still refused: an administrator-set debugging policy is never normal.
- register_
user_ data_ dir - Tell the tripwire about a user data folder the application gives a webview itself (Tauri’s
data_directory). Call it before the webview is created. The folders a policy or the WebView2 user-data environment variable names are added byguard_process_start. - runtime_
folder_ env_ name - The name of the environment variable that makes WebView2 start a browser from another folder.
- runtime_
folder_ env_ violation - The refusal for that variable’s
valuein the process environment at start, if it is set to anything. A launcher controls the environment as it controls policy, so it is refused the same way. - runtime_
folder_ violations - Errors for every value of the WebView2
BrowserExecutableFolderpolicy that applies to this program. Such a value makes WebView2 start whatever browser is in that folder, with every argument and behaviour that browser was built with, so nothing this crate sets can be relied on. - verify_
after_ first_ navigation - The tripwire once more, the first time a page has finished loading; later calls return
Okwithout looking. The browser process can write its port file after the webview is ready, which is whenverify_not_remote_debuggablefirst runs. - verify_
not_ remote_ debuggable - Post-creation tripwire (Windows): the browser process writes the port file while it starts, so a fresh file next to this process’s user data means a debugging port is open. A no-op elsewhere.