Security#
This page answers the questions a security team asks before a pilot. Each statement is
checked against the server source, docs/architecture.md, [operations] or deploy/.
Where a protection does not exist, the same section says so. Sandfort is version 0.1.0
and has no production references; read this page as a description of the code, not as an
assurance.
Paths such as docs/architecture.md, SECURITY.md and deploy/ are repository paths, not
published pages: read them in the source repository, the docs site does not serve them.
1. Threat model summary#
Users and AI agents submit code that Sandfort runs inside sandboxes. That code may be buggy or hostile. The platform tries to do three things with it:
- keep it contained: one sandbox should not reach the host, the control plane, other sandboxes or the platform's secrets;
- keep it resource-bounded: CPU, memory, processes and disk are capped per sandbox;
- keep the actions around it auditable: lifecycle and toolbox calls are recorded per organization.
The production driver is the Docker driver, and each sandbox runs on one of three isolation
tiers, chosen per sandbox (isolation on create). The container tier (runc) and the gvisor
tier (runsc) share the host kernel: under gvisor a user-space kernel handles the sandbox's
system calls, which narrows what reaches the host kernel but is not a hardware boundary. The
microvm tier (Kata Containers) gives each sandbox its own guest kernel in a lightweight VM and
needs KVM. On the hosted beta the microvm tier runs on nested KVM, and a hypervisor or Kata bug
is in scope for that tier. A kernel or runtime escape from a container or gvisor sandbox is
therefore in scope for the host, and the controls below reduce that risk without removing it.
The Firecracker driver
in the tree is a skeleton exercised against a mock agent and is not supported
(src/sandfort/drivers/firecracker/driver.py).
Tiers are mapped to Docker runtimes by the isolation tier map,
SANDFORT_ISOLATION_RUNTIMES (for example container=runc,gvisor=runsc,microvm=kata), and the
default tier is SANDFORT_DEFAULT_ISOLATION; see [isolation-tiers]. The runtimes must be
installed and registered on each node. Without a map, the only tier is the default one on
SANDFORT_CONTAINER_RUNTIME (empty means the daemon's default runtime). In prod the server
refuses to start when a configured runtime is not among the daemon's runtimes.
Not covered by this page's protections: a malicious operator or database administrator, a compromised Docker daemon, and anyone who already holds control of a sandbox node.
2. Sandbox isolation as configured by the Docker driver#
The container settings are built in src/sandfort/drivers/docker/hardening.py and asserted
by unit tests. Every sandbox gets:
| Control | Setting |
|---|---|
| Capabilities | cap_drop=ALL |
| Added back | CHOWN, DAC_OVERRIDE, FOWNER, SETUID, SETGID, KILL, NET_BIND_SERVICE |
| Privilege | privileged=False, no-new-privileges:true, init=True |
| Processes | pids_limit=512 |
| CPU | nano_cpus from the requested millicores |
| Memory | mem_limit from the request, memswap_limit equal to it (no swap) |
| Shared memory | shm_size is the smaller of 64 MiB and a quarter of memory |
| Open files | nofile soft and hard limit 4096 |
| Logs | local log driver, 10 MB per file, 3 files |
| Docker socket | not mounted into sandboxes |
What the table does not say:
- Seccomp is optional, and only the Kubernetes kit sets it.
deploy/seccomp.jsonis derived from the moby v28.3.3 default profile, with some syscalls removed and extra rules onclonearguments (see its_comment). The driver passes it as asecurity_optonly whenSANDFORT_SECCOMP_PROFILE_PATHpoints at it. The default is empty, which keeps Docker's own default profile. The file is read and validated once at startup.deploy/k8s/: the ConfigMap (configmap.yaml) setsSANDFORT_SECCOMP_PROFILE_PATH=/etc/sandfort/seccomp/seccomp.json, andapi.yamlmounts thesandfort-seccompConfigMap, which kustomize generates fromdeploy/seccomp.json, at/etc/sandfort/seccomp. Apply the kit with the load restrictor lifted (deploy/k8s/kustomization.yaml,deploy/k8s/README.md).deploy/compose.prod.ymlanddeploy/Dockerfile: neither sets the path or mounts the profile. To use it with compose, add the setting and a bind mount of the file yourself.- The driver passes the profile as a security option for every runtime once the path is set
(
src/sandfort/drivers/docker/hardening.py): the daemon passes it, but underrunscit is not applied to the sandboxed processes' syscalls the wayruncapplies it. On thegvisortier gVisor's own Sentry filters the syscalls, and the host-siderunscprocesses run under gVisor's own seccomp filters ([isolation-tiers]). The Kubernetes kit defaults togvisor(SANDFORT_DEFAULT_ISOLATION), so the profile there covers thecontainertier. - The Kubernetes
apimanifest (deploy/k8s/api.yaml) also setsseccompProfiletoRuntimeDefaultin the podsecurityContextof the API pod itself. That is a different thing from the sandbox profile above: it confines the API process, not the sandboxes.
- User-namespace remapping and the cgroup parent are opt-in; no AppArmor profile is set.
Remapping (
userns-remap) is a Docker daemon option that is daemon-wide; Sandfort does not turn it on, but it reads whether it is active and acts on it. Three server settings (src/sandfort/config.py):SANDFORT_USERNS_HOST_TIERS(defaultmicrovm; a blank value removes the opt-out) lists the tiers created with the host user namespace, because Kata cannot run remapped;SANDFORT_REQUIRE_USERNS_REMAP(defaultfalse) makesprodrefuse to start without remapping;SANDFORT_CGROUP_PARENT(default empty; must be a systemd slice name such assandfort.slice) sets the cgroup parent of every sandbox. Without remapping, container root maps to host root for every tier; with it, the tiers not in the opt-out list run remapped. Details, validation and the gate texts:docs/architecture.md, "Container hardening"; node steps in [operations]. The driver sets no AppArmor option, so the daemon's default applies where AppArmor is enabled, and no setting feeds theuserfield. - Disk limits need host support. The driver sets
storage_opt.sizefromdisk_gibwhenSANDFORT_ENVIRONMENT=prod. Docker honours it onoverlay2over XFS mounted withpquota, or on btrfs or zfs. The startup check readsdocker info, which does not show mount options, so XFS withoutpquotapasses the check and then fails at sandbox create. Outsideprodthe driver sets no disk limit unlessSANDFORT_ENFORCE_DISK_QUOTA=true, which enforces it in any environment (the hosted beta uses it; see [isolation-tiers], "Disk size"). prodrefuses to start on a weak host. The startup self-check (check_isolationinsrc/sandfort/api/app.py) refuses the start when disk quota support is missing, when the configured runtime is not registered with the daemon, or whenSANDFORT_EGRESS_ACKNOWLEDGEDis nottrue. Indevthese findings are only logged. Two daemon-level findings follow different rules. The user-namespace remapping finding refuses aprodstart only whenSANDFORT_REQUIRE_USERNS_REMAP=true; with the flag off it is logged as a warning (isolation advisory (does not refuse startup)), and outsideprodit is logged and tolerated. The default-runtime finding (the daemon default runtime is not one of the runtimes the tiers use, so tenant image builds run on it) is advisory in every environment: a warning, never a refusal. Both texts are indocs/architecture.md, "Container hardening".
Network#
All networked sandboxes join the bridge network sf-net, created with inter-container
traffic disabled (enable_icc=false). Three controls sit on top of that.
- Cloud metadata and private ranges. The driver itself does not filter addresses. The
block comes from
deploy/host-setup.sh, which installs iptables rules inDOCKER-USERthat reject traffic from the sandbox bridge to169.254.0.0/16(including the metadata address169.254.169.254),100.64.0.0/10, the Azure wire server168.63.129.16, and the RFC 1918 ranges. It also rejects new connections from sandboxes to the host's own address on the bridge. Without the script none of this applies. - Full block per sandbox.
network.block_allat create time runs the sandbox with Docker network modenone. It takes precedence over everything else, and combining it with an egress allowlist is refused. - Egress allowlist.
egress_allowlistat create time (at most 16 host names by default) puts the sandbox on a second bridge,sf-egress-net, whose firewall chain admits only the egress proxy address (SF_EGRESS_PROXY). The proxy is a separate process,python -m sandfort.egress.proxy, that checks signed tokens made withSANDFORT_EGRESS_SECRET. If the proxy address or secret is not configured, an allowlisted create is refused with 409 and never runs with open egress. Allowlisted creates are also refused when sandboxes are created by jobs.
Limits of the network controls, stated in deploy/host-setup.sh and [operations]:
- The script supports Linux hosts with the iptables backend and a
DOCKER-USERchain. It refuses to run elsewhere, and Docker's nftables firewall backend is not supported. Docker Desktop is out of scope. - The server cannot observe the rules.
prodrelies on the operator settingSANDFORT_EGRESS_ACKNOWLEDGED=trueafter running the script. Setting it without running the script removes the protection while passing the check. - IPv6 is filtered only for
fe80::/10andfc00::/7, and only ifip6tablesexists. Public IPv6 destinations are not filtered. - A sandbox without
block_alland without an allowlist can reach the public internet. - The default
SF_EGRESS_PROXYis127.0.0.1, which admits no real destination. Set it to the proxy host's address. A proxy on the Docker host itself needs its own INPUT rule.
Image build runtime#
Tenant image builds do not run on a sandbox tier runtime. They run on the Docker daemon's
default runtime, with Docker's default capabilities, no pids limit and no seccomp profile. When
a tier offers a strong runtime (a name containing runsc or kata) but the daemon default
runtime is not one of them, the capability check reports a build-runtime finding
(src/sandfort/drivers/docker/capabilities.py). Nothing is reported while no tier offers a
strong runtime.
- Production gate. With
SANDFORT_ENVIRONMENT=prodandSANDFORT_REQUIRE_BUILD_RUNTIMEon, that finding refuses startup. The setting defaults totruewhen read from the environment. Outside prod the finding is a logged warning. - Fix. Set the daemon's
default-runtimeto the strong runtime. SettingSANDFORT_REQUIRE_BUILD_RUNTIME=falsestarts the server anyway and accepts that tenant builds run with the weaker defaults.
3. What is outside the sandbox boundary#
- The Docker socket. It is never mounted into a sandbox. It is mounted into the server
pod:
deploy/k8s/api.yamlmounts/var/run/docker.sockand carries a warning that this grants host-level control of the node.deploy/k8s/worker.yamlis intentionally empty and mounts nothing; the supported topology is one pod withSANDFORT_ROLE=all. The api manifest keeps the pod on a dedicated node with anodeSelector(sandfort.dev/sandbox-node: "true") and a matching toleration of thesandfort.dev/sandbox-node=true:NoScheduletaint. [operations] recommends running sandbox workloads on dedicated nodes. - Namespace access is node root.
deploy/k8s/namespace.yamlsets pod security admission toprivilegedfor thesandfortnamespace, because the server pod useshostNetworkand ahostPathsocket. Anyone who is allowed to create pods in thesandfortnamespace is effectively root on the node. - Socket holder threat statement. The socket is never mounted into a sandbox, but any code execution in the server process is node root: the process holds the Docker client, and the daemon runs as root. Planned mitigations, in order and without dates: a Docker daemon authorization plugin next, a node agent later. Neither exists in this repository yet, so today the controls are the dedicated node, the namespace access above, and the sandbox hardening.
- Platform environment variables. Names starting with
SANDFORT_are reserved. A create request that sets one is rejected (422), and the driver rejects them again. The server's own settings are not passed to sandboxes, and a test checks that noSANDFORT_*variable is visible inside one. This protects the server's secrets from sandbox code. It does not stop a sandbox from reading anything that was deliberately put into it. - Git credentials. A credential sent with a git call is written to a temporary helper
for that one operation and removed in a
finallystep (src/sandfort/toolbox/git_credentials.py). It is not stored, and tests check that the token is absent from process environments, audit rows and stored logs.- Any credential handed to a sandbox is disclosed to the code running there. The
helper and the git binary both live in the sandbox filesystem. Code in the sandbox can
read the token while the operation runs, or replace
gitwith a program that copies the token out. Code can also keep running between calls and wait for the next credentialed operation, so one leaked token is not limited to one call. Treat every token you send as given to the sandbox code. - Push and pull are bound to the caller's host. A credentialed push or pull must
carry
remote_url. The server reads the repository's remote, refuses with 422UNPROCESSABLEwhen its scheme or host differs fromremote_url, and runs git againstremote_urlitself, not the remote name. The helper answers only password prompts for that host. A planted remote url orinsteadOfrule therefore cannot send the token to another host through git. This does not protect against the disclosure described above. - Mitigation. Send only short-lived tokens scoped to the one repository and the least permission the operation needs (read-only for clone and pull). Revoke or let them expire right after the call. Do not send a credential to a sandbox that runs code you would not give that token to. Uncredentialed push and pull by remote name are unchanged.
- Any credential handed to a sandbox is disclosed to the code running there. The
helper and the git binary both live in the sandbox filesystem. Code in the sandbox can
read the token while the operation runs, or replace
- Volumes and snapshots. Their contents are whatever sandbox code wrote. Treat them as untrusted data.
4. Control plane#
API keys. A key has the form sf_<env>_<prefix8>_<secret43>, with the secret drawn from
secrets.token_urlsafe(32). The plaintext is returned once. The database stores the lookup
prefix and v1$<salt>$<HMAC-SHA256(pepper, salt || key)> with a random salt per key, and
verification is constant-time (src/sandfort/auth/api_keys.py). The pepper comes from
SANDFORT_API_KEY_PEPPER and is empty by default, so it must be set.
Scopes and roles. Each key carries scopes and each route requires scopes; a missing
scope is a 403. Human members have the role admin, developer or viewer, and each role
maps to a set of scopes. Repository methods take org_id as a required argument, so
queries are scoped to one organization.
Key rotation and cascade. A key records the key that minted it (created_by). Revoking a
key (DELETE /v1/api-keys/{id}) revokes only that key by default. Its live descendants
(children, grandchildren, and so on) stay valid unless the request sets cascade=true, in the
JSON body or the query string. The response always lists those descendants under dependants
and carries a cascade flag: with cascade=true they were just revoked, otherwise they are
still alive. Rotate by minting the new key with the old one, then revoking the old one without
cascade; the new key survives. If you revoke a key because it leaked, use cascade=true, or
every key it minted keeps working. The cascade also runs for a key that is already revoked,
to clean up its remaining children. Source: src/sandfort/services/api_key_admin.py.
Child expiry bound. A key minted by a key that has an expires_at must set its own
expires_at, and it may not be later than the creator's. Otherwise the create is refused with
422 and details.max_expires_at names the bound. A child key therefore never outlives a
creator that expires.
SSO. POST /v1/auth/sso/exchange verifies an OIDC identity token and returns a signed
session token (sfs_..., HMAC-SHA-256 under SANDFORT_SESSION_SECRET, at least 32
characters). Its lifetime is configurable between 60 seconds and 24 hours. Verification
accepts RS256 only and checks signature, issuer, audience, expiry, email_verified, and a
header type of JWT. The key set URL must be https (plain http only for localhost).
SSO is bound to one organization (SANDFORT_OIDC_ORG_ID), and the user must already be a
member.
SCIM. Off by default (SANDFORT_SCIM_ENABLED). A SCIM token (sf_scim_...) belongs to
one organization, is hashed like an API key, is shown once, works only on /scim/v2, and
has a max_role ceiling: it cannot create or promote a member above that role. An
organization may hold at most 5 active tokens. Tokens do not expire; rotate by minting a
new one and revoking the old one. Removing a member through SCIM does not revoke API keys
that person created earlier.
Webhook secrets. A webhook signing secret (whsec_...) is shown once and stored encrypted
with a Fernet key (SANDFORT_WEBHOOK_SECRET_KEY). Production (SANDFORT_ENVIRONMENT=prod)
refuses to start without the key. Outside prod an empty key stores new secrets in plaintext.
Details are in
the governance page, section "Webhooks". The
repository's security policy, with the reporting
channel and the supported versions, is SECURITY.md at the repository root.
Limits to plan around:
- No built-in TLS. The server runs uvicorn without TLS options (
deploy/Dockerfile,src/sandfort/main.py), and the Kubernetes Service isClusterIP. API keys, session tokens and sandbox data travel in clear text unless you terminate TLS in front of the API. /metricsis open by default. An optional bearer token (SANDFORT_METRICS_TOKEN) guards it when set; the runbook says to keep it cluster-internal either way, because the token travels in clear text without TLS in front.- The node-to-node hop is not encrypted. With cross-node routing, a request for a
sandbox on another node is forwarded over plain HTTP. The hop carries a route token
(HMAC-SHA-256 under
SANDFORT_ROUTING_SECRET, valid 30 seconds, no principal) that proves the sender is a platform node, and the owning node still authenticates the forwarded API key. The API key, file contents and command output cross the internal network unencrypted, so a private network or an encrypted overlay between nodes is a requirement. - No fine-grained revocation for sessions. Session tokens are stateless and valid until they expire; the runbook documents that a removed member's token stops working because the membership check fails.
- No SCIM groups, no per-tenant SSO. See [operations].
5. Audit and tamper evidence#
The audit log is chained per organization. Each row stores prev_hash and
hash = HMAC-SHA256(key, prev_hash + canonical(row)), where key is
SANDFORT_AUDIT_CHAIN_KEY (at least 32 bytes) and the canonical form covers the fixed
fields of the row (src/sandfort/services/audit_chain.py). With no key set the hash is plain
sha256 over the same input; prod refuses to start in that state unless
SANDFORT_UNKEYED_AUDIT_CHAIN_ACKNOWLEDGED=true accepts the unkeyed chain explicitly. Audit rows are written in the
same transaction as the change they describe. The rule is one event per mutating call, with
named exceptions: a meta-test checks that every non-GET route writes one row for what it did.
A call refused after a valid key writes a request.denied row instead (a create or start
refused for host capacity writes sandbox.create_refused or sandbox.start_refused, at most
one per API key and reason per 60 seconds, the suppressed ones counted in
refusals_coalesced). A call that fails after it was accepted adds a failure row
(sandbox.failed, sandbox.reset_failed). Read (GET) calls write no rows, except the few
that read sandbox content. Details are redacted: no request bodies, no stdin, long commands
truncated, credentials dropped. A row also stores the client ip and user_agent; both are
stored unhashed and are not part of the hash, so they are readable by anyone with audit:read.
The full list of actions and the exceptions are on
the governance page, section Audit.
Two admin commands work on the chain:
python -m sandfort.admin_cli audit-verify # re-computes every chain; exit 3 if any row fails
python -m sandfort.admin_cli audit-export # ndjson with hash fields; --org-id, --output
python -m sandfort.admin_cli audit-verify --head export.ndjson # also check signed headsaudit-verify reports a hash mismatch, a broken link or a missing hash, and exits 3 when
there is any finding, so it can run from cron or CI.
Keyed chain. With SANDFORT_AUDIT_CHAIN_KEY set, a database writer without the key cannot
recompute the hashes of a rewritten history, so audit-verify fails on it. Rows written
before the key was set stay unkeyed. SANDFORT_AUDIT_CHAIN_ACCEPT_UNKEYED (default true)
lets verify accept and count them, but only before the first keyed row: an unkeyed row after
a keyed one is a finding, and so is a chain whose newest row is unkeyed while the key is
set, whatever the flag says. To migrate: set the key and restart, make one audited write per
org, run audit-verify and check it exits 0, then set the flag to false. Details are in
the governance page, section Audit. Hashes read
from the database are compared as bytes in
constant time.
Signed head. With the key set, audit-export ends each org's rows with one trailer line of
type audit_head (newest row id, its hash and an HMAC over them). Consumers of the export
must skip that line. audit-verify --head <file> checks the signature and that the live
chain still reaches the head row, which catches deleting the newest rows.
Ed25519 signature. With SANDFORT_AUDIT_SIGNING_KEY set as well, the head also carries alg,
public_key, signed_at (UTC, to the second) and signature. The HMAC needs the secret chain
key; the signature needs only the public key, so an auditor with no secret can check it.
GET /v1/status (no key needed) publishes audit_public_key and audit_key_fingerprint
(first 16 hex of sha256 over the raw public key), both null unless heads are signed. Pin the
fingerprint out of band, from the release notes or the operator's own channel, not from the
server that is being checked; the public_key inside a trailer is not a trust anchor.
sandfort audit verify-head <file> checks an export against that key. It proves that the
signature verifies, that the file's last row is the row the head names with the head's hash,
and that each row's prev_hash is the hash of the row before it. It does not prove the rows
before the last one: someone who rewrites prev_hash and hash consistently still passes,
a row edited without touching its hashes passes, and an older genuine export still verifies
(compare signed_at). Row hashes are keyed, so a client cannot recompute them. Only the
server-side check (sandfort audit verify, audit-verify, GET /v1/audit-events/verify)
proves the full chain. Details: governance page, section Audit.
The log is tamper-evident, not a guarantee against edits. The key lives outside the database, so
someone with only write access to the audit table cannot forge a consistent history. Someone who
holds the key as well, or any writer while the key is unset (plain SHA-256), can edit rows and
recompute the hashes, and audit-verify would then pass. Verification starts from the first row's
stored prev_hash, so pruning a prefix by retention is not flagged. To get stronger evidence,
export regularly and keep the exports somewhere the database operators cannot write.
6. Operational hardening checklist#
Walk this list before a pilot.
- [ ] Run sandboxes on dedicated nodes. The Docker socket gives control of the node.
- [ ] Put a private network or an encrypted overlay between nodes if you use cross-node
routing, and do not expose
SANDFORT_NODE_INTERNAL_URLports to clients. - [ ] Terminate TLS in front of the API. The server does not.
- [ ] Keep
/metricsreachable only from inside the cluster (and setSANDFORT_METRICS_TOKENif it must cross a boundary). - [ ] Use a Docker storage setup that supports disk quotas (
overlay2on XFS withpquota) and verify a create succeeds inprod. - [ ] Run
deploy/host-setup.shon every sandbox node after the Docker daemon starts and on every boot, then setSANDFORT_EGRESS_ACKNOWLEDGED=true. SetSF_EGRESS_PROXYif you use egress allowlists. - [ ] Decide which isolation tiers to offer and the default: map tiers to runtimes with
SANDFORT_ISOLATION_RUNTIMES(for examplecontainer=runc,gvisor=runsc,microvm=kata) and pickSANDFORT_DEFAULT_ISOLATION. Without a map, the only tier runs onSANDFORT_CONTAINER_RUNTIME(empty is the daemon default). Also decide on the seccomp profile (SANDFORT_SECCOMP_PROFILE_PATH): the Kubernetes kit sets it, the compose file does not, andrunscdoes not enforce it. No runtime map or profile is set by the server defaults. - [ ] Set
SANDFORT_API_KEY_PEPPER,SANDFORT_SESSION_SECRETand the other secrets from a secret manager. Never use defaults. - [ ] Back up the database (
pg_dump, per the runbook) and store the pepper with it. - [ ] Keep the pepper stable. Changing it invalidates every API key and every SCIM token.
- [ ] Run
audit-verifyon a schedule and keepaudit-exportfiles off the database host.
7. Reporting a vulnerability#
Sandfort is in a design-partner phase. If you suspect a vulnerability, report it privately
to the maintainer and do not open a public issue. SECURITY.md at the repository root
states the scope and the supported versions (the latest v0.1.0-beta.N tag). Send the report
by email to office@sandfort.dev, the public contact address, with "Security" in the subject
and no details in any public place. If you are a design partner, you can use the security or
support contact in your agreement instead. Once the repository is public, GitHub private
vulnerability reporting is an additional channel. There is no published key for
encrypted reports. Sandfort has no certifications: no SOC 2 report, no ISO 27001
certificate and no third-party penetration test.
[isolation-tiers]: https://docs.sandfort.dev/isolation-tiers.html [operations]: https://docs.sandfort.dev/operations.html