Security
Nothing set is Closed. That cap is ReadWorkspace only. The permissions are ReadWorkspace,
WriteWorkspace, RunCommands, Network, SpawnSubagents, GitHubRead, and GitHubWrite. A request is intersected with the cap, and the
session records what was dropped. The Ceiling page covers how the cap is applied.
Sandbox
File tools resolve inside a granted root. terret.readRoots and terret.writeRoots add roots.
Both default to empty. A directory the harness created for that session is also a root of that
session, for reads and for writes. It is not a writeRoots entry, and another session does not
receive it. The grant ends when the scope that created the directory closes. A write root is
included in the read roots. A read root does not grant a
write, and ReadWorkspace never grants a write. The shell stays off
unless RunCommands is granted. When it is, its cwd is the workspace. A host that cannot apply a
profile refuses the command. Mach and XPC lookups in that profile are an allowlist of the system
agents a toolchain needs. Security and keychain services stay denied. When Network is granted,
outbound TCP to terret's listen port and to the session GitHub port stays denied. Grok's own
process is not sandboxed.
A configured symlinked root covers its literal path and its resolved target for file tools and shell commands. The root is resolved at startup and again for each operation. An invalid or unresolvable root fails startup with its setting and path. A missing descendant is accepted when its existing prefix resolves. Empty entries in a populated root list fail startup.
The profile preserves both spellings and grants exact symlink reads for path lookup. Ancestors receive metadata access, and symlink ancestors receive exact link reads. Their directory contents and sibling paths stay denied. A symlink inside a granted root that points outside the grant stays denied.
Waits
An open-ended watch is refused before it starts. That is tail -f, tail -F, tail --follow,
tailf, watch, less +F, nohup, setsid, a background &, script without a visible command,
and sh -c or bash -lc wrapping one of those. A subshell or a brace group around one of those
is the same watch. A shell heredoc hides its script and is refused. A shell that reads its
script from stdin or from a file (bash, bash < f.sh, sh f.sh) is refused, and so is an
unclosed quote. A shell here-string is the script.
A while or until loop that runs sleep is the same watch, including sleep inside a substitution.
busybox in front of a watch is that watch. LESS=+F less is less +F.
A shell -c, eval, or script -c whose script is
itself a substitution is refused, because the text that will run is not visible. timeout longer
than terret.command.timeout is refused too, and so is a tool wait (block_until_ms or timeout_ms)
past that cap, of zero, or not a number. The refusal tells the model to run the command in the
foreground and wait for the exit code. That watch check is a best-effort deny-list. The command
kill timer is the real limit: a command still running when terret.command.timeout elapses
(default 15 minutes) is killed, and terminal/wait_for_exit returns that timeout to the model
so the turn continues. Completion is the exit status, not a matched line in a log.
spawn_subagent stays denied unless SpawnSubagents is granted. A granted helper runs in the
parent session's confinement and is cancelled with that session. Its start, update, and cancel
are milestones on the parent, so a relay sees them there.
monitor, wait_commands_or_subagents, wait_tasks, get_command_or_subagent_output, and
get_task_output are on --disallowed-tools whenever Closed or Clamp passes a deny list, even
when RunCommands is granted. Inherit does not pass that list. A shell command on the ACP path
is still refused, because terret owns terminal/create.
Reads
A command may read:
The workspace,
readRoots, and everywriteRootspath.The fixed system roots a shell needs:
/usr,/bin,/sbin,/System,/Library,/dev,/opt/homebrew,/usr/local,/private/var/select, and/var/select. A root that is not present is omitted./private/etc/ssland/etc/ssl, asfile-read*subpaths only. That is the system TLS config (openssl.cnfand the public CA bundle). Both spellings are granted because/etcis a symlink toprivate/etc.
A command may not read:
Anything else under
/etcor/private/etc. Parents of the TLS tree are metadata so lookup can stat them. They are not subpaths, so password files and the rest of those directories stay closed./tmp,/private/tmp, and/var/folders, except for the private session temp directory or an explicit configured root. A/tmproot on macOS also covers its/private/tmptarget.
The TLS rules are not writes and not exec rules. WriteWorkspace does not extend them. Network
stays off unless Network is granted.
Writes
Writes are the workspace, writeRoots, and a directory that session's harness created, and only
when WriteWorkspace is granted.
A linked worktree may also read and write its admin directory and the common objects, refs,
logs, packed-refs, and packed-refs.lock. Those writes require WriteWorkspace, and every
path has to resolve strictly inside the project root. hooks and the common HEAD stay
read-only. A path outside the project root is not granted, and the main checkout's files are not
granted.
Protected personal directories
The shell's Seatbelt profile adds a gate to macOS Transparency, Consent, and Control (TCC). By default the profile denies reads and writes to these paths and their contents:
~/Desktop,~/Documents,~/Downloads,~/Library/Mobile Documents, and/Volumes.~/Library/Application Support/Firefox,~/Library/Application Support/BraveSoftware,~/Library/Application Support/Google/Chrome, and~/Library/Safari.
Ambient host and runtime grants do not override these denials. The session workspace and
terret.readRoots or terret.writeRoots can restore access to the paths they cover. Reads and
writes are evaluated separately: the workspace and either root setting restore reads, while
writes require WriteWorkspace and coverage by the workspace, terret.writeRoots, or a directory
that session's harness created. A Terret
grant leaves macOS authorization, including TCC, in effect.
Localhost-only Playwright UI vetting
Get operator approval and bind the test app to a loopback address. Allow only loopback navigation and requests. Block external requests and redirect hops that leave loopback. Use a fresh, disposable browser context or temporary profile and keep artifacts in a disposable temporary directory. Never load a personal browser profile.
Playwright MCP runs outside the shell's Seatbelt profile and is a separate trust boundary. Enforce
the loopback restriction separately: it does not narrow the general Network grant. Never use
Playwright MCP to bypass Terret's network grants. GrokHome strips ambient mcp_servers from
local Grok launches. Terret passes ACP only explicitly granted servers from the workspace's
.mcp.json; grant them only from a trusted workspace. See Config.
Temp
Each session gets its own directory, mode 0700, created in one step when the session opens and removed when the harness scope closes. A symlink at that path is not followed.
TMPDIR,TMP, andTEMPname that directory.JDK_JAVA_OPTIONSkeeps options already set and appends-Djava.io.tmpdirfor it, so the last flag in that variable is the session one. An unclosed quote in the inherited options is closed first.JAVA_TOOL_OPTIONSis removed from the agent and from the session shell, so it cannot name another directory.An inherited
TMPDIRorJDK_JAVA_OPTIONSdoes not replace terret's values. A-Djava.io.tmpdiron the java command itself is later and replaces the variable. That is accepted: the seatbelt still does not grant that other path, and terret does not rewrite the command.A dsh child gets the same allowlist as the session shell:
PATH,LANG, the git config nulls, and those temp variables. Its directory is created at mode 0700 for that spawn and removed when the spawn's scope closes.JAVA_TOOL_OPTIONSis not copied.Each process terret spawns for the agent gets its own temp directory, not the session's, and that directory is removed when the process is destroyed.
The key and the gh token are not written in these directories.
Denials
Each command's deny-default rule carries a message tag, terret:<id>:<nonce>. One server-scoped
log stream reads sandbox denials and keeps a line only when that tag belongs to a live command.
When the command exits non-zero and a tagged denial was seen, the tool result names the operation
and the path and says Russ has been notified. That fact is a Refused milestone. Nothing
is approved or retried. If log stream cannot be read, detection is off and the command still runs.
Operation not permitted in the output is then an unconfirmed hint, not a denial. A file-tool
refusal is Refused too.
Commit hooks
The command sandbox may read and execute files in ~/.config/early-effect-githooks when that path is a
real directory strictly inside the home directory. The seatbelt grant is file-read* on that
directory. process* is already allowed, so a file there can be executed once it can be read.
file-map-executable stays the global rule. The directory is not writable, with or without
WriteWorkspace. ~/.config is not granted. A sibling such as ~/.config/other stays closed. A
missing directory adds no path. A symlink at .config or at the hooks directory is not granted,
including a symlink that stays inside the home directory. A symlink inside the directory that points
outside it is denied. Parents of the directory are metadata only, so lookup can stat them. This is
not the repository hooks directory, which stays read-only on its own. Terret does not read
core.hooksPath from git config. The path is this fixed directory under the home directory. The
child still points the system and global git config files at /dev/null, so the grant does not open
~/.gitconfig. The grant is the command sandbox. It is not a readRoots entry, so a file tool still
has to resolve inside a granted root.
There is one key. HTTP, including the local listener, refuses /mcp unless header x-terret-key
matches that key. The same match is the event subscriber's principal: key: plus the first 8 hex
characters of the SHA-256. A missing source on HTTP logs the error and exits non-zero. Stdio trusts
the owner of the pipe. events/subscribe on that pipe stays forbidden. The key is not logged,
and it is not an environment variable of the start script. Set
terret.key.file or the keychain pair terret.key.service and terret.key.account, not both.
The Config page lists those keys.
Watch authentication
The watch listener starts only when an operator enables at least one provider: native passkeys,
GitHub OAuth, or Cloudflare Access. Enable any combination. The local listener keeps /watch
closed. /mcp on both listeners requires x-terret-key, including for a signed-in watch owner.
Native login spends a browser-bound, three-minute challenge and verifies a WebAuthn assertion
against the enrolled passkeys and configured relying-party policy. Login challenges and mutation
challenges are separate. GitHub login uses a five-minute, browser-bound, single-use OAuth state
with PKCE (Proof Key for Code Exchange). Terret exchanges the code and checks the login returned
by GitHub's authenticated user endpoint against terret.githubAuth.owner. Failed callbacks give
a generic denial. OAuth access tokens stay on the server during the exchange.
A successful native or GitHub login issues an eight-hour HMAC-SHA256 session cookie with
HttpOnly and SameSite=Strict, plus Secure on HTTPS. Signing keys and active sessions are
process-local. POST /watch/logout requires that session, its CSRF token, and the configured
origin. It clears and revokes the cookie and ends its live streams. A Cloudflare Access session
remains governed by Cloudflare. On the configured browser host, the login page and its script and
stylesheet are public when either native login or GitHub login is enabled.
Cloudflare Access verifies Cf-Access-Jwt-Assertion with RS256 using the team certificates at
https://<team>/cdn-cgi/access/certs. The token must have the configured audience and issuer
https://<team> and must be unexpired. Optional nbf and iat must be epoch seconds at most 60
seconds ahead. Timestamps must fit in Instant. A protected crit header is rejected. The email
claim must match the whole terret.access.owner address, ignoring case. A service token and a
loopback request without a valid assertion carry no Access identity. The Access-only listener
requires this assertion for every non-MCP path. With another provider enabled, paths outside
watch and MCP still require an Access assertion; they are closed when Access is disabled.
Worktree
open can ask terret to add a linked worktree and confine the session to it. Terret runs
git worktree add itself, outside the session sandbox, with an argument vector. The branch and the
base are ref names. main, master, HEAD, and the repository default are refused, and the main
checkout is not moved. The source checkout must resolve strictly inside terret.root, and the new
checkout must resolve strictly inside terret.worktreeRoot. The two roots cannot overlap, either
as configured or after symlinks resolve. The checkout root grants no access to sibling checkouts.
Terret disables Git hooks and fsmonitor, isolates system and global Git configuration, and refuses
repository filters, includes, and worktree redirects for hosted mutations. The session's later
Git writes use the linked-worktree grant, so the common HEAD, hooks, and main checkout stay out
of its write set. Use hosted worktree operations on trusted source repositories and keep their
Git configuration, refs, and registration files stable during the operation. This applies to
other writable sessions on the source repository as well as local tools.
remove_worktree checks x-terret-key at HTTP ingress and MCP dispatch. The app explicitly trusts
the owner of its stdio pipe. Removal verifies the source registration and target filesystem
identity. Only managed linked checkouts are eligible. force allows removal of a dirty checkout;
Git locks, current workspace use, path checks, and ownership checks still apply. Terminal cleanup
checks the foreground process and its observed descendants. Keep independently detached processes
out of managed checkouts. The Jobs page has both request shapes.
Grants
gh_push needs the gh write grant. read and write are separate. The Jobs page
lists each tool.
Repository
Every gh tool, including the push, reads origin from the workspace git config file.
git remote get-url is not used, so insteadOf is not applied. The resolved owner/name is
passed as gh --repo, and the push URL is https://github.com/<owner>/<name>.git built from that
value. terret.github.repo is not consulted, so a histos worktree is not pushed to terret.
Accepted:
httpsandsshGitHub URLs.A
pushurlonly when it names the same repository.
Refused before gh or git writes:
A missing origin, or an owner other than
early-effect.A credential, a port, a query, or an extra path segment.
A
[url],[include],[includeIf], or[alias]section.A
pushRemote, apushDefault, a branch remote other thanorigin, or an origin push refspec.An
sshCommand, an askpass, a proxy, or a credential helper.A
.gitpath that leaves the workspace, or a workspace symlink that leaves the project.
Push
It pushes only the session's current branch to the same branch on that session's origin, over
HTTPS. Terret runs gh and git for that push itself, not inside the session sandbox. gh sees
the service environment the other gh tools use, from a directory that is not the session workspace,
and git is told not to search above that directory. Fetch and push set GIT_DIR to a temporary
bare repository. Hooks and core.sshCommand in the workspace are not used for that process.
A detached HEAD,
main, the default branch, a protected branch, and any update that is not a fast-forward are refused.If the protection lookup fails, the push is refused.
There is no force push.
A failed lookup refuses the push and includes gh's error with secrets redacted.
Merge
gh_pr_mergerequires the head sha and passes--match-head-commit.A sha that is not 40 hex digits is refused.
GitHub credentials
GH_FORCE_TTYis removed, because any value makes gh write terminal formatting.NO_COLORis1andCLICOLORis0.Output that still contains terminal formatting is refused as that problem and is not parsed.
Fetch and push ignore git config and askpass, and keep the service token for the credential helper.
The token is not placed in the session sandbox, the command arguments, a workspace file, git config, or a milestone.
A session's GitHub tools use a same-pipe ACP transport when the agent advertises one. Otherwise they use streamable HTTP on
127.0.0.1andterret.sessionGh.port, with the bearer only in that session'ssession/newandsession/load. The bearer is revoked when the session ends.The command sandbox denies outbound traffic to the main listen port and to that session port with
(remote ip "localhost:<port>"). That is the loopback filter the profile compiler accepts, and it matches127.0.0.1,localhost, and::1. Mach lookups are an allowlist. Security and keychain services are not on it.Gh children set
GIT_CONFIG_GLOBALandGIT_CONFIG_SYSTEMto/dev/null.
Tokens, secret-shaped keys, and email addresses are replaced with [redacted] before an event
leaves the process.
HTTP passkey step-up
Mutating HTTP job routes require step-up regardless of the MCP setting. A first request returns
403 with approval_required, challenge, expiresAt, and argsHash without executing anything.
Retry with the same arguments and this header:
x-terret-step-up: {"challenge":"<challenge>","assertion":{...}}
The assertion fields are credentialId, authenticatorData, clientDataJSON, and signature,
encoded as base64url. The 60-second, single-use challenge binds the server, operation, and
canonical JSON arguments. HTTP and MCP spend the challenge before verifying the assertion.
Read-only jobs, events, and streams retain their ingress checks.
Watch steering binds the request method, path, query, UTF-8 body, and any X-CSRF-Token header.
Ingress screening runs first, followed by passkey verification and CSRF validation. The Scala.js
client gives WebAuthn the UTF-8 bytes of the challenge and converts the authenticator's ES256 DER
signature to the 64-byte r || s format the verifier accepts. It sends one signed same-origin retry
and disables redirects. An approved browser action returns JSON with a location checked by the
client before navigating. Signed requests without JSON negotiation keep the 303 response.
Watch passkey enrollment
Both enrollment requests require same-site request headers, a watch CSRF token, an origin in
terret.passkey.origins, and an authenticated owner or the one-time first-key enrollment permit.
The permit authorizes enrollment only while the store is empty. The three-minute registration
challenge binds the viewer, origin, and CSRF token. An
approved completion spends it before verifying the attestation. The server checks webauthn.create,
the challenge and origin in the client data, the relying-party ID hash, user presence, and user
verification when configured as required. It accepts an ES256 public key on P-256 and requests
WebAuthn's none attestation, which does not establish authenticator vendor identity.
Only one completion can enroll a first credential into an empty store. Once the store has a credential, completion requires the same fresh, request-bound step-up as watch steering, before Terret adds the new key. A passkey outside the current store cannot approve enrollment. If a credential file is configured, one Terret process owns it and persists the enrolled public keys.
MCP passkey step-up
terret.passkey.mcpStepUp defaults to false. HTTP MCP still requires x-terret-key, and stdio
still trusts the owner of the pipe. true enables approval with scoped reads, session grants, and
classification off. Use the Config policy object to enable those features.
With approval enabled, an open requesting WriteWorkspace, RunCommands, Network, or
SpawnSubagents needs a fresh assertion. So do worktree creation, resume, GitHub mutations,
cancel, and remove_worktree. alwaysRequire can add actions to this list. An approved open
or run may grant run on that session until sessionGrantTtl expires. The window starts at
verification, survives ordinary turns, and is cleared by a process restart. It cannot approve
another session or a fresh-approval action.
On HTTP with a configured watch listener and compatible origin, a call without
an assertion waits for a decision in Watch. The authenticated owner sees
a bounded preview. Decision requests also need a trusted browser origin and a CSRF token. Approval
requires user verification from an enrolled passkey. The random challenge identifies a single
waiting call, including its original arguments. It cannot approve another call, even with identical
arguments. Approval, denial, expiry, and interruption remove the pending request. A verified
assertion releases only that caller. Only a successfully approved session operation can record
the optional in-memory run grant.
For an inline ceremony on HTTP, send _meta with "terret/stepUpMode": "inline" to request the
challenge. Stdio and HTTP without an eligible watch listener issue an inline challenge by default.
Retry with the same arguments and send the challenge and assertion under
_meta.rocks.earlyeffect/stepUp. Calls with that assertion field go directly to inline verification.
Enrollment and verification require a configured relying party and allowed origin.
Scoped reads
Enable autoAllowReads to permit open with exactly ReadWorkspace and GitHub reads under the
explicit approvedReadRoots. find and call use the explicitly configured terret.root; find
filters out ungranted servers before connecting. call uses one resolved server definition for
both authorization and execution. Only exact readOnlyCalls pairs can receive the read exception.
Terret pins the server definitions present at startup for automatic approval. A new or changed
definition needs freshly verified approval. Keep the project catalog and the executables it names
under operator control. A readOnlyCalls declaration trusts the server implementation and its
handling of tool arguments. Status and export simply read retained session state and logs.
Approved roots are separate from sandbox grants. Startup rejects broad and protected roots and checks their resolved targets. A path that resolves outside its approved root loses automatic approval. Desktop, Documents, Downloads, iCloud Drive, network volumes, and browser profiles are ineligible for automatic approval. The sandbox and server/tool grants still apply after approval.
Classifiers
StepUpClassifier is a ZIO service with Allow, RequireStepUp, and Deny decisions and a
reason for each. It defaults to disabled. Deterministic rules can make a decision first and defer
ambiguous cases to the built-in Grok classifier. The model receives action metadata rather than
prompts, tool arguments, paths, credentials, or tool output. Errors, timeouts, and unexpected
responses require step-up. Classifiers cannot add server grants, extend the sandbox, change
trusted roots, or skip an explicitly required fresh assertion.
HTTP job approval and /watch verification apply independently of this flag. That includes native
passkey sign-in, steering, and additional passkey enrollment.
Session card
The session card on open uses a static ui://terret/session document. The shell bytes omit
credentials and session data. The host supplies the launch result. The view requests an opaque
origin, no network destinations, and no browser permissions.
The separate terret://session-states resource is private. Terret checks the configured HTTP MCP
key on every request; a dedicated stdio connection uses the trusted local owner. Heddle binds
sessions and resource notifications to that owner. The payload contains session IDs and phases
only. The configured owner can already see all these sessions; the card renders only its launch
session. A read-only resource capability grants no tool or passkey authority.
CommandWait.admit("tail -F target/assembly.log | grep done", CommandBudget.default.command)Some(Follow(tail))PermissionPolicy.Closed.ceilingCeiling(Set(ReadWorkspace))KeyGate.ready(Listen.Http(WarpLocal.Host, WarpLocal.Port), None)Left(KeyMissing)KeyGate.ready(Listen.Stdio, None)Right(None)Ceiling.all.clamp(Ceiling.closed)(Ceiling(HashSet(ReadWorkspace)),HashSet(GitHubRead, GitHubWrite, SpawnSubagents, RunCommands, Network, WriteWorkspace))