EnterpriseSandboxes

Sandbox policy on managed computers

Set the organization floor and profile keys that decide what a person's sandbox may do on a managed computer, with packs, asks and saved decisions.

openshell.admin is the organization floor, the loosest anyone gets. guardrail.profiles.<name>.sandbox is a profile overlay with the same keys that can only tighten the floor. The same profile_assignments and default_profile that choose the guardrail profile choose it. The one key that replaces instead of tightens is request_access.

To install OpenShell and turn sandboxes on, see Sandboxes on managed computers.

config.yaml
guardrail:
  profiles:
    contractors:
      description: Contractors. Coding agents only in a sandbox.
      mode: action
      sandbox:
        required_for: [claudecode, codex]
        when_unavailable: refuse
        allowed_harnesses: [claudecode, codex]
        egress_allow_only: [api.anthropic.com, "*.amazonaws.com", github.com]
        allow_mount: false
        user_approvals: session
        allowed_credentials: [bedrock]
        delete_stopped_after: 14d
  profile_assignments:
    - profile: contractors
      match: {groups: ["contractors@corp.example.com"]}
  default_profile: contractors

The keys and how they combine

The first table lists the keys under openshell.admin that exist for every OpenShell install. The second lists the keys added for managed sandboxes. A profile overlay can use all of them.

KeyHow a profile tightens the floorApplies
required_pack, required_pack_digestThe profile's pack must be at least as strict as the floor's pack in every setting, and sit in the policies folderAt create
min_profileThe stricter profile winsAt create
allow_yolo, allow_host_ports, allow_learn_modefalse winsAt create (learn mode: live)
allow_mount, require_copy_forfalse wins; the lists are joinedAt create
allowed_harnessesIntersectionAt create
egress_block, egress_allow_only, block_large_uploads (Preview)Block lists are joined, allow-only lists intersect, true winsLive
allow_unblockfalse winsLive
max_resourcesThe minimumAt create
lockedThe lists are joinedAt create
Managed keyTypeMeaningHow a profile tightens the floorApplies
allowedboolMay this person use sandboxes at allfalse winsAt create
required_forconnector namesAgents that must run in a sandbox on this computer, for example claudecode, codex, cursor, copilot (Require sandboxes)UnionHost hooks
when_unavailablerefuse, alertWhat a required agent gets where sandboxes cannot run. Default refuse.refuse wins; alert needs the floor and the profile to both say alertHost hooks
user_approvalsnone, sessionWhat the person may approve (Asks and saved decisions)The stricter winsLive
allowed_credentialsprovider names, or [none]Which model credentials may enter a sandboxIntersection. none stands alone.At create
on_silencestop, alertThe response when a user-tier agent works without its hooksstop winsLive
max_silence_afterduration, 1m or moreHow long a user-tier agent may work without hooksThe minimumLive
process_treeboolSample the sandbox's process treetrue winsLive
foreign_sandboxesstop, alertWhat to do with a sandbox DefenseClaw did not start. Default on a managed host: stop.stop winsLive
allow_upstream_telemetryboolLet OpenShell send its own usage telemetry. Off on a managed host unless set.false winsAt create
delete_stopped_afterduration or Nd, 1h or moreDelete a sandbox that has been stopped, or has completed, this long; one in the error phase is left to its ownerThe minimumLive
request_accesstext, up to 512 bytesWho the person contacts for an exception. Falls back to "contact your IT help desk" when empty.A profile value replaces the floor'sLive
driver_fallbackdocker or nonenone refuses a Linux sandbox that wants the MicroVM driver where KVM is not available (The docker fallback)none wins; docker never loosens itAt the next sandbox start
runtimesopenshell, substrateWhere the person's agents may run. Left out: both. With required_for, [substrate] refuses the host run and a sandbox on this computer, and points to defenseclaw substrate run (Agent Substrate)IntersectionHost hooks, at create
  • Unset means no constraint. An unset key adds no constraint, and a list left out is "no constraint". An empty list is refused by the schema; to allow no credentials, write allowed_credentials: [none].
  • Upstream telemetry. An account whose profile has allow_upstream_telemetry: false has OpenShell's own telemetry off at its gateway, even if the host's rendered gateway.env allows it.
  • Agent Substrate keys. sandbox_class, idle_suspend_after, idle_suspend_tasks, unattended_asks, ask_timeout, actor_secrets, ask_hosts, url_rules and git_push are refused in openshell.admin. In a profile they apply to Agent Substrate actors only.

Combinations that ensure refuses

A combination that cannot be satisfied is an error when the config loads. config validate and ensure refuse it and keep the previous config:

  • allowed: false together with required_for.
  • Two allowed_harnesses lists with nothing in common, or a required_for agent outside allowed_harnesses.
  • An egress_allow_only that leaves no destination once the floor is applied.
  • allowed_credentials: [none] together with other providers.
  • An unknown required_for connector.
  • A pack outside <policy_dir>/sandbox/, or looser than the floor's.

Packs

Custom packs for managed hosts live under the policies folder in sandbox/<name>/; a required_pack outside it is refused. See Sandbox policy packs for the pack format.

  • Strictness. A profile's required_pack must be at least as strict as the floor's (with no floor pack, as the default pack: openshell.pack, else balanced) in network and approvals modes, workspace, MCP, hooks.fail_mode, on_tamper, on_silence, silence_after and the egress lists. It must match its required_pack_digest when it has one. ensure and the config load refuse anything else and keep the previous config, and every create checks again and fails closed.
  • Default pack. A run whose profile names no pack gets the default pack (openshell.pack, else balanced; never open).
  • Copy only. A pack that sets or inherits workspace.mode: mount (a pack that extends balanced inherits it) is refused as looser than the default pack. That includes an openshell.pack that openshell.admin.locked: [pack] makes the required pack of every sandbox. Set workspace.mode: copy in the pack.
  • sandbox run --pack under a required pack takes a pack at least as strict in every setting and refuses a looser one, naming the profile and the setting it loosens. extends helps you write a pack and guarantees nothing.
  • Folder rules. The packs folder must be owned by root:defenseclaw (macOS root:_defenseclaw) with mode 0750. Every ensure refuses one that other accounts can read, and verify fails on it. ensure and verify warn, field by field, where default_profile is looser than an assigned profile, and name a custom pack without a digest.
  • Pin it everywhere. If you pin a pack for one profile with required_pack and required_pack_digest, pin it for default_profile too. enterprise <os> sandbox pack-digest FILE prints the digest.

Editing a pack

ChangeWhat happens
A pack edited in place, config.yaml unchangedThe next ensure applies it: it records the next config_generation and restarts the gateway. policy.applied reads true once the gateway reports the new digest.
An edit that no longer loadsensure fails with config_refused and the reason (also with --config of the config already applied), reports noop with noop_reason policy_refused, records no config_generation, and leaves the gateway running the last good pack.
A new config.yaml that names a required pack that does not loadIt fails validation; see Check a candidate config.
A gateway started on a pack that does not loadIt refuses to start. A reload keeps the previous configuration.

Hook silence

Claude Code, Codex, Copilot and Cursor images own their hooks as root, so the agent cannot switch them off, and silence on those only alerts. on_silence and max_silence_after bind the user-tier agents, such as OpenCode and Hermes. sandbox policy explain shows the response that applies to the agent in question.

Silence counts only while the agent works: its model calls and other connections, with no hook request for max_silence_after. An agent idle at its prompt, or waiting on a long tool call that its hooks reported (a build, or sleep 180), is not silent and keeps running.

Profile assignment

  • Proven matches. Proven matching assignments combine at their strictest settings.
  • The default. default_profile applies when no proven assignment matches and no assignment needs an unconfirmed fact. When it is empty, the floor applies alone.
  • Missing facts. If DefenseClaw cannot read the groups an assignment needs, the request is refused and names the missing fact.
  • Keep the default strict. Make default_profile at least as strict as every assigned profile; ensure warns for each weaker setting (sandbox_default_profile_looser).
  • Agents and connectors. match.agents is ignored for sandboxes, because agent ids are claimed by the caller. A floor reachable only through match.agents or match.connectors gets a warning; key strict floors on groups.
  • Group spelling. Write each group the way the host reports it: group@domain on Linux with SSSD fully qualified names, DOMAIN\group on macOS and Windows. A bare group name also selects the members of a local group of the same name, which a person with root on that host can create; ensure warns when a bare entry is ambiguous that way.

See User and group policies. A copyable example is packaging/identity/ad/sandbox-profiles.example.yaml.

A complete profile set with an offline floor

The offline-floor profile repeats every setting of contractors and engineering, so accounts with no matching assignment, and unverified users, get the strictest policy.

config.yaml
guardrail:
  profiles:
    contractors:
      description: Contractors. Coding agents only in a sandbox.
      mode: action
      sandbox:
        required_for: [claudecode, codex]
        when_unavailable: refuse
        allowed_harnesses: [claudecode, codex]
        egress_allow_only: [api.anthropic.com, "*.amazonaws.com", github.com]
        allow_mount: false
        allow_unblock: false
        user_approvals: session
        allowed_credentials: [bedrock]
        process_tree: true
        delete_stopped_after: 14d
    engineering:
      sandbox:
        allowed_harnesses: [claudecode, codex, opencode, hermes]
        on_silence: stop
        max_silence_after: 5m
    offline-floor:
      sandbox:
        # Offline and unverified users get this profile, so it repeats every
        # setting of the strictest profile above.
        required_for: [claudecode, codex]
        when_unavailable: refuse
        min_profile: strict
        allowed_harnesses: [claudecode, codex]
        egress_allow_only: [api.anthropic.com, "*.amazonaws.com", github.com]
        allow_mount: false
        allow_unblock: false
        user_approvals: session
        allowed_credentials: [bedrock]
        process_tree: true
        on_silence: stop
        max_silence_after: 5m
        delete_stopped_after: 14d
  profile_assignments:
    - profile: contractors
      match: {groups: ["contractors@corp.example.com"]}
    - profile: engineering
      match: {groups: ["engineering@corp.example.com"]}
  default_profile: offline-floor

Asks and saved decisions

An ask is a connection the sandbox's egress proxy does not decide for itself. On a managed host the gateway, not the daemon, decides and stores the answer, and it never passes the organization's floor.

user_approvalsallow_unblockAllow for this session"Always"Lift a block
unsettrue or unsetYesYes, storedYes
unsetfalseYesNoNo
sessiontrue or unsetYesNoFor the session only
sessionfalseYesNoNo
noneanyNoNoNo
  • Session answers. An answer for the session lasts while the sandbox runs; its next session asks again. Only an "Always" answer outlives the stop. A sandbox unblock HOST --sandbox NAME without --always also lasts only for that session.
  • allow_unblock: false. With allow_unblock: false, the person can approve an ask for this session only, even when user_approvals is unset. A request for "always" and an unblock are both refused, with the rule that refused them and the contact.
  • Saved decisions. They are per person (decisions/<uid>.json, service-owned, mode 0600), record who answered (not an operator), and are capped by the floor every time the policy is resolved. A call straight to the decisions route is checked against the same table.
  • Blocks always store. A block the person adds always stores, because it only tightens. With user_approvals: none, every rule that came from a user is removed.

defenseclaw sandbox approve --always and defenseclaw sandbox unblock on a profile with user_approvals session and allow_unblock false: both end with Blocked by your organization's DefenseClaw policy, one naming rule user_approvals and one naming rule allow_unblock, each with the Request access quote and exit status 1

A refused answer carries the request-access text and the exact rule, so the person knows what to ask for:

Blocked by your organization's DefenseClaw policy: api.example.net is not on your profile's allowed hosts (profile contractors, rule egress_allow_only). You can't approve this.
Request access: it-security@example.com. Quote: profile contractors, rule egress_allow_only, host api.example.net, sandbox brave-otter.

What the agent and the person see for an ask or a block is on What users see.

Foreign sandboxes, rules and containers

On a managed host the daemon lists every sandbox on the user's OpenShell gateway at each reconcile, and on every other local gateway registered with the user's OpenShell CLI that answers. A sandbox made with openshell sandbox create --from directly is not a DefenseClaw sandbox: it is foreign.

Foreign itemWhat DefenseClaw does
A sandbox without DefenseClaw's labels and a registrationStopped (foreign_sandboxes: stop, the default) or alerted on (alert), with log.sandbox.foreign_sandbox. The person is told it was not started with defenseclaw sandbox run, which the organization requires. The record reaches the managed gateway even when the person has no registered sandbox.
A foreign sandbox OpenShell won't stop yet (provisioning, starting, or in error)Deleted instead. A failed delete is tried again at the next reconcile; after three reconciles the person is told to remove it with openshell sandbox delete.
A network rule DefenseClaw did not render, and no stored decision coversRemoved and audited (sandbox.policy.foreign_rule). A repeat stops the sandbox.
An agent process in a container DefenseClaw did not createOnly alerted on (log.sandbox.foreign_container), so ordinary dev containers keep working.
  • Under alert. A foreign sandbox on the person's managed gateway keeps running while the gateway does, but does not hold the gateway port. When the person's last DefenseClaw sandbox stops, the gateway stops within about 45 seconds and the foreign sandbox with it, so the next account can start.
  • How containers are found. The daemon checks containers at every reconcile. It finds an agent by its command's name or, under another name, by its package name in the command line or in the program it runs, which it reads from the container with docker cp (nothing runs in the container).
  • Which daemon reports a container. On Linux with a rootful Docker engine every account in the docker group sees every container. A container whose agent runs as another account with a running daemon is reported by that account's daemon only. One whose agent runs as root, or as an account without a daemon, is reported by every daemon that sees it.

defenseclaw sandbox status and sandbox list after raw openshell created a sandbox: Sandbox raw1 was removed: it wasn't started with defenseclaw sandbox run, which your organization requires

Limits of this control:

  • An agent in a plain container or in the user's own virtual machine is not stopped. The control is the sandbox policy and the alert, not control over every container on a Docker host.
  • A second openshell-gateway that the user starts by hand shares the MicroVM driver's state folder and can sweep the first one's sandboxes. defenseclaw sandbox status and sandbox doctor list it as "Other gateway" with its process id.
  • A gateway that is not registered with the user's OpenShell CLI (one started from a private configuration and never added) is outside the reconcile: what it runs is neither stopped nor recorded as foreign.

Changes while sandboxes run

The managed gateway re-matches each live registration when the config changes, or when a person's directory facts change: their principal, directory, tenant or groups, or a slow lookup that has now resolved. The daemon learns of it from the next relayed hook or from a poll every 60 seconds. A renamed or recycled account is different: the registration is revoked, not re-matched.

Kind of fieldWhat happens
Live fields (egress lists, approvals, request_access, silence, process tree, retention)Switch at once and the person sees a status line. An edit of a profile's own settings applies tighter or looser; an assignment change only tightens a running sandbox.
Tighter create-time fields (for example mounts no longer allowed)The violating sandbox is stopped; the notice begins "This sandbox was stopped: your profile no longer allows" and names the field and the command to start again. The agent's session ends with it, sandbox activity shows it, and sandbox status NAME repeats it. Only after a verified match, never on a failed lookup.
Looser create-time fieldsApply at the next run.

The end of a Claude Code session in a sandbox on Linux: This sandbox was stopped: your profile no longer allows sandboxes, with the request-access contact; the work stays in the sandbox and sandbox pull reads it

Live fields and new connections

  • Each new connection. A running sandbox's egress proxy decides each new connection with the policy the managed gateway confirmed for it within the last second, and confirms again first when a relayed hook names another policy. A connection no relayed hook preceded (sandbox exec, a script that keeps running) is decided with a confirmation at most a second old.
  • Open connections. A connection already open is checked again once the new policy is in force.
  • Gateway not answering. The policy in force stays, except after a relayed hook said it changed: then new connections are refused with "your organization changed this sandbox's policy and DefenseClaw could not confirm the new one yet; try again in a moment" until the new one is confirmed.
  • Registration ended. A sandbox whose registration the managed gateway ended has every new connection refused while DefenseClaw stops it.

Floors are pinned per sandbox

  • When a person's profile assignment changes, each running sandbox is re-matched but runs under the stricter of two floors: the floor of the profile it was created under and the floor of the new one.
  • A sandbox created under a strict profile keeps its blocked destinations after the person moves to a looser profile. One created under a looser profile is tightened at once when the person moves to a stricter one.
  • The next sandbox takes the new profile alone. To loosen a running sandbox, stop it and run a new one.
  • If the profile a sandbox was created under is removed from the configuration, that sandbox's policy no longer loads and it is refused until it is started again.
  • While a sandbox keeps a pinned floor, its refusals, defenseclaw sandbox status and defenseclaw sandbox policy explain name the pinned profile first, then the profile the person is assigned now. The request-access quote names the pinned profile, whose rule refused.
  • sandbox status NAME shows the organization profile the registration matches now on its Your policy row, with the digest of that match. For a running sandbox it asks the organization's gateway first (2 seconds), so after a regroup it names the new profile at once. The Policy row keeps naming the pack and network profile the sandbox runs under.

Directory lookups and accounts

  • Cold lookups. When a directory lookup is cold, the create waits up to 10 seconds for it. If a profile assignment needs the unanswered identity fact, the create and hooks are refused with that fact named. If no assignment needs it, the proven profile or default_profile applies; a create under the default may be marked provisional and re-evaluated after the fact is confirmed.
  • The account itself. The computer must still know the account. OpenShell reaches every sandbox over ssh as the person, and ssh refuses an account the computer cannot look up (on Linux, SSSD stopped, or no cached entry). A new sandbox run then waits up to 10 seconds, and otherwise stops with "Your account can't be looked up on this computer right now. Try again in a moment."
  • Late stops. A sandbox still running two minutes after it should have stopped is revoked.
  • Recycled or renamed accounts. The same uid with a different name revokes its registrations. The account that holds the uid now never inherits the earlier account's sandboxes or saved decisions: its first sandbox run removes them once the account database confirms which account holds the uid (never during a directory outage), and the gateway log names how many it removed. They never count against the new account's limits.