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.
[warden]
enable = trueConnection 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_torather 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:
Module
enableSwitch: Controls whether a mechanism actively inspects traffic and generates telemetry.Module
remediateSwitch: 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. Whilefalse, BlueWarden inspects and records all traffic without blocking any connections. Whentrue, individually armed modules begin enforcing denials.fail_closed(boolean, default:false): Controls sandbox network behavior if the BlueWarden proxy process terminates or restarts. Whenfalse, 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. Whentrue, temporary failures pause egress; if the circuit breaker trips, the sandbox container is terminated immediately via SIGKILL.
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.
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 ash2corCONNECTtunnels). 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 requiresoptions.remediate: true,llm.remediate: true, andllm.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. Requiresoptions.remediate: trueanddns.remediate: trueto refuse non-permitted DNS transports.allow_over_tls(boolean, default:false): Controls DNS-over-TLS (port 853). Whendns.remediateisfalse, DoT traffic is observed and forwarded; whentrue, DoT traffic is dropped.
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, andblock_dns_over_tls. Address guards (deny_private_addresses,deny_link_local_addresses) andrequire_known_protocoloperate independently ofegress.remediate, responding tooptions.remediateand their ownremediateflags.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 withoptions.remediate.
Address Guards
deny_private_addresses: Blocks cleartext HTTP andtls.passthroughdials targeting RFC1918, loopback, and carrier-grade NAT space. (Inspected HTTPS traffic is governed byhttp.endpoint, and raw TCP is governed byegress.destinations). Exceptions are defined viaallowed_private_destinations(e.g.,["172.31.0.0/16"]).deny_link_local_addresses: Blocks access to169.254.0.0/16, protecting cloud metadata endpoints (e.g.,169.254.169.254). Exceptions are set viaallowed_link_local_destinations.
Telemetry & Observability Events
BlueWarden emits structured telemetry events for every processed flow and policy violation. Enabling a module automatically activates its corresponding telemetry stream.
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:
Observation Posture (
Watch): Deploy BlueWarden with default settings (options.remediate: false). All module inspection engines remain active, recording traffic flows without blocking any connections.Traffic Analysis: Review
warden_llm_request(for model IDs and hosts), andwarden_http_request(for web destinations). Useverdict_reasononwarden_flowrecords exclusively to identify connection-level blocks.Content Rules: Set
options.remediate: true. Enableremediate: trueselectively onhttp.endpoint,llm(setting bothllm.remediateandllm.model.remediate).Integrity Guards: Set
remediate: trueontls.require_server_name,http.require_host,http.sni_mismatch,http.protocol_upgrade,deny_private_addresses, anddeny_link_local_addresses.Configure Fail-Closed Availability: Evaluate operational requirements and set
options.fail_closed: truefor sensitive production workloads. Note: If BlueWarden crash-loops,fail_closed: truewill terminate the sandbox container via SIGKILL.Lock Layer 4 Datapath: Enable
egress.remediate: true. Non-web TCP/UDP traffic not explicitly listed inegress.destinations.allow_tois dropped.
Last updated