Repository navigation
fix(box): let direct-egress tools verify TLS without the gateway - #412
Conversation
|
Assessment: Comment The fix is correct for the problem it names: a native leaf no longer receives the gateway's routing and CA names, and only Review Categories
Checked and held:
The split into a |
9f78a5d to
5b78b71
Compare
|
Re-review at Both open threads still apply, and neither has a reply yet:
The summary's merge preconditions also still apply: a linked approval for the frozen composed environment and the new decision, and a macOS run. Assessment: Comment (unchanged). |
5b78b71 to
4a38874
Compare
|
Assessment: Comment (re-review at This revision changes the design. Box no longer sets a CA file for a direct-egress process, and that process's table may set the proxy and CA names. The second change resolves the Review Categories
Checked and held:
|
Description
Problem
[tool.<name>.network] contain_egress = false(and the same key on a stdio MCP server) is meant to let one program connect directly, outside the gateway. Two things stopped it from working:environment::composeset Core's proxy and CA names in both egress modes. A direct-egress process still gotHTTPS_PROXYand friends pointing at the gateway, and the six CA names at the gateway's CA. Any proxy-aware client (Go,gh,reqwest,curl) sent its traffic through the gateway anyway, so the escape did nothing.com.apple.trustd.agent(OSStatus -26276) andcom.apple.SecurityServer(-9808from Secure Transport). That breaks Go ≤ 1.26, Go 1.27 with an oldergo.mod, Rustrustls-platform-verifierandnative-tls, and very likely Swift.Solution
Rule: a direct-egress program behaves as it does on the host. Box adds no proxy or CA setting of its own for it, and refuses none.
crates/box/src/run/contain/boundary.rs:environment::Inputsnow takes aRouteinstead of a baretrust_bundle.Route::Gateway { trust_bundle }composes exactly what it did before.Route::Nativesets none ofHTTP_PROXY,HTTPS_PROXY,http_proxy,https_proxy,NODE_USE_ENV_PROXY,NO_PROXY,no_proxy, and none of the six CA names. A native leaf also gets no read grant on the gateway's CA. Box sets no default CA file on either platform: a fixed file changes which roots a client trusts (on macOS,rustls-native-certsreads onlySSL_CERT_FILEwhen it is set, and/private/etc/ssl/cert.pemlacks keychain-added roots such as a TLS-inspection root).crates/box/src/record/config/env.rs,process.rs: a[tool.<name>]or stdio[mcp.<name>]table withcontain_egress = falsemay set those 13 proxy and CA names in itsenv(refused_native_egress_name), for a company proxy or CA bundle. A file it names still needs aread_fileentry. Gateway tables and the agent still refuse them, because the gateway's CA must win for interception to work.PWD,USER,OTEL_EXPORTER_OTLP_*,LD_*andDYLD_*stay refused everywhere. A tool pack that knows its client reads only a file sets that file in the table'senv.crates/containment/src/backend/macos/seatbelt.rs:Network::AllowAll(how native egress renders) adds(allow mach-lookup (global-name "com.apple.trustd.agent"))and(allow mach-lookup (global-name "com.apple.SecurityServer")), as the program has on the host.native-tlsneedsSecurityServer; the other clients need only trustd. The gateway path (Network::Localhost) and the agent get neither.native trust:line under the existingnative egress:line:strands-box: [tool.x] native trust: no proxy and no CA variable from Box, so its client uses its own defaults or its table'senv; the trustd and SecurityServer services for the system's certificate checks(the services clause on macOS only).docs/user/config.md(the refused-names list),docs/user/egress.md,docs/user/mcp.md,docs/design/egress.md,docs/design/macos-enforcement.md,crates/box/README.md,crates/box/AGENTS.md, and the macOS measurements incrates/containment/AGENTS.md.Interfaces that moved (frozen surfaces): the composed environment of a
contain_egress = falseprocess, and theenvnames such a table may set. A gateway-routed process, including the agent, is unchanged. The publiccheck_workload_envkeeps refusing all 13 names, because it has no table context; it is stricter than Core for direct tables.Keychain finding and its limits.
SecurityServeralso serves the keychain and authorization. On a Mac, a throwaway login-keychain generic password stayed unreadable through/usr/bin/securitywith both services allowed, because Box still refuses reads of the keychain files. So the program reaches the host's services, not the host's keychain files. Data-protection and iCloud keychain items were not tested; their service (secd) stays denied.Related Issues
Fixes #409. Related: #344, #311.
Type of Change
Bug fix
Testing
On Linux aarch64 at
4a38874(onorigin/main88e8c19):cargo build,cargo test,cargo clippy --all-targets,cargo fmt --checkwith--all-featuresforstrands-boxandstrands-box-containment: all pass, no new clippy warnings in either crate (the vendoredstrands-shellwarnings are unchanged).mcp_alias_fallbackneeds--test-threads=1on this host ("Text file busy" race); it passes that way.site_manifestpasses.only_a_native_egress_leaf_renders_the_trust_services: the agent and a gateway leaf render neither service; a native leaf renders both (box-level render, runs on Linux too).the_trust_services_render_only_with_native_egress(seatbelt render): both services render once withAllowAll, never with the gateway's localhost port.a_native_egress_leaf_gets_no_proxy_or_ca_from_core_and_keeps_its_own: no proxy or CA name and no gateway-CA grant from Core; a declaredHTTPS_PROXYandSSL_CERT_FILEreach the process unchanged.only_a_native_egress_table_may_set_the_proxy_and_ca_names: a direct table accepts the proxy and CA names, a gateway table refuses them with "set by the box itself", andPWD,USER,OTEL_EXPORTER_OTLP_ENDPOINTandLD_PRELOADstay refused on a direct table.a_gateway_leaf_routes_through_the_proxy_and_trusts_the_gateway_ca: every proxy name, every CA name at the gateway's CA, and the CA grant, unchanged.a_leaf_holds_no_operator_variable_only_its_spec_phantom_and_core_namesasserts the routing names only for the gateway mode;the_disclosure_names_native_egress_only_when_it_is_selectedchecks thenative trust:line./usr/bin/envtool gets all 13 proxy and CA names; acontain_egress = false/usr/bin/printenvtool gets none. A directcurltool verifiedapi.github.comwith the system roots once/etc/pkiwas granted, and failed withcurl: (77)on/etc/pki/tls/certs/ca-bundle.crtwithout it.On macOS 26 arm64, at
4a38874, with no test patches and a Box Corebox.tomlonly (one gateway tool and onecontain_egress = falsetool per probe,GET https://api.github.com/zen, gh usesgh api /zenwith a fake token):-26276-26276-26276-9808env.SSL_CERT_FILE = "/private/etc/ssl/cert.pem"+read_file/usr/bin/security<box_dir>/trust/cert.pem. The direct tool's environment holds none of them.native trust:line.com.apple.trustd.agentandcom.apple.SecurityServerdenials only from the gateway tools.5b78b71(which setSSL_CERT_FILEon direct tools) gave the same results for every shared row.Not covered
rustls-native-certswith no CA file found Apple's built-in roots. Roots an administrator added to/Library/Keychains/System.keychain(for example a TLS-inspection root) were not tested; Box refuses that tree, so such a client may miss them. Its tool pack or the operator can setSSL_CERT_FILEto a company bundle in that case.curlcould not resolve host names (curl: (6)) even with/etc/resolv.conf's target granted. The TLS check was done with--resolve. That is a separate, existing limit of direct egress on Linux.Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.