M4-egress-defaults #126
pt-act
started this conversation in
Feature Request
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Proposal
Summary
Ship the examples with least-privilege egress by default: the container-backed examples
should not enable unrestricted network egress (
{ mode: "direct" }) without an explicit,visible opt-in, and the docs should state the risk at the point of configuration.
Background and motivation
examples/mcp/src/index.tswires its container backend withegress: { mode: "direct" },which grants code executed in the sandbox unrestricted outbound network access — including
internal services and cloud-metadata endpoints (
169.254.169.254). The worker backend inthe same file already defaults to
{ mode: "none" }, so the container backend is the oneremaining permissive default in the shipped examples. Examples are the first thing users
copy, so a permissive default propagates into downstream projects.
examples/egressalready demonstrates the safer pattern:workspaceEgressPolicywith anhttp-gatewayand anEgressGatewaythat pins an exact origin and usesredirect: "manual". The default-vs-example mismatch is the gap.Who is affected: anyone starting from the MCP example and running untrusted or
model-generated code in the container backend.
Goals
none(or an allowlistedgateway); make
directreachable only via an explicit env flag / clearly-namedconstant, so opting into full network reach is a visible act rather than an inherited
default.
full-network-reach / SSRF-to-metadata risk of
direct/all, pointing to the gatewaypattern in
examples/egress.the gateway engine itself.
packages/computeregress policy types or enforcement.Example
examples/mcptoday:Proposed:
We have a working implementation of this change for
examples/mcp(env-gated default)plus the egress-mode warning block for
examples/egress/README.md; it applies cleanly oncurrent
main. Per the contribution policy we have not opened a PR — happy to if themaintainers would like one.
All reactions