Skip to main content

Require OpenShell for Confidential Code Policy

Overview

When Claude Code or Codex runs on a device outside an OpenShell sandbox and works in, or touches, a confidential location, Swif reports or blocks the action. If the action is blocked, the agent is told to run inside OpenShell instead. Inside a sandbox, the Swif OpenShell Sandbox Policy controls which files, hosts, and model endpoints the agent can reach.

Important: This policy is a guardrail against mistakes, not a security boundary. It catches agents that are accidentally run outside OpenShell on confidential work. It doesn't stop a user who deliberately works around it, such as a user with root or administrator rights, or an agent that Swif can't hook.


How it works

  1. A user runs Claude Code or Codex on the device, outside an OpenShell sandbox.

  2. The agent works in, or touches, a location.

  3. Swif checks whether the location is confidential. See What makes a location confidential below.

  4. If it is, and it isn't an exception:

    • log: the action is allowed and reported.

    • block: the action is stopped, and the agent is told to run inside OpenShell.

Agents running inside an OpenShell sandbox aren't affected by this policy.

What makes a location confidential

A location is confidential when any of these is true:

  • It's under a folder in Confidential Paths.

  • It belongs to a Git repository in Confidential Repositories, wherever that repository is checked out.

  • It, or a parent folder, contains the Marker File (.swif-confidential by default).

Folders in Exceptions are never blocked, even when they're confidential.

What counts as working in a confidential location

An action counts when the agent's working directory is in a confidential location, or the action names a file or folder there.

Situation

How it's checked

Working directory

An agent started in a confidential folder is caught on its first tool call, even calls that use files outside that folder.

Claude Code file tools

Read, Write, Edit, Grep, and Glob are checked by the path they use.

Shell commands

Claude Code's Bash and Codex's shell are checked by the paths written in the command, such as /…, ~/…, ./…, or $HOME/….

Codex apply_patch

Checked by the files it adds, updates, deletes, or moves.

Symbolic links

Followed, so what counts is where the data actually lives.

Not detected: paths built while a command runs, for example through a variable or a subshell. This is one reason the policy is a guardrail, not a security boundary.


Requirements

Requirement

Details

Operating systems

macOS, Linux, and Windows

Device ownership

Company-owned and BYOD

Swif agent

Swif Agentic Security agent installed and running. Deploy it with the Apple, Windows, or Linux Agentic Security Policy.

AI agents

Claude Code, Codex CLI

For blocking

The Swif OpenShell Sandbox Policy assigned and enabled on the same device

Blocking needs the Sandbox Policy

Blocking only makes sense if there's a sandbox to move to. If When An Agent Works Outside OpenShell is set to block, but the OpenShell Sandbox Policy isn't assigned and enabled on the device:

  • actions are reported, not blocked, and

  • Swif flags the device.

The OpenShell Sandbox Policy doesn't apply on Windows, because OpenShell runs there only inside WSL 2. On Windows devices, the policy still runs and logs, but with block, matches are reported, not blocked, and the device is flagged.

What isn't covered

  • Other AI agents. Only Claude Code and Codex can be hooked today. Other agents aren't checked.

  • Users who can change the guard's files. That's root on macOS and Linux, and administrators on Windows.

  • Anything running inside WSL 2 on Windows.


Settings reference

General

Setting

What it does

Default

Enabled

Checks supported agents against the confidential locations. Turning it off removes everything Swif installed for this policy.

Off

When An Agent Works Outside OpenShell

log allows the action and reports it. block stops the action and tells the agent to run inside OpenShell.

log

Agents

The coding agents to check: claude, codex. Leave empty to check all supported agents.

claude, codex

Block When The Policy Cannot Be Read

What an agent hook does if it can't read this policy on the device. Off allows the action and reports the problem. On blocks it.

Off

Start with log. It shows what would be blocked without interrupting anyone. Review the reports, add any exceptions you need, then switch to block.

Confidential locations

Setting

What to enter

Limit

Confidential Paths

Folders that are confidential. A path covers itself and everything under it.

256 paths, each up to 4,096 bytes

Confidential Repositories

Git repositories that are confidential, wherever they're checked out. Matched against each repository's remote URLs.

256 repositories, each up to 512 characters

Marker File

A file name. Any folder that contains it, or has a parent folder that contains it, is confidential.

Up to 255 bytes. A name, not a path.

Paths for each operating system. Use /path for macOS and Linux, and C:\path or \\server\share for Windows. Each device uses only the paths written for its own system, so one policy can hold both. Paths must be absolute, can't contain .., and can't be /.

Repository format. Use host/owner/name, for example gitlab.example.com/team/project. GitLab subgroups add parts between owner and name, such as gitlab.example.com/team/subgroup/project. Use * as the last part to cover every repository under an owner, for example gitlab.example.com/team/*.

Marker file. Teams can mark a folder as confidential by adding the marker file, without asking an admin to change the policy. For example:

touch ~/projects/acquisition-model/.swif-confidential

Exceptions

Folders that are never blocked, even when they're confidential. Each exception needs:

Field

What to enter

Required

Path

The folder, including everything under it. An absolute path without .., and not /.

Yes

Reason

Why the folder is allowed, up to 256 characters. Kept for audits.

Yes

You can add up to 64 exceptions.


Before you start

  1. Assign the Swif OpenShell Sandbox Policy to the same devices if you plan to block. Configure its network and model endpoints so agents can work inside the sandbox.

  2. List your confidential locations: folders, Git repositories, or both.

  3. Decide whether teams can mark folders themselves with the marker file.

  4. Tell users that agents working on confidential code must run inside OpenShell.

  5. Choose a pilot group of devices.


Create the policy

  1. In Swif, go to Agentic Security > Policies.

  2. Select Require OpenShell for Confidential Code Policy.

  3. Set When An Agent Works Outside OpenShell to log.

  4. Add your Confidential Paths and Confidential Repositories.

  5. Keep or change the Marker File name.

  6. Add any Exceptions, each with a reason.

  7. Turn on Enabled.

  8. Assign the policy to your pilot devices and save.

  9. After reviewing the reports, change When An Agent Works Outside OpenShell to block.


Example configurations

Example 1: Pilot in log mode

Setting

Value

Enabled

On

When An Agent Works Outside OpenShell

log

Agents

claude, codex

Confidential Repositories

github.com/example-corp/*

Marker File

.swif-confidential

Every action on an example-corp repository outside OpenShell is reported, but nothing is blocked. Use the reports to find teams that need help moving to OpenShell.

Example 2: Enforce for a confidential project

Setting

Value

Enabled

On

When An Agent Works Outside OpenShell

block

Confidential Paths

/Users/Shared/finance and C:\Finance

Confidential Repositories

gitlab.example.com/finance/*

Exceptions

Path: /Users/Shared/finance/public-reports; Reason: Published reports, no confidential data

The OpenShell Sandbox Policy is also assigned to the same devices. Agents working on finance folders or repositories outside OpenShell are blocked and told to use OpenShell. The public reports folder is never blocked.

Example 3: Strict enforcement

Setting

Value

When An Agent Works Outside OpenShell

block

Block When The Policy Cannot Be Read

On

If an agent hook can't read the policy, the action is blocked instead of allowed. Use this only after the policy has been stable on your devices, since a problem reading the policy would block agents.


Turn off or remove the policy

Turning off Enabled, or unassigning the policy, removes only what Swif installed for this policy. Agents can then work on confidential locations outside OpenShell again.


Troubleshooting

Actions are reported but not blocked

  • Check that When An Agent Works Outside OpenShell is set to block.

  • Check that the Swif OpenShell Sandbox Policy is assigned and enabled on the device. Without it, blocking is reported only, and the device is flagged.

  • On Windows, matches are reported, not blocked, and the device is flagged, because the Sandbox Policy doesn't apply there.

An agent isn't checked at all

  • Only Claude Code and Codex are supported. Other agents can't be hooked yet.

  • Check that the agent is listed in Agents, or that Agents is empty.

  • Check that the agent isn't running inside WSL 2 on Windows.

A confidential repository isn't detected

  • Check that the entry matches the repository's remote URL in the format host/owner/name.

  • For GitLab subgroups, include every part of the path, or use * as the last part.

  • Check the repository's remotes with git remote -v.

An agent was blocked on a file outside the confidential folder

The agent was started in a confidential folder. When the working directory is confidential, every tool call is caught, including calls that use files elsewhere. Start the agent outside the confidential folder, or run it inside OpenShell.

A command used a confidential file but wasn't caught

The path was probably built while the command ran, for example through a variable or a subshell. The policy only sees paths written in the command itself.

A folder is blocked that shouldn't be

  • Check whether the folder or a parent folder contains the marker file.

  • Add the folder to Exceptions, with a reason.

An agent is blocked even though it's in OpenShell

This policy only applies outside OpenShell sandboxes. Confirm that the agent is running inside a sandbox, and check the device's report for details.

Agents are blocked unexpectedly on one device

Block When The Policy Cannot Be Read may be on, and the agent hook can't read the policy on that device. Check that the Swif agent is running, or turn the setting off.


Related resources

Swif

NVIDIA

Did this answer your question?