Skip to content

coder/boundary

 
 

Repository files navigation

boundary

Network isolation tool for monitoring and restricting HTTP/HTTPS requests from processes.

boundary creates an isolated network environment for target processes, intercepting HTTP/HTTPS traffic through a transparent proxy that enforces user-defined allow rules.

Features

  • Process-level network isolation (Linux namespaces)
  • HTTP/HTTPS interception with transparent proxy and TLS certificate injection
  • Wildcard pattern matching for URL patterns
  • Request logging and monitoring
  • Linux support
  • Default deny-all security model
  • Simple mode: No special permissions required (uses HTTP_PROXY environment variables)

Installation

Quick Install (Recommended)

curl -fsSL https://raw.githubusercontent.com/coder/boundary/main/install.sh | bash

For installation options, manual installation, and release details, see RELEASES.md.

From Source

Build boundary from source:

# Clone the repository
git clone https://github.com/coder/boundary.git
cd boundary

# Build the binary
make build

# Install binary and wrapper script (optional)
sudo cp boundary /usr/local/bin/
sudo cp scripts/boundary-wrapper.sh /usr/local/bin/boundary-run
sudo chmod +x /usr/local/bin/boundary-run

Requirements:

  • Go 1.24 or later
  • Linux

Usage Modes

boundary supports two modes of operation:

Simple Mode (No Special Permissions)

Simple mode uses HTTP_PROXY/HTTPS_PROXY environment variables to route traffic through the proxy. No sudo, no capabilities, no special permissions required.

# No sudo needed!
boundary --simple --allow "domain=github.com" -- curl https://github.com
boundary --simple --allow "domain=*.npmjs.org" -- npm install
boundary --simple -- bash

Trade-off: Processes can bypass the proxy by ignoring the HTTP_PROXY/HTTPS_PROXY environment variables. Use namespace mode for stronger isolation.

Namespace Mode (Full Isolation)

Namespace mode uses Linux network namespaces and iptables for complete network isolation. Processes cannot bypass the proxy.

The recommended way to run in namespace mode is using the boundary-run wrapper, which handles privilege escalation automatically:

boundary-run --allow "domain=github.com" -- curl https://github.com
boundary-run -- bash

Note: If you installed boundary manually, you can install the wrapper script separately:

sudo cp scripts/boundary-wrapper.sh /usr/local/bin/boundary-run
sudo chmod +x /usr/local/bin/boundary-run

Direct Namespace Mode Usage

If you prefer to run boundary directly in namespace mode, you'll need to handle privilege escalation:

# Note: sys_admin is only needed in restricted environments (e.g., Docker with seccomp).
# If boundary works without it on your system, you can remove +sys_admin from both flags.
sudo -E env PATH=$PATH setpriv \
  --reuid=$(id -u) \
  --regid=$(id -g) \
  --clear-groups \
  --inh-caps=+net_admin,+sys_admin \
  --ambient-caps=+net_admin,+sys_admin \
  boundary --allow "domain=github.com" -- curl https://github.com

Comparison

Feature Simple Mode Namespace Mode
Permissions Required None CAP_NET_ADMIN (via sudo)
Network Isolation Environment-based Full namespace isolation
Can Process Bypass? Yes (ignore env vars) No
Setup Complexity Simple Requires wrapper or setpriv

Examples

# Simple mode - no special permissions
boundary --simple --allow "domain=github.com" -- curl https://github.com

# Namespace mode with full isolation
boundary-run --allow "domain=github.com" -- curl https://github.com

# Allow full access to GitHub issues API, but only GET/HEAD elsewhere on GitHub
boundary --simple \
  --allow "domain=github.com path=/api/issues/*" \
  --allow "method=GET,HEAD domain=github.com" \
  -- npm install

# Default deny-all: everything is blocked unless explicitly allowed
boundary --simple -- curl https://example.com

Allow Rules

Format

--allow "key=value [key=value ...]"

Keys:

  • method - HTTP method(s), comma-separated (GET, POST, etc.)
  • domain - Domain/hostname pattern
  • path - URL path pattern(s), comma-separated

Examples

boundary --simple --allow "domain=github.com" -- git pull
boundary --simple --allow "domain=*.github.com" -- npm install           # GitHub subdomains
boundary --simple --allow "method=GET,HEAD domain=api.github.com" -- curl https://api.github.com
boundary --simple --allow "method=POST domain=api.example.com path=/users,/posts" -- ./app  # Multiple paths
boundary --simple --allow "path=/api/v1/*,/api/v2/*" -- curl https://api.example.com/api/v1/users

Wildcards: * matches any characters. All traffic is denied unless explicitly allowed.

Logging

boundary --simple --log-level warn --allow "domain=github.com" -- git pull  # Default: only logs denied requests
boundary --simple --log-level info --allow "method=*" -- npm install     # Show all requests
boundary --simple --log-level debug --allow "domain=github.com" -- git pull  # Debug info

Log Levels: error, warn (default), info, debug

Platform Support

Platform Implementation Privileges
Linux Network namespaces + iptables CAP_NET_ADMIN (namespace mode only)
Linux Simple mode (HTTP_PROXY) None
macOS Not supported -
Windows Not supported -

Security and Privileges

Simple Mode

Simple mode runs entirely as your regular user with no elevated privileges. The target process receives HTTP_PROXY and HTTPS_PROXY environment variables pointing to the boundary proxy.

Namespace Mode

All processes are expected to run as non-root users for security best practices:

  • boundary-parent: The main boundary process that sets up network isolation
  • boundary-child: The child process created within the network namespace
  • target/agent process: The command you're running (e.g., curl, npm, bash)

The boundary-run wrapper script handles privilege escalation automatically using setpriv to drop privileges before launching boundary. This ensures all processes run with the minimum required capabilities (CAP_NET_ADMIN and optionally CAP_SYS_ADMIN for restricted environments) while executing as your regular user account.

If you run boundary directly with sudo (without setpriv), all processes will run as root, which is not recommended for security reasons. Always use boundary-run or the equivalent setpriv command shown in the Direct Namespace Mode Usage section.

Command-Line Options

boundary [flags] -- command [args...]

 --simple                    Use simple mode (no network isolation, no special permissions)
 --config <PATH>             Path to YAML config file (default: ~/.config/coder_boundary/config.yaml)
 --allow <SPEC>              Allow rule (repeatable). Merged with allowlist from config file
 --log-level <LEVEL>        Set log level (error, warn, info, debug). Default: warn
 --log-dir <DIR>             Directory to write logs to (default: stderr)
 --proxy-port <PORT>        HTTP proxy port (default: 8080)
 --pprof                     Enable pprof profiling server
 --pprof-port <PORT>         pprof server port (default: 6060)
 -h, --help                  Print help

Environment variables: BOUNDARY_SIMPLE, BOUNDARY_CONFIG, BOUNDARY_ALLOW, BOUNDARY_LOG_LEVEL, BOUNDARY_LOG_DIR, PROXY_PORT, BOUNDARY_PPROF, BOUNDARY_PPROF_PORT

Development

make build          # Build for current platform
make build-all      # Build for all platforms
make test           # Run tests
make test-coverage  # Run tests with coverage
make clean          # Clean build artifacts
make fmt            # Format code
make lint           # Lint code

Architecture

For detailed information about how boundary works internally, see ARCHITECTURE.md.

License

MIT License - see LICENSE file for details.

About

No description, website, or topics provided.

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published