For the complete documentation index, see llms.txt. This page is also available as Markdown.

BlueWarden Egress Security

BlueWarden operates as a per-sandbox egress security proxy designed for AI coding agents running inside the BlueRock Sandbox environment. Every outbound TCP connection initiated by a sandboxed agent passes through BlueWarden, where configured security policies dictate accessible destinations and permissible Large Language Models (LLMs) before data leaves the host.

Prerequisite

BlueWarden must be enabled in the host configuration file (/etc/bluedev/bouncer.toml) before policy rules in bru_policy.json can take effect. If BlueWarden is disabled in bouncer.toml, all warden policy rules will be ignored.

bouncer.toml
[warden]
enable = true

Connection Handling & Enforcement Architecture

First-Byte Traffic Inspection

BlueWarden inspects the initial bytes of every connection opened by the sandbox to classify and handle traffic based on content rather than port numbers. No policy field names a port for protocol classification, ensuring that internal services or gateways running on non-standard ports receive deep packet inspection.

Initial Bytes Observed

Routing & Handling Protocol

TLS Handshake (any port)

Decrypted and inspected using a certificate minted for the sandbox, unless the target server is listed in tls.passthrough.hosts.

HTTP Request Line / HTTP/2 Preface (any port)

Parsed as cleartext HTTP and evaluated against http and llm policy rules.

DNS Query (port 53 UDP/TCP, port 853 TCP)

Handled or proxied according to the dns block configuration.

Unrecognized / Non-Web Data

Relayed byte-for-byte unread, subject exclusively to Layer 4 destination checks in egress.destinations.allow_to.

  • Port-Agnostic Processing: An LLM gateway on port 3000 undergoes identical application-layer inspection to standard public endpoints. Non-web protocols (such as database connections or SSH) running on port 443 are carried unread rather than reset.

  • Datagram & Protocol Floor: All TCP traffic is forced through BlueWarden. UDP traffic is filtered at the kernel layer via egress.destinations.allow_to rather than proxied. Non-TCP/UDP protocols (such as ICMP) pass without proxy filtering.

Two-Tiered Enforcement Model

To prevent accidental disruption during deployment, every enforcement mechanism in BlueWarden operates under a two-tiered control model:

  1. Module enable Switch: Controls whether a mechanism actively inspects traffic and generates telemetry.

  2. Module remediate Switch: Controls whether policy violations trigger traffic blocking (true) or operate in watch-and-record mode (false).

Model pinning requires three active remediation switches (options.remediate: true, llm.remediate: true, and llm.model.remediate: true).

Configuration Reference

All BlueWarden configurations reside within the bru_policy.json file, defined under app_policies.default.warden for default policies or app_policies.<policy_name>.warden for custom, user-defined policies.

Global Options (options)

The options block defines proxy-wide enforcement toggles and failure behavior.

  • remediate (boolean, default: false): Master enforcement toggle. While false, BlueWarden inspects and records all traffic without blocking any connections. When true, individually armed modules begin enforcing denials.

  • fail_closed (boolean, default: false): Controls sandbox network behavior if the BlueWarden proxy process terminates or restarts. When false, temporary proxy failures bypass inspection. If proxy crash-looping trips the circuit breaker (5 restarts within 300 seconds), network egress is permanently isolated while the workload remains running. When true, temporary failures pause egress; if the circuit breaker trips, the sandbox container is terminated immediately via SIGKILL.

notes

Note:

  • Unspecified/broadcast addresses, documentation ranges, and connections directed back to BlueWarden's own listeners are refused regardless of enforcement settings.

  • If BlueWarden loses its connection to bluerockd, for example while bluerockd restarts, BlueWarden exits and is restarted like any other BlueWarden failure. A restart succeeds once bluerockd is available again, and enforcement resumes. If bluerockd is still unavailable when the circuit breaker trips, the sandbox is left without network access (fail_closed: false) or terminated (fail_closed: true).

TLS Configuration (tls)

Governs TLS termination and pass-through exemptions.

  • passthrough.hosts (array of strings, default: []): Explicit list of FQDN hostnames that bypass TLS decryption (e.g., ["pinned-sdk.vendor.com"]). Wildcards are prohibited. Passthrough traffic is relayed without decryption (retaining end-to-end TLS). Host allow/deny rules are still enforced by SNI inspection. Path scoping, model pinning, and MCP filtering are bypassed..

  • require_server_name (boolean, default: enable: true, remediate: false): Refuses TLS handshakes that omit the Server Name Indication (SNI) extension.

HTTP & Web Endpoint Filtering (http)

Evaluates all decrypted web traffic, inference calls, and MCP exchanges. Host filtering is configured within the endpoint sub-block using host pattern entries and optional path scopes.

  • endpoint.allow_list (array of strings or objects, default: []): Denies outbound HTTP traffic from the sandbox to external endpoints by default, permitting only the web hostnames and path objects explicitly specified in the list.

  • endpoint.deny_list (array of strings or objects, default: []): Permits outbound HTTP traffic from the sandbox to external endpoints by default, blocking only the web hostnames and path objects explicitly specified in the list.

notes

Note:

allow_list and deny_list are mutually exclusive. Populating both parameters within the same policy causes compilation failure.

Host Patterns

  • api.example.com: Matches the exact hostname.

  • .example.com: Matches the apex domain and all subdomains.

  • *.example.com: Matches subdomains only (excluding apex).

Path Scoping

Host entries can be expanded into objects to restrict path prefixes:

only_paths and except_paths are mutually exclusive and segment-anchored.

Request Invariants

  • require_host: Refuses requests missing a valid Host header.

  • sni_mismatch: Refuses requests where the HTTP Host header contradicts the TLS SNI server name (domain fronting).

  • protocol_upgrade: Refuses switches to uninspectable protocols (such as h2c or CONNECT tunnels). Standard WebSockets are permitted as frame payloads remain inspected.

LLM Inference Recognition & Model Pinning (llm)

BlueWarden inspects JSON request payloads on the wire to enforce model selection rules.

  • model.allow_list / deny_list (array of strings, default: []): Glob-matched lists defining permitted or blocked model names (e.g., ["claude-*"], ["gpt-4*"]).

  • model.remediate (boolean, default: false): Controls enforcement for model pinning. Blocking an unauthorized model call requires options.remediate: true, llm.remediate: true, and llm.model.remediate: true.

Provider Independence

BlueWarden automatically recognizes known endpoints (Anthropic, OpenAI, ChatGPT backend), but also evaluates any HTTP request body containing a top-level model field regardless of the destination host.

Unreadable Payloads

Requests with obfuscated, corrupted, or non-decodable model fields trigger an automatic policy violation if either list is active.

Client Refusal Emulation

When a request names a model blocked by policy, BlueWarden returns a single unified provider-native JSON response directly to the client with HTTP Status 400 Bad Request. This prevents LLM SDKs (such as Anthropic or OpenAI) from mistaking policy denials for credential failures or triggering continuous authentication retry loops:

Response Telemetry

Decodes reply streams to emit telemetry regarding token outputs and tool-call requests without altering response content.

DNS Control (dns)

BlueWarden captures all sandbox DNS lookups on port 53 by default. Upstream resolvers are configured via nameservers (array of strings, default []), falling back to /etc/resolv.conf when empty.

Transport Controls

  • allow_over_udp_tcp (default: true): Resolves standard DNS queries via configured nameservers.

  • allow_over_https (default: true): Answers DNS-over-HTTPS queries transparently within web traffic.

  • enable (boolean, default: true): Controls whether the DNS proxy module actively processes lookups.

  • remediate (boolean, default: false): Master switch for DNS transport enforcement. Requires options.remediate: true and dns.remediate: true to refuse non-permitted DNS transports.

  • allow_over_tls (boolean, default: false): Controls DNS-over-TLS (port 853). When dns.remediate is false, DoT traffic is observed and forwarded; when true, DoT traffic is dropped.

lightbulb-exclamation-on

Egress Controls (egress)

The egress block governs non-web TCP/UDP routing, protocol classification requirements, and network boundary security.

  • remediate (boolean, default: false): Parent enforcement arm for destination lists (allow_to/deny_to), UDP controls, block_quic, and block_dns_over_tls. Address guards (deny_private_addresses, deny_link_local_addresses) and require_known_protocol operate independently of egress.remediate, responding to options.remediate and their own remediate flags.

  • destinations.allow_to / deny_to (array of objects, default: []): Rules defining non-web destinations. Entries require three attributes:

    • addr: Destination CIDR block or IP address (e.g., "10.0.5.10/32"). Hostnames are accepted only for UDP rules (proto: ["udp"]) and are resolved once upon policy installation. TCP rules must use explicit IP addresses or CIDR blocks.

    • ports: Array of permitted/denied port integers (e.g., [22, 5432]).

    • proto: Array of protocols (e.g., ["tcp"], ["udp"]). Omission applies the rule to both TCP and UDP.

  • block_quic (boolean, default: true): Drops UDP traffic on port 443. This forces browsers and tools to fall back from HTTP/3 to inspectable TCP.

  • require_known_protocol (boolean, default: enable: true, remediate: false): Refuses connections whose initial bytes are neither a TLS handshake nor an HTTP request line. Arms directly with options.remediate.

Address Guards

  • deny_private_addresses: Blocks cleartext HTTP and tls.passthrough dials targeting RFC1918, loopback, and carrier-grade NAT space. (Inspected HTTPS traffic is governed by http.endpoint, and raw TCP is governed by egress.destinations). Exceptions are defined via allowed_private_destinations (e.g., ["172.31.0.0/16"]).

  • deny_link_local_addresses: Blocks access to 169.254.0.0/16, protecting cloud metadata endpoints (e.g., 169.254.169.254). Exceptions are set via allowed_link_local_destinations.

lightbulb-exclamation-on

Telemetry & Observability Events

BlueWarden emits structured telemetry events for every processed flow and policy violation. Enabling a module automatically activates its corresponding telemetry stream.

Telemetry Record / Event
Description & Triggering Mechanism

warden_connect

Connection acceptance record containing target address, dialled port, TLS SNI, and classification branch.

warden_http_request

Decrypted HTTP request record capturing host, path, HTTP method, and invariant flags.

warden_llm_request

Inference exchange record capturing target model ID and provider endpoint.

warden_llm_response

Inference response telemetry capturing completion status and token counts (tool-call intents recorded separately in warden_llm_tool_call).

warden_dns

Name resolution record containing queried hostname, query type, resolved IP addresses, and TTL.

warden_flow

Completed flow summary record emitted ~2 minutes after TCP termination, detailing total bytes transferred and policy_verdict (would_deny, allowed, denied).

warden_endpoint_violation

Refusals by http.endpoint host and path rules.

warden_model_violation

Refusals by model pinning.

warden_dns_violation

DNS queries and transports refused by the dns block.

warden_invalid_protocol

Raised on refusals by tls.require_server_name (no_sni), http.require_host (missing_host), and http.protocol_upgrade (upgrade_refused).

warden_sni_host_mismatch

Raised on domain-fronting refusals by http.sni_mismatch.

warden_ssrf_blocked

Raised when cleartext HTTP requests are blocked by deny_private_addresses or deny_link_local_addresses.

warden_egress_violation

Raised on non-web TCP/UDP layer-4 refusals (destination lists, link-local guards, require_known_protocol).

Complete Annotated Policy Configuration

Below is a reference JSON configuration illustrating an active, fully configured warden block populated with representative production policies. Configure this object under app_policies.<policy_name>.warden within bru_policy.json:

Phased Rollout Workflow

To prevent service disruption, operators must deploy BlueWarden using a structured six-stage workflow:

  1. Observation Posture (Watch): Deploy BlueWarden with default settings (options.remediate: false). All module inspection engines remain active, recording traffic flows without blocking any connections.

  2. Traffic Analysis: Review warden_llm_request (for model IDs and hosts), and warden_http_request (for web destinations). Use verdict_reason on warden_flow records exclusively to identify connection-level blocks.

  3. Content Rules: Set options.remediate: true. Enable remediate: true selectively on http.endpoint, llm (setting both llm.remediate and llm.model.remediate).

  4. Integrity Guards: Set remediate: true on tls.require_server_name, http.require_host, http.sni_mismatch, http.protocol_upgrade, deny_private_addresses, and deny_link_local_addresses.

  5. Configure Fail-Closed Availability: Evaluate operational requirements and set options.fail_closed: true for sensitive production workloads. Note: If BlueWarden crash-loops, fail_closed: true will terminate the sandbox container via SIGKILL.

  6. Lock Layer 4 Datapath: Enable egress.remediate: true. Non-web TCP/UDP traffic not explicitly listed in egress.destinations.allow_to is dropped.

notes

Note:

Policy updates apply immediately without requiring a sandbox container restart or interrupting existing connections. Setting options.remediate: false instantly reverts the entire proxy to observation posture.

Last updated