Debian Codegraph @

book/src/workspace-trust.md

raw symbols SCIP
1 # Workspace trust
2
3 Helix has several features that can execute arbitrary code:
4
5 - Language servers (LSP)
6 - Debug adapters (DAP)
7 - Local workspace configuration (`.helix/config.toml`, `.helix/languages.toml`)
8 - Git integration (filters and other commands in a repository's `.git/config`)
9
10 To protect against malicious projects (a checked-out PR, a freshly cloned
11 repository, etc.) Helix gates these behind explicit per-workspace trust.
12 By default language servers start automatically (their binaries come from
13 `$PATH`, not from the workspace) and debug adapters may be launched, but
14 loading `.helix/config.toml` or `.helix/languages.toml` and trusting a
15 repository's `.git/config` requires opting in. Note that debug adapters
16 are never started automatically — you launch them yourself — but the same
17 trust level still gates whether they may run. The model is intentionally
18 similar to [direnv](https://direnv.net/): you run `:workspace-trust` once
19 per workspace and Helix remembers across sessions.
20
21 ## Granting trust
22
23 When Helix opens a file inside a workspace it has never seen before, a
24 modal trust prompt asks:
25
26 - **Trust** — allow the workspace permanently.
27 - **Never** — exclude the workspace; never prompt again.
28
29 `<Esc>` (or any other dismissal) caches "untrusted for this session" so
30 the prompt doesn't re-fire for every file you open in the workspace. The
31 next time you start Helix in that workspace, it'll prompt again.
32
33 A small `[⚠]` indicator appears in the bottom-right of the editor (next
34 to the macro-recording `[@]`) whenever the workspace is in restricted mode
35 *and* running `:workspace-trust` would change observable behavior — i.e.
36 when there's a local config to load or an LSP that would start.
37
38 You can also run `:workspace-trust` / `:workspace-untrust` /
39 `:workspace-exclude` directly from the typed command prompt.
40
41 ## Revoking trust
42
43 Run `:workspace-untrust` to revoke a workspace's trust grant. The next time
44 you open a file in that workspace, you're back to the untrusted hint.
45
46 ## Detecting changes after trust was granted
47
48 When you trust a workspace, Helix records a hash of every file under
49 `.helix/`. If those files change afterwards (a malicious checkout, an
50 inadvertent rebase, etc.) Helix detects the mismatch on the next open and
51 reports the workspace as *stale*:
52
53 ```
54 Workspace `.helix/` config changed since `:workspace-trust`. Local config
55 not loaded. Run `:workspace-trust` to re-allow.
56 ```
57
58 In the stale state, language servers continue to run (they use the
59 globally-configured binaries on `$PATH`, which are unchanged), but
60 `.helix/config.toml` and `.helix/languages.toml` are not loaded. Run
61 `:workspace-trust` again to re-pin the new hash.
62
63 ## Storage
64
65 Trust grants live in `data_dir()/workspace_trust/`, one small file per
66 workspace. The filename is the SHA-256 of the workspace's absolute path;
67 the contents look like:
68
69 ```
70 path = /home/user/proj1
71 hash = sha256:abc123...
72 excluded = false
73 ```
74
75 - Linux, macOS: `~/.local/share/helix/workspace_trust/`
76 - Windows: `%AppData%\Roaming\helix\workspace_trust\`
77
78 The one-file-per-workspace shape is safe under multiple concurrent Helix
79 instances — different workspaces never write the same file.
80
81 ## Configuration
82
83 Settings live under `[editor.workspace-trust]`:
84
85 | Key | Values | Default | Effect |
86 | --- | --- | --- | --- |
87 | `level` | `"none"`, `"servers"`, `"insecure"` | `"servers"` | What is auto-trusted in every workspace. See below. |
88 | `prompt` | `true`, `false` | `true` | Whether to surface the modal popup. The `[⚠]` indicator is shown regardless. |
89 | `trusted` | list of glob patterns | `[]` | Workspaces matching a pattern are trusted without a grant. Discouraged; see below. |
90
91 ### Recommended setups
92
93 **Default: trust servers, prompt before loading workspace config.**
94
95 ```toml
96 [editor.workspace-trust]
97 level = "servers"
98 prompt = true
99 ```
100
101 Language servers start automatically in every workspace — their binaries
102 come from `$PATH` and are not workspace-controlled — and debug adapters
103 you launch are allowed to run. The modal only appears when opening a file
104 in a workspace whose `.helix/config.toml` or `.helix/languages.toml` would
105 unlock something. Trust everything else with one keystroke per workspace,
106 deny with another.
107
108 **Maximum security: never prompt, trust each workspace by hand.**
109
110 ```toml
111 [editor.workspace-trust]
112 level = "none"
113 prompt = false
114 ```
115
116 Nothing trusts implicitly: language servers, debug adapters, local
117 config, and git `Trust::Full` are all off until you run
118 `:workspace-trust`. The popup never appears; the `[⚠]` indicator in the
119 bottom-right is your only signal that the current workspace is
120 restricted. Suited to users who would rather grant trust as a
121 deliberate action than dismiss a dialog.
122
123 > [!WARNING]
124 > `level = "insecure"` is highly discouraged. It implicitly trusts every
125 > workspace you open, which defeats the protection entirely: a
126 > checked-out PR with a malicious `.helix/config.toml` would get its
127 > configuration loaded and any language server it defines launched, with
128 > no prompt and no indicator. Only set this if you accept full
129 > responsibility for what's in every project directory you `cd` into.
130
131 ### Trusting workspaces by path (discouraged)
132
133 If you keep all your repositories under a predictable layout, you can
134 trust them in bulk with glob patterns instead of granting each workspace
135 individually:
136
137 ```toml
138 [editor.workspace-trust]
139 trusted = [
140 "~/src/github.com/me/*",
141 "~/work/repos/*",
142 ]
143 ```
144
145 A workspace whose path matches a pattern is trusted for everything, just
146 as if you had run `:workspace-trust` in it. `~` and environment variables
147 are expanded.
148
149 > [!WARNING]
150 > This is weaker than an explicit grant and is discouraged. It skips the
151 > `.helix/` change detection entirely (a malicious checkout under a
152 > matched directory is never flagged as stale), and it trusts *any*
153 > repository that later lands under a matching path — including one you
154 > clone into `~/src/github.com/me/` from an untrusted source. Prefer
155 > granting trust per workspace; reach for this only if the prompts are
156 > genuinely disruptive to your workflow. An explicit `:workspace-exclude`
157 > still overrides a matching pattern.
158
159 ## Git trust
160
161 Workspace trust also gates how Helix opens git repositories. Untrusted
162 workspaces are opened in [gix](https://github.com/Byron/gitoxide)'s
163 `Trust::Reduced` mode; trusted workspaces use `Trust::Full`.
164
165 Under `Trust::Reduced`, gix still runs the full filter pipeline (so
166 built-in conversions like `core.autocrlf` keep working) but ignores
167 configuration coming from the untrusted, repository-local `.git/config`.
168 That means `filter.*.clean` / `filter.*.smudge` drivers and similar
169 keys that would otherwise execute external programs are dropped until you
170 trust the workspace.
171
172 Helix forces this trust level explicitly rather than letting gix infer it
173 from `.git` directory ownership — a malicious `.git/config` in a directory
174 you happen to own is still treated as untrusted until you run
175 `:workspace-trust`.