MiniBox applies layered hardening across three surfaces: the API, the container runtime, and the build pipeline. This page documents every control, where it is implemented, and its effective scope.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/chaitu426/minibox/llms.txt
Use this file to discover all available pages before exploring further.
API Security
Theminiboxd HTTP API exposes all build and runtime operations. The following controls protect the API surface.
Bearer Token Authentication
WhenMINIBOX_API_TOKEN is set, the requireAPIToken middleware in internal/api/auth.go enforces authentication on every request. Two header forms are accepted:
MINIBOX_API_TOKEN is not set, all requests are accepted without authentication. This is appropriate only for local-only, loopback-bound deployments.
Method-Based Routing
Routes are registered with explicit HTTP methods (GET, POST) in internal/api/router.go. A request to a valid path with a wrong method returns 405 Method Not Allowed rather than falling through to the handler.
Request Body Limits
High-risk endpoints that accept user-controlled payloads (build context metadata, run options) have explicit request body size limits to prevent memory exhaustion from oversized payloads.Security Response Headers
The API setsX-Content-Type-Options: nosniff on responses to prevent MIME-type sniffing by HTTP clients that may interpret responses in unexpected ways.
Runtime Hardening
Every container spawned by MiniBox is subject to the following isolation and restriction controls, applied in the child process beforeexec of the workload.
Namespace Isolation
MiniBox clones four Linux namespaces for each container:| Namespace | Flag | Effect |
|---|---|---|
| PID | CLONE_NEWPID | Container processes cannot see or signal host processes |
| UTS | CLONE_NEWUTS | Container has its own hostname |
| Mount | CLONE_NEWNS | Container filesystem changes do not affect the host |
| Network | CLONE_NEWNET | Container has an isolated network stack (its own eth0, routing table, and iptables state) |
Seccomp Deny-List
A seccomp BPF filter (internal/runtime/seccomp_linux.go) is applied before the workload executes. The filter is deny-list based: a set of high-risk syscalls are blocked, and all others are permitted.
PR_SET_NO_NEW_PRIVS is set via prctl(2) before the seccomp filter is loaded. This ensures the filter cannot be bypassed by a setuid or setgid binary inside the container.
Capability Drop
Capabilities are dropped ininternal/runtime/drop_linux.go before exec. The workload starts with a minimal capability set, removing most host-administration capabilities.
Resource Limits (rlimits)
Hard and soft resource limits are applied to the container process to bound runaway resource consumption. Limits are set on file descriptor count, process count, and core dump size.cgroups v2
The daemon writes cgroup v2 knobs for the container:| Knob | Effect |
|---|---|
memory.max | Caps container memory usage |
cpu.max | Throttles CPU share |
cpuset.cpus | Pins to allowed CPUs |
io.weight | Sets block I/O weight |
cgroup.procs | Assigns container PID to cgroup |
db_mode containers, oom_score_adj is set to -900 to make the OOM killer prefer other processes over the database.
Build Security
Build Context Path Restrictions
TheMINIBOX_BUILD_PREFIXES environment variable defines which filesystem paths are allowed as build contexts. The check in internal/security/security.go (ResolveAllowedPath) resolves the submitted path to an absolute path, verifies it is a directory, and confirms it falls under one of the allowed prefixes.
Default allowed prefixes:
ErrBuildPathNotAllowed before any filesystem operation begins.
Path Traversal Prevention
The security package validates all container-scoped file paths withContainerFile(). This function resolves the path to an absolute form and verifies it remains under the container’s directory using a strict prefix check. Any path that escapes the container directory returns ErrPathEscape.
Container IDs are validated against a strict 8-character lowercase hex regular expression (^[a-f0-9]{8}$) before use in any filesystem operation.
Delete Safety
Before any deletion,SafeToDelete() in internal/security/security.go checks the target path against a list of protected system paths:
DataRoot directory itself or any path that escapes the data root.
Root Daemon Note
The daemon binds to127.0.0.1:8080 by default, limiting its API to loopback access. For any environment where the loopback assumption is insufficient (multi-user systems, CI runners, exposed VMs), combine a non-default MINIBOX_HTTP_ADDR with a strong MINIBOX_API_TOKEN.