← All articles

MCP Network Isolation: Complete Security Guide

July 20, 2026·24 min read·MCPForge

MCP Network Isolation: Complete Security Guide

MCP servers connect AI applications to files, databases, APIs, developer tools, cloud platforms, and internal business systems.

That connectivity creates value, but it also creates pathways an attacker may abuse.

A malicious or compromised MCP server may attempt to:

  • scan the local network
  • contact cloud metadata services
  • exfiltrate source code or credentials
  • reach internal APIs
  • communicate with command-and-control infrastructure
  • access another MCP server
  • bypass perimeter controls through SSRF
  • expose a local HTTP endpoint to remote devices
  • use the MCP client as a network proxy

Network isolation limits these pathways.

Instead of allowing every MCP component to communicate with every reachable system, the environment permits only the connections required for a documented function.

text
Unrestricted MCP Server
        │
        ├── Internet
        ├── Localhost
        ├── Private Network
        ├── Cloud Metadata
        ├── Databases
        └── Other MCP Servers

A more secure design narrows the boundary:

text
Isolated MCP Server
        │
        ├── Approved API
        └── Approved DNS Resolver

Blocked:
Localhost
Private Networks
Metadata Services
Unknown Internet Hosts
Other MCP Servers

Quick Answer

MCP network isolation means placing clients and servers inside restricted network boundaries, denying unnecessary ingress and egress, binding local HTTP servers only to loopback, and allowing access solely to approved destinations. It reduces the blast radius of malicious servers, prompt injection, SSRF, token theft, and software supply-chain compromise.


Why MCP Needs Network Isolation

MCP combines two security-sensitive properties:

  1. Servers may access valuable systems.
  2. Language models may decide when and how tools are invoked.

A conventional application usually contains predefined request paths.

An MCP-enabled application may generate a URL, hostname, query, file reference, or callback dynamically based on:

  • user instructions
  • tool results
  • external documents
  • web content
  • repository files
  • output from another MCP server

That information may be malicious.

text
Untrusted Document
       │
       ▼
Language Model
       │
Generates Tool Argument
       │
       ▼
MCP Fetch Tool
       │
       ▼
Internal Network Target

Input validation should block the request at the application layer.

Network isolation adds another control below the application. If validation fails, the operating environment can still prevent the connection.

This is defense in depth.


Network Isolation Is Not Authentication

Network isolation and authentication solve different problems.

ControlPrimary purpose
AuthenticationDetermines who or what is making a request
AuthorizationDetermines what that identity may do
Network isolationDetermines which network paths are possible
Input validationDetermines whether supplied values are acceptable
SandboxingRestricts process access to system resources

An authenticated MCP server can still be compromised.

An authorized client can still send a dangerous URL.

A trusted package can still contain a vulnerable dependency.

Therefore, access to a network should not be granted merely because a component has a valid identity.


MCP Network Trust Boundaries

A typical deployment may include several distinct network boundaries:

text
User Device
   │
   ▼
MCP Host
   │
   ▼
MCP Client
   │
   ├──────── Local Server
   │
   └──────── Remote MCP Gateway
                     │
                     ▼
                 MCP Server
                     │
             ┌───────┼────────┐
             ▼       ▼        ▼
          Database  SaaS   Internal API

Important trust boundaries include:

  • browser to local MCP endpoint
  • MCP host to local server process
  • MCP client to remote server
  • remote server to internal resource
  • server to Authorization Server
  • server to downstream API
  • one MCP server to another
  • workload to cloud metadata service
  • container to host network
  • tenant to tenant

Every permitted connection should have an explicit reason.


Want to analyze your API security?

Import your OpenAPI spec and generate a Security Report automatically.

Ingress and Egress

Network isolation is usually divided into two directions.

Ingress

Ingress is traffic entering the MCP component.

Examples include:

  • a client connecting to a remote MCP server
  • a browser reaching a local HTTP listener
  • another container contacting the MCP workload
  • an internal service calling the server endpoint

Egress

Egress is traffic leaving the MCP component.

Examples include:

  • the MCP server calling a SaaS API
  • OAuth metadata discovery
  • database connections
  • DNS requests
  • package downloads
  • webhook delivery
  • calls to a cloud metadata endpoint
text
             Ingress
Client ─────────────────► MCP Server

             Egress
MCP Server ─────────────► External API

Ingress and egress must be controlled separately.

A server may require inbound access from one gateway but outbound access only to a database. Giving it unrestricted access in either direction increases the blast radius.


Default-Deny Networking

The safest starting point is default deny.

text
Initial Policy:
Deny All Ingress
Deny All Egress

Then add scoped exceptions narrowly:

text
Allow Ingress:
MCP Gateway → MCP Server:443

Allow Egress:
MCP Server → api.example.com:443
MCP Server → Approved DNS Resolver:53

This is safer than trying to enumerate every dangerous destination after unrestricted connectivity has already been granted.

Default-deny policies also make undocumented dependencies visible. When a server fails because it attempts an unexpected connection, operators can investigate instead of silently permitting the behavior.


Local MCP Servers and stdio

For local servers, stdio usually creates a narrower communication path than HTTP.

Under the standard MCP stdio transport:

text
MCP Client
    │
Launches Child Process
    │
    ├── stdin ─────► MCP Server
    └── stdout ◄─── MCP Server

The server does not need to expose a TCP port merely to communicate with the client.

The official MCP security guidance recommends stdio for local servers when appropriate because it limits access to the launching client.

Benefits of stdio

  • no listening TCP port
  • no exposure to other devices
  • no browser-origin attack surface
  • no HTTP routing configuration
  • process lifetime can be tied to the client
  • communication is associated with the launched child process

Important Limitation

stdio does not remove the server's own network access.

A local server using stdio can still make outbound connections unless the operating system, container, or sandbox blocks them.

text
MCP Client
    │
    ▼
stdio MCP Server
    │
    └────────► Internet

Therefore:

A non-network transport does not automatically create a network-isolated process.


Local HTTP Servers

Some local MCP deployments use Streamable HTTP rather than stdio.

The official transport specification requires servers to validate the Origin header on incoming HTTP connections, recommends binding local servers only to 127.0.0.1, and recommends authentication for all connections. These controls are intended to reduce DNS rebinding and unauthorized access risks.

A safe local listener looks like:

text
127.0.0.1:3000

An unnecessarily exposed listener may look like:

text
0.0.0.0:3000

The first accepts connections through the local loopback interface.

The second may accept connections through every available network interface, depending on host firewall and network configuration.


Why Binding to 0.0.0.0 Is Dangerous

Binding to 0.0.0.0 can expose the MCP endpoint to:

  • other devices on the local network
  • virtual machine networks
  • container bridge networks
  • VPN peers
  • cloud network interfaces
  • public interfaces when firewall rules permit it
text
Laptop
  ├── 127.0.0.1
  ├── Wi-Fi: 192.168.1.50
  ├── VPN: 10.20.0.15
  └── Container Bridge: 172.17.0.1

Server bound to 0.0.0.0
may listen on all interfaces.

A developer may believe the service is “local” because it runs on a local machine, even though the network listener is reachable by other systems.

Safer Default

Bind explicitly to:

text
127.0.0.1

or, where correctly supported:

text
::1

Remote access should require an intentional architecture with authentication, TLS, firewall rules, and an approved network path.


DNS Rebinding

DNS rebinding can allow a malicious website to interact with a service running on the victim's local machine.

A simplified attack looks like this:

text
User Visits Malicious Website
          │
          ▼
Attacker-Controlled Domain
Initially Resolves Externally
          │
          ▼
DNS Response Changes
Domain Resolves to 127.0.0.1
          │
          ▼
Browser Sends Requests
to Local MCP Server

A vulnerable local MCP server may accept requests because they arrive through the browser while lacking adequate origin validation and authentication.

The MCP transport specification, therefore, requires Origin validation for Streamable HTTP connections and recommends loopback-only binding for local servers.

Mitigations

  • validate Origin on incoming HTTP requests
  • reject absent or unexpected origins where policy requires it
  • return HTTP 403 for invalid origins
  • bind only to loopback
  • require authentication
  • avoid permissive CORS configuration
  • do not trust the Host header alone
  • use a Unix domain socket or restricted IPC where suitable

Unix Domain Sockets

A Unix domain socket can provide local interprocess communication without exposing a TCP listener.

text
MCP Client
     │
     ▼
/run/mcp/server.sock
     │
     ▼
MCP Server

Filesystem permissions can restrict which users and processes may open the socket.

Benefits include:

  • no TCP port
  • local-only communication
  • operating-system permission controls
  • reduced exposure to browser-based network attacks

The official MCP security guidance lists Unix domain sockets and other restricted IPC mechanisms as suitable options when local deployments do not use stdio.

Unix sockets do not protect outbound traffic from the server, so egress restrictions remain necessary.


Ingress Isolation for Remote MCP Servers

A remote MCP server should not normally be reachable directly from every network.

A layered deployment may use:

text
Internet
   │
   ▼
Load Balancer / API Gateway
   │
   ▼
Authentication and Rate Limits
   │
   ▼
Private MCP Server
   │
   ▼
Protected Resources

The MCP server itself can remain on a private network and accept traffic only from the approved gateway.

  • permit only the API gateway or reverse proxy
  • expose only the required port
  • require TLS
  • authenticate every connection
  • validate request origins where applicable
  • apply rate limits
  • restrict administrative endpoints
  • separate health checks from MCP operations
  • block direct access to backend instances
  • use private service discovery
  • log rejected connection attempts

Egress Isolation

Egress isolation controls where an MCP server can connect.

This is one of the most important controls for reducing:

  • data exfiltration
  • command-and-control traffic
  • SSRF
  • internal network reconnaissance
  • cloud credential theft
  • remote code downloads
  • malicious package behavior
text
MCP Server
    │
    ├── Approved CRM API ───── Allowed
    ├── Approved DNS ───────── Allowed
    ├── 169.254.169.254 ────── Blocked
    ├── 127.0.0.1 ──────────── Blocked
    ├── Private Subnets ─────── Blocked
    └── Unknown Internet Host ─ Blocked

OWASP recommends disabling network access for local MCP servers unless explicitly required and treating separate servers as independent security domains.


Servers That Need No Network Access

Some MCP servers operate entirely on local data.

Examples include:

  • local text transformations
  • deterministic calculations
  • parsing local files
  • searching an approved directory
  • generating static output

For these servers, outbound network access should be disabled.

text
Local File MCP Server

Allowed:
MCP stdio
/workspace/docs read-only

Blocked:
All TCP
All UDP
Internet
Private Networks
Cloud Metadata

This prevents a compromised server from exfiltrating local content over the network.

A filesystem server with no network access may still cause damage through local file operations, so filesystem permissions and sandboxing remain necessary.


Servers That Require External APIs

Some MCP servers legitimately need outbound access.

Examples include:

  • GitHub integrations
  • payment APIs
  • issue trackers
  • cloud platforms
  • email services
  • hosted databases

The policy should permit only the required destinations.

text
GitHub MCP Server

Allowed:
api.github.com:443
github.com:443
Approved DNS Resolver

Blocked:
All Other Destinations

Where possible, restrictions should include:

  • hostname or service identity
  • protocol
  • port
  • DNS resolver
  • certificate expectations
  • HTTP method
  • API path
  • request size
  • destination environment

IP-only allowlists may be difficult for large SaaS platforms whose addresses change. An authenticated egress proxy can enforce hostname and application-level policy more reliably.


Egress Proxies

An egress proxy acts as a controlled gateway for outbound connections.

text
MCP Server
    │
    ▼
Egress Proxy
    │
    ├── Validate Destination
    ├── Block Private IPs
    ├── Inspect Redirects
    ├── Log Requests
    ├── Apply Domain Policy
    └── Add Authentication
    │
    ▼
Approved External Service

The official MCP Security Best Practices recommend considering an egress proxy for server-side MCP clients, particularly when fetching OAuth-related URLs that could otherwise create SSRF exposure.

Benefits

  • centralized domain allowlists
  • blocking of private and reserved IP ranges
  • redirect validation
  • DNS policy enforcement
  • audit logging
  • bandwidth and response-size controls
  • prevention of direct Internet access
  • consistent policy across workloads

Limitations

An egress proxy must itself be securely configured.

A fully open proxy merely moves unrestricted access to another component.


Server-Side Request Forgery

SSRF occurs when an attacker causes an MCP component to request an unintended destination.

Potential input sources include:

  • tool arguments
  • resource URLs
  • OAuth metadata
  • Authorization Server discovery
  • redirect targets
  • webhooks
  • callback URLs
  • remote file imports
  • tool return values
text
Attacker-Controlled URL
         │
         ▼
MCP Client or Server
         │
         ▼
Internal Resource

Targets may include:

  • 127.0.0.1
  • ::1
  • private IPv4 subnets
  • private IPv6 ranges
  • link-local addresses
  • cloud metadata services
  • Kubernetes APIs
  • internal admin panels
  • databases
  • development services

The official MCP security guidance specifically warns that OAuth metadata fetching can expose server-side MCP clients to SSRF, including access to internal networks and cloud metadata endpoints.


Blocking Private and Reserved Networks

For components processing attacker-influenced URLs, the policy should normally reject connections to:

text
IPv4 private:
10.0.0.0/8
172.16.0.0/12
192.168.0.0/16

IPv4 loopback:
127.0.0.0/8

IPv4 link-local:
169.254.0.0/16

IPv6 loopback:
::1

IPv6 unique local:
fc00::/7

IPv6 link-local:
fe80::/10

Development exceptions should be explicit rather than silently permitted in production.

The MCP security guidance also warns against implementing IP parsing manually because unusual encodings and IPv4-mapped IPv6 representations can bypass naive checks.

Defense-in-Depth Controls

  • use a standards-compliant URL parser
  • resolve DNS before connecting
  • validate every resolved address
  • block private and reserved ranges
  • pin or preserve validated resolution where practical
  • validate the actual connection destination
  • apply the same checks after redirects
  • route traffic through a restrictive egress proxy
  • block dangerous ranges at the firewall layer

Redirect Validation

A public URL may redirect to an internal destination.

text
https://attacker.example/start
             │
             ▼
HTTP 302
Location: http://169.254.169.254/
             │
             ▼
Cloud Metadata Service

Validating only the initial URL is insufficient.

Every redirect hop should be treated as a new destination and rechecked.

Safer Redirect Handling

  • disable automatic redirects where practical
  • limit redirect count
  • parse the new URL independently
  • require approved schemes
  • resolve the new hostname
  • reject private and reserved IPs
  • prevent HTTPS-to-HTTP downgrade
  • block credential-bearing URLs
  • reject unexpected ports
  • do not forward sensitive headers across origins

DNS Rebinding and DNS TOCTOU

DNS validation introduces a time-of-check to time-of-use problem.

An attacker-controlled hostname may resolve to a public address during validation and to an internal address when the connection is established.

text
Validation:
evil.example → 203.0.113.20

Connection:
evil.example → 127.0.0.1

The official MCP guidance recommends considering DNS pinning and combining DNS checks with other network controls.

Mitigations

  • validate all resolved addresses
  • use the validated address for the connection where safe
  • recheck at connection time
  • reject responses containing both allowed and disallowed addresses
  • control DNS through an approved resolver
  • prevent arbitrary DNS-over-HTTPS bypass
  • combine application checks with firewall or proxy enforcement
  • revalidate after redirects

Cloud Metadata Isolation

Cloud metadata services may expose temporary credentials and workload information.

A frequently targeted IPv4 link-local address is:

text
169.254.169.254

Depending on the cloud platform and configuration, metadata may include:

  • temporary identity credentials
  • instance information
  • service account tokens
  • network details
  • startup data
  • configuration secrets

An MCP server should not be able to reach a metadata endpoint unless that access is explicitly required.

text
MCP Workload
      │
      ├── Approved API ───────── Allowed
      └── Metadata Service ───── Blocked

Network-level blocking should be combined with the cloud provider's metadata protections and workload identity mechanisms.


Multi-Server Isolation

An MCP host may connect to several servers simultaneously.

Each server should be treated as a separate security domain.

text
MCP Host
   │
   ├── Filesystem MCP
   ├── GitHub MCP
   ├── Payment MCP
   └── Production Cloud MCP

Placing all servers in one unrestricted network namespace allows compromise of a low-risk server to provide network access toward high-risk systems.

A safer structure isolates them:

text
Filesystem MCP
No Network

GitHub MCP
GitHub API Only

Payment MCP
Payment API Only

Cloud MCP
Approved Cloud APIs Only

OWASP recommends separating sensitive MCP servers from general-purpose servers and monitoring cross-server data flows.


Preventing Server-to-Server Reachability

MCP servers usually do not need direct network access to one another.

Blocking east-west traffic can prevent:

  • lateral movement
  • session probing
  • internal API discovery
  • data transfer between servers
  • exploitation of another server's local endpoint
  • bypass of host-level approval controls
text
Server A ─────X────► Server B
Server A ─────X────► Server C
Server B ─────X────► Server C

When cross-server workflows are required, they should preferably pass through a host, broker, or gateway that applies:

  • identity checks
  • authorization
  • data-flow policy
  • argument validation
  • audit logging
  • user approval

The official MCP client guidance recommends that sandboxed model-generated code have no direct network access and route external communication through a host broker that retains credentials and enforces access control.


Containers and Network Namespaces

Containers can place an MCP server inside a separate network namespace.

A network namespace gives the process its own:

  • network interfaces
  • routing table
  • firewall rules
  • listening ports
  • loopback interface
text
Host Network
    │
    ├── MCP Client
    │
    └── Container Namespace
            │
            └── MCP Server

This separation can prevent the MCP server from automatically seeing every service available on the host.

However, containerization is not the same as complete network isolation.

A container may still have access to:

  • the public Internet
  • other containers
  • internal bridge networks
  • host services
  • cloud metadata
  • mounted Unix sockets
  • container runtime APIs

The actual protection depends on how the container is configured.


Docker Network Isolation

Docker commonly connects containers to a bridge network that permits outbound traffic and communication with other containers on the same network.

A default deployment may look like:

text
MCP Container
      │
      ▼
Docker Bridge
      │
      ├── Internet
      ├── Other Containers
      └── Host Gateway

For a server that does not require network connectivity, Docker can run the container with networking disabled:

bash
docker run --network none example-mcp-server

The resulting container normally retains its internal loopback interface but receives no external network interface.

text
MCP Container
    │
    └── Loopback Only

No Internet
No LAN
No Container Network

This is appropriate for local MCP servers that operate entirely on mounted files or standard input and output.


Docker Network Modes

Docker provides several network modes with different security implications.

None

text
--network none

Provides the narrowest network boundary.

Use it when the server does not require external connectivity.

Bridge

text
--network bridge

Provides container networking through a Docker-managed bridge.

Outbound Internet access is commonly available unless separately restricted.

User-Defined Bridge

A dedicated user-defined bridge can isolate selected workloads from unrelated containers.

text
MCP Server
    │
Dedicated Network
    │
Approved Proxy

This is safer than connecting every container to one shared application network.

Host

text
--network host

The container shares the host's network namespace.

This removes much of the network separation normally provided by containers and may expose host-local services directly to the container.

Host networking should not be used merely for convenience.


Docker Egress Restrictions

Docker does not provide a simple high-level domain allowlist for container egress.

Restricting outbound access may require:

  • host firewall rules
  • an egress proxy
  • separate bridge networks
  • cloud firewall controls
  • container-aware security platforms
  • custom routing
  • DNS filtering

A strong design routes the MCP container through a controlled proxy:

text
MCP Container
      │
      ▼
Restricted Docker Network
      │
      ▼
Egress Proxy
      │
      ▼
Approved SaaS API

The container should not have a second unrestricted route that bypasses the proxy.


Avoid Exposing Docker and Container Runtime Sockets

Mounting a container runtime socket into an MCP container is extremely dangerous.

Example:

text
/var/run/docker.sock

A process with access to the Docker socket may be able to:

  • start privileged containers
  • mount host directories
  • inspect secrets
  • stop workloads
  • modify networks
  • execute commands in other containers
  • effectively gain host-level control
text
Compromised MCP Server
        │
        ▼
Docker Socket
        │
        ▼
Privileged Container
        │
        ▼
Host Filesystem

An MCP server should not receive access to the Docker socket unless container management is its explicit purpose and the deployment has strong compensating controls.

A safer architecture places a restricted broker between the server and the runtime API.


Container Port Publishing

A container may listen only inside its namespace until a port is published to the host.

Example:

bash
docker run -p 3000:3000 example-mcp-server

Depending on configuration, this may expose the service on every host interface.

A safer local-only binding is:

bash
docker run -p 127.0.0.1:3000:3000 example-mcp-server
text
Remote Device ─────X────► MCP Server

Local Host ─────────────► 127.0.0.1:3000

Even with loopback binding, the server should still use authentication and validate expected HTTP origins.


Kubernetes Network Isolation

Kubernetes workloads commonly share a flat cluster network.

Without network policy enforcement, a pod may be able to contact:

  • other pods
  • cluster services
  • databases
  • internal APIs
  • DNS
  • the public Internet
  • node-local services
  • cloud metadata endpoints
text
MCP Pod
   │
   ├── Namespace A
   ├── Namespace B
   ├── Internal Services
   ├── Internet
   └── Metadata

Kubernetes NetworkPolicy resources can restrict pod ingress and egress when the cluster uses a network plugin that supports and enforces them.

A policy existing in YAML does not provide protection if the network implementation ignores it.


Kubernetes Default-Deny Policy

A namespace can begin with a policy that selects all pods and allows no ingress or egress.

yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: default-deny-all
spec:
  podSelector: {}
  policyTypes:
    - Ingress
    - Egress

This creates the foundation for explicit allow policies.

text
Namespace
   │
   ├── Deny All Ingress
   └── Deny All Egress

Required connections can then be added individually.


Allowing Ingress from an MCP Gateway

A remote MCP server may accept traffic only from a gateway with a specific label.

yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-mcp-gateway
spec:
  podSelector:
    matchLabels:
      app: mcp-server
  policyTypes:
    - Ingress
  ingress:
    - from:
        - podSelector:
            matchLabels:
              app: mcp-gateway
      ports:
        - protocol: TCP
          port: 8080

Conceptually:

text
MCP Gateway ───────────► MCP Server

Other Pods ─────X──────► MCP Server

In larger clusters, namespace selectors and service identities may be needed to avoid trusting every pod that can apply a matching label.


Allowing DNS Egress

A default-deny egress policy may also block DNS.

If the MCP server needs hostname resolution, allow access only to the approved cluster DNS service.

yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-dns
spec:
  podSelector:
    matchLabels:
      app: mcp-server
  policyTypes:
    - Egress
  egress:
    - to:
        - namespaceSelector:
            matchLabels:
              kubernetes.io/metadata.name: kube-system
          podSelector:
            matchLabels:
              k8s-app: kube-dns
      ports:
        - protocol: UDP
          port: 53
        - protocol: TCP
          port: 53

Labels vary between Kubernetes distributions, so the actual DNS workload must be verified.

Allowing DNS does not automatically permit access to the resolved destination. A separate rule is still required for the outbound connection.


Kubernetes Egress Allowlisting

Standard Kubernetes NetworkPolicy is primarily based on:

  • pod selectors
  • namespace selectors
  • IP blocks
  • protocols
  • ports

It does not universally provide hostname-based policy.

That creates challenges for SaaS APIs whose IP ranges change.

Possible solutions include:

  • an egress gateway
  • a service mesh
  • an authenticated HTTP proxy
  • a network plugin with DNS-aware policies
  • provider-managed firewall controls
  • fixed private endpoints
text
MCP Pod
   │
   ▼
Egress Gateway
   │
   ├── api.github.com ─ Allowed
   └── Other Domains ─ Blocked

The MCP pod should not have a route that lets it bypass the gateway.


Namespace Isolation Is Not Enough

Kubernetes namespaces provide organizational separation, but they do not automatically block network traffic between workloads.

text
Namespace: low-risk-tools
       │
       └────────► Namespace: production-tools

NetworkPolicies or equivalent controls are still required.

Sensitive MCP servers should be isolated by:

  • namespace
  • service account
  • network policy
  • secrets
  • workload identity
  • node policy where appropriate
  • runtime security controls

No single Kubernetes object should be treated as the complete security boundary.


Service Meshes

A service mesh can provide workload-aware network controls between MCP components.

Potential capabilities include:

  • mutual TLS
  • service identity
  • authorization policies
  • traffic logging
  • egress gateways
  • destination restrictions
  • certificate rotation
  • retry and timeout policies
text
MCP Gateway
    │
   mTLS
    │
    ▼
MCP Server
    │
Egress Gateway
    │
    ▼
Approved API

A service mesh may allow policy based on authenticated workload identity rather than source IP alone.

Example policy concept:

text
Allow:
identity = mcp-gateway
destination = documentation-mcp
method = POST
path = /mcp

Limitations

A service mesh does not automatically:

  • validate MCP tool arguments
  • prevent prompt injection
  • detect malicious server code
  • enforce OAuth scopes
  • protect local filesystem access
  • verify that a requested external URL is safe

It strengthens transport and network policy but does not replace application controls.


Mutual TLS Between MCP Services

Mutual TLS allows both sides of a connection to authenticate using certificates.

text
MCP Gateway
Certificate A
     │
     │ Encrypted and Mutually Authenticated
     ▼
MCP Server
Certificate B

mTLS can prevent unauthorized workloads from directly connecting to an internal MCP server.

It is particularly useful for:

  • service-to-service communication
  • internal gateways
  • multi-cluster communication
  • zero-trust environments
  • private MCP deployments

Certificates should be:

  • short-lived
  • automatically rotated
  • tied to workload identity
  • scoped to the intended service
  • revocable

mTLS proves workload identity at the transport layer. The server must still perform user-level authorization where user identity matters.


OAuth Endpoint Isolation

Remote MCP deployments may communicate with:

  • Protected Resource Metadata endpoints
  • Authorization Server Metadata endpoints
  • authorization endpoints
  • token endpoints
  • registration endpoints
  • introspection endpoints
  • revocation endpoints

These connections should be restricted to trusted authorization infrastructure.

text
MCP Client Backend
       │
       ├── auth.example.com ─ Allowed
       ├── login.example.com ─ Allowed
       └── Arbitrary Metadata Host ─ Blocked

A malicious MCP server may attempt to direct a client toward an attacker-controlled or internal OAuth endpoint.

Network policy should complement metadata validation.

  • maintain an allowlist of approved Authorization Servers
  • require HTTPS
  • validate metadata issuer relationships
  • restrict redirect destinations
  • use an SSRF-resistant HTTP client
  • block internal and metadata address ranges
  • route discovery through an egress proxy
  • alert when authorization domains change
  • separate OAuth traffic from general tool traffic where practical

Reverse Proxies and API Gateways

A reverse proxy or API gateway can form the controlled ingress point for a remote MCP service.

text
Client
  │
  ▼
API Gateway
  │
  ├── TLS Termination
  ├── Authentication
  ├── Rate Limits
  ├── Request Size Limits
  ├── Access Logging
  └── Routing
  │
  ▼
Private MCP Server

Useful controls include:

  • maximum request body size
  • connection timeouts
  • idle timeouts
  • request rate limits
  • concurrent connection limits
  • header validation
  • path restrictions
  • TLS policy
  • IP restrictions
  • protection against malformed HTTP traffic

The gateway should preserve sufficient authenticated identity information for the MCP server to make authorization decisions.


Do Not Trust Proxy Headers from Arbitrary Sources

Applications behind a proxy may rely on headers such as:

text
X-Forwarded-For
X-Forwarded-Proto
X-Forwarded-Host
Forwarded

These headers can be forged by a direct client unless the backend accepts traffic only from trusted proxies and overwrites untrusted values.

text
Attacker
   │
Forged X-Forwarded-For
   │
   ▼
Direct Backend Access
   │
   ▼
Incorrect Trust Decision

Mitigations

  • block direct access to backend instances
  • trust proxy headers only from approved proxies
  • configure the proxy to replace incoming forwarding headers
  • avoid using client IP as the sole authentication control
  • validate expected host and scheme values
  • log both proxy and authenticated identity information

Host Firewalls

A host firewall can restrict connections available to a local or containerized MCP server.

Potential controls include:

  • block inbound access to local MCP ports
  • restrict outbound traffic by process, user, container, port, or destination
  • block private network access
  • block cloud metadata addresses
  • prevent access to developer services
  • isolate production and development networks
text
MCP Process
    │
Host Firewall
    │
    ├── Approved API ─ Allowed
    └── Everything Else ─ Blocked

Host firewalls are valuable because they operate below the MCP application.

However, their effectiveness depends on:

  • rule correctness
  • operating-system support
  • administrative privileges
  • process attribution
  • IPv4 and IPv6 coverage
  • container routing behavior

Rules must cover both IPv4 and IPv6 where both are enabled.


Localhost Is a Network Boundary Too

Developers often treat localhost as automatically trusted.

A compromised MCP server may find services such as:

  • development databases
  • local administration panels
  • debugging ports
  • browser automation endpoints
  • container APIs
  • build services
  • local model servers
  • credential agents
text
Compromised MCP Server
       │
       ▼
127.0.0.1
       │
       ├── Database
       ├── Debugger
       ├── Admin UI
       └── Internal Agent

When the MCP server does not need localhost access, it should be blocked.

For containers, remember that the container's own loopback differs from the host's loopback, but host gateway routes and shared network modes may still expose host services.


Protecting Internal Databases

An MCP server that queries a database should not receive general access to the entire database network.

A safer design uses:

  • a dedicated database account
  • a specific database endpoint
  • a narrow port
  • read-only permissions where possible
  • row-level or tenant-level restrictions
  • network policy
  • query timeouts
text
MCP Server
    │
    ▼
Read-Only Database Endpoint
    │
    ▼
Approved Schema / Rows

Network access alone must not determine database authorization.

If the server is compromised, database credentials and server-side permissions become the next boundary.


Private Endpoints

Cloud providers often support private endpoints for managed services.

Instead of sending traffic across the public Internet:

text
MCP Server
    │
Public Internet
    │
    ▼
Cloud Database

the workload may connect through a private network path:

text
MCP Server
    │
Private Network
    │
    ▼
Private Service Endpoint

Benefits may include:

  • no public service exposure
  • tighter routing
  • firewall integration
  • reduced Internet dependency
  • improved traffic visibility

Private connectivity does not remove the need for authentication, encryption, or least-privilege credentials.


Zero-Trust Segmentation

Zero-trust networking assumes that network location alone is not sufficient evidence of trust.

Every connection should be evaluated using context such as:

  • workload identity
  • user identity
  • destination
  • requested action
  • environment
  • device posture
  • risk
  • authorization policy
text
Request
  │
  ▼
Identity Verification
  │
  ▼
Policy Evaluation
  │
  ▼
Short-Lived Authorized Connection

For MCP deployments, this means:

  • do not trust a server because it is inside the corporate network
  • do not trust a client because it uses a private IP
  • authenticate service-to-service connections
  • authorize each protected operation
  • minimize persistent network access
  • continuously verify policy

Development and Production Separation

Development MCP servers often require broad access for testing.

That access should not carry into production.

text
Development MCP
   │
   ├── Test APIs
   ├── Local Database
   └── Sandbox Credentials

Production MCP
   │
   ├── Production API
   └── Restricted Workload Identity

Avoid configurations where:

  • development servers can reach production databases
  • test credentials work in production
  • local tools use production VPN routes
  • staging and production share one network namespace
  • broad developer tokens are mounted into production workloads

Use separate:

  • accounts
  • networks
  • credentials
  • DNS zones
  • policies
  • logging
  • approval processes

Tenant Network Isolation

Multi-tenant MCP platforms must ensure that one tenant cannot use the platform as a path into another tenant's resources.

Potential risks include:

  • shared outbound proxies without identity
  • tenant-controlled URLs
  • shared credentials
  • overlapping private address spaces
  • shared sessions
  • incorrectly keyed network policies
text
Tenant A MCP Session
       │
       └────X────► Tenant B Private Resource

Mitigations

  • bind every network request to a verified tenant identity
  • use tenant-specific credentials
  • partition proxies and connection pools
  • prevent tenant-controlled routing changes
  • isolate private network connectors
  • apply per-tenant allowlists
  • separate logs and audit trails
  • test cross-tenant access attempts
  • avoid trusting tenant IDs supplied only as tool parameters

Model-Generated Code and Network Access

Some MCP clients allow models to generate or execute code.

Generated code should not receive direct network access by default.

A safer design uses a broker:

text
Generated Code Sandbox
        │
        ▼
Restricted Host Broker
        │
        ├── Validate Destination
        ├── Apply Credentials
        ├── Enforce Scope
        ├── Limit Data
        └── Log Request
        │
        ▼
Approved External Service

The broker retains secrets and decides whether the requested operation is allowed.

This prevents generated code from:

  • scanning the internal network
  • reading service credentials
  • sending arbitrary data externally
  • bypassing user approval
  • contacting unapproved APIs

Preventing Covert Egress Channels

Blocking ordinary HTTP traffic may not eliminate every exfiltration path.

Possible channels include:

  • DNS queries
  • ICMP
  • alternate ports
  • WebSockets
  • encrypted tunnels
  • proxy environment variables
  • cloud logging APIs
  • error-reporting services
  • package registries
text
Blocked HTTPS
     │
     ▼
Malicious Server Uses DNS Queries
to Encode Sensitive Data

Mitigations

  • force DNS through an approved resolver
  • block direct external DNS
  • restrict protocols and ports
  • deny arbitrary proxy configuration
  • monitor unusual query volume and labels
  • block unauthorized tunneling protocols
  • restrict access to telemetry endpoints
  • inspect destination behavior where legally and operationally appropriate

Network controls should be based on required functionality, not only on common attack ports.


Network Monitoring

Monitoring helps identify behavior that policy did not prevent.

Useful telemetry includes:

  • destination hostname
  • destination IP
  • port
  • protocol
  • connection duration
  • bytes sent and received
  • DNS queries
  • denied connection attempts
  • process or workload identity
  • tenant
  • MCP server identity
  • tool correlated with the request
text
Tool Call
   │
Correlation ID
   │
   ▼
Network Connection Log

Correlating tool activity with network traffic makes it easier to answer:

  • Which tool caused the connection?
  • Which user initiated the workflow?
  • What data may have been sent?
  • Was the destination approved?
  • Was this behavior new for the server?

Avoid logging secrets, tokens, or complete sensitive payloads.


Network Baselines

A stable MCP server often has a predictable communication pattern.

Example:

text
Normal GitHub MCP:
- api.github.com:443
- github.com:443
- approved DNS

Unexpected:
- random-domain.example:443
- 10.0.0.5:22
- 169.254.169.254:80

Baseline monitoring can alert on:

  • new destinations
  • new ports
  • unusual data volume
  • private network access
  • repeated denied connections
  • unexpected DNS patterns
  • traffic outside normal execution hours
  • connections unrelated to tool calls

A new destination is not automatically malicious, but it should be explained and approved.


Network Policy Testing

A policy should be tested rather than assumed to work.

Useful tests include:

  • can the server reach the Internet?
  • can it reach private IPv4 ranges?
  • can it reach private IPv6 ranges?
  • can it access cloud metadata?
  • can it contact other MCP servers?
  • can it resolve through an unauthorized DNS server?
  • can it bypass the egress proxy?
  • can redirects reach blocked destinations?
  • does direct backend ingress remain blocked?
  • does the policy survive workload restart?

Automated tests can run during deployment to verify expected connectivity.

text
Expected Allowed:
Approved API → Success

Expected Blocked:
Metadata → Failure
Private Network → Failure
Unknown Internet → Failure

Handling Policy Failures

Network restrictions can reveal hidden dependencies.

A server may fail because it attempts to contact:

  • telemetry services
  • update servers
  • package registries
  • analytics endpoints
  • undocumented APIs
  • remote configuration services

Do not automatically allow every failed destination.

Investigate:

  1. Is the connection required?
  2. Is it documented?
  3. What data is sent?
  4. Who operates the destination?
  5. Can the feature work without it?
  6. Can the destination be proxied?
  7. Should the server be rejected?

A denied connection is often useful security information.


Incident Response for Network Abuse

When suspicious MCP network activity is detected, respond quickly.

1. Contain

  • stop or isolate the server
  • block outbound access
  • disable related credentials
  • remove the server from approved configurations
  • terminate active sessions
  • block observed destinations

2. Preserve Evidence

Collect:

  • process information
  • container image digest
  • package version
  • configuration
  • network flow logs
  • DNS logs
  • proxy logs
  • tool invocation history
  • authentication records
  • relevant filesystem state

3. Determine Exposure

Identify:

  • which destinations were contacted
  • what data may have been sent
  • which credentials were accessible
  • which internal services were reachable
  • whether cloud metadata was accessed
  • whether lateral movement occurred
  • which users and tenants were affected

4. Rotate Credentials

Rotate credentials available to the workload, including:

  • OAuth Refresh Tokens
  • API keys
  • database credentials
  • cloud workload credentials
  • source-control tokens
  • proxy credentials

5. Recover

  • deploy a verified server version
  • tighten network policy
  • remove unnecessary routes
  • restrict secrets
  • test the revised policy
  • monitor for recurring activity
  • document the root cause

MCP Network Isolation Checklist

Local Transport

  • Can the server use stdio instead of HTTP?
  • If HTTP is required, is it bound only to loopback?
  • Is the Origin header validated?
  • Is authentication required?
  • Is the port exposed beyond the host?
  • Could a browser reach the endpoint?
  • Can a Unix domain socket be used?

Ingress

  • Is ingress denied by default?
  • Which component is allowed to connect?
  • Is the backend reachable only through a trusted gateway?
  • Is TLS enforced?
  • Are administrative endpoints separated?
  • Are connection and request limits configured?
  • Are proxy headers trusted only from approved proxies?

Egress

  • Is egress denied by default?
  • Does the server need Internet access?
  • Are approved destinations documented?
  • Are ports and protocols restricted?
  • Is an egress proxy used?
  • Can the server bypass the proxy?
  • Are private and reserved networks blocked?
  • Is cloud metadata blocked?

DNS

  • Is DNS routed through an approved resolver?
  • Can the workload use an arbitrary external DNS?
  • Are DNS responses validated for SSRF-sensitive requests?
  • Is DNS rebinding considered?
  • Are unusual DNS queries monitored?
  • Are IPv4 and IPv6 both covered?

Containers

  • Is the server placed in its own network namespace?
  • Can --network none be used?
  • Is host networking disabled?
  • Are published ports bound only where required?
  • Is the Docker socket unavailable?
  • Are unrelated containers on separate networks?
  • Are runtime privileges minimized?

Kubernetes

  • Does the cluster network plugin enforce NetworkPolicy?
  • Is there a default-deny policy?
  • Is DNS explicitly allowed?
  • Is ingress limited to the MCP gateway?
  • Is egress routed through a controlled gateway?
  • Are namespaces treated as organizational rather than automatic network boundaries?
  • Can the pod reach node or metadata services?

Service Identity

  • Are service-to-service connections authenticated?
  • Is mTLS used where appropriate?
  • Are certificates short-lived?
  • Does the server perform user-level authorization separately?
  • Are network permissions based on verified workload identity?

SSRF

  • Are URLs parsed with a trusted library?
  • Are private, loopback, link-local, and reserved ranges rejected?
  • Are all resolved addresses checked?
  • Are redirects revalidated?
  • Is DNS rebinding mitigated?
  • Are unusual IP representations handled correctly?
  • Are metadata endpoints blocked at the network layer?

Multi-Server Isolation

  • Can one MCP server directly contact another?
  • Are high-risk servers on separate networks?
  • Are server-specific egress policies applied?
  • Are cross-server workflows routed through a broker?
  • Is data provenance retained across server boundaries?
  • Are credentials isolated per server?

Monitoring

  • Are connection and DNS logs collected?
  • Can network traffic be correlated with tool calls?
  • Are new destinations alerted?
  • Are denied connections visible?
  • Are unusual data volumes detected?
  • Are logs protected from tampering?
  • Are secrets excluded from logs?

Incident Response

  • Can a server's network access be disabled immediately?
  • Can credentials be revoked?
  • Are package versions and image digests inventoried?
  • Are network logs retained long enough for investigation?
  • Can affected workloads be isolated without relying on the server?
  • Are known-good policies and artifacts available?

A mature deployment may use the following layered model:

text
User
  │
  ▼
MCP Client
  │
Authenticated Connection
  │
  ▼
API Gateway
  │
Ingress Policy
  │
  ▼
Private MCP Server
  │
Workload Identity
  │
  ▼
Default-Deny Network
  │
  ▼
Egress Proxy
  │
Destination Allowlist
  │
  ▼
Approved External API

For a local MCP server:

text
MCP Client
   │
stdio
   │
   ▼
Sandboxed MCP Process
   │
Read-Only Approved Files
   │
   └── No Network

For a server that requires one API:

text
MCP Client
   │
   ▼
Sandboxed MCP Server
   │
   ▼
Egress Proxy
   │
   └── Approved API Only

Each layer reduces the impact of failure in another layer.


Common Network Isolation Mistakes

Assuming stdio Disables Networking

It does not. The process can still initiate outbound connections unless restricted separately.

Binding a Local Server to All Interfaces

A locally running service may become reachable from LAN, VPN, container, or cloud networks.

Allowing All Egress for Convenience

Unrestricted egress enables data exfiltration and command-and-control traffic.

Trusting Kubernetes Namespaces Alone

Namespaces do not inherently block network traffic.

Using a Shared Container Network for Every Server

A compromise can lead to lateral movement between unrelated tools.

Validating Only the First URL

Redirects may lead to localhost, private networks, or metadata endpoints.

Blocking Only IPv4

Attackers may reach equivalent destinations through IPv6.

Trusting DNS Names Without Checking Resolved Addresses

A hostname may resolve to a private or loopback address.

Giving Generated Code Direct Internet Access

Model-generated code may bypass tool-level controls and send data arbitrarily.

Treating Private Networks as Trusted

Internal services may lack strong authentication because they assume network isolation.


Conclusion

MCP network isolation reduces the number of systems a client, server, tool, or generated process can reach.

The strongest approach begins with:

  • no exposed local network listener unless required
  • loopback-only binding for local HTTP
  • stdio or restricted IPC for local communication
  • default-deny ingress
  • default-deny egress
  • explicit destination allowlists
  • blocked private and metadata networks
  • isolated servers and network namespaces
  • controlled DNS
  • SSRF-resistant URL handling
  • authenticated gateways and proxies
  • continuous network monitoring

Network isolation does not replace OAuth, tool authorization, input validation, sandboxing, or user approval.

It provides a lower-level boundary that remains effective when higher-level controls fail.

The central principle is:

An MCP server should be able to communicate only with the exact systems required for its approved purpose—and nothing else by default.

Continue learning:

Frequently Asked Questions

What is MCP network isolation?

MCP network isolation limits which clients, servers, internal systems, and external destinations an MCP component can communicate with, reducing the impact of malicious servers, prompt injection, SSRF, and credential theft.

Should a local MCP server bind to 0.0.0.0?

No. A local HTTP-based MCP server should normally bind only to a loopback address such as 127.0.0.1 or ::1 unless remote access is explicitly required and protected.

Is stdio safer than HTTP for a local MCP server?

Stdio usually provides a narrower communication boundary because the client launches the server and communicates through its standard input and output rather than exposing a network listener.

Should an MCP server have Internet access?

Only when its required functionality depends on external services. Servers that do not need outbound connectivity should run with network access disabled.

What is egress filtering for MCP?

Egress filtering restricts the external hosts, protocols, ports, and IP ranges that an MCP server may contact.

How does network isolation reduce SSRF risk?

Even if an attacker controls a URL passed to an MCP component, network policies can prevent the component from reaching localhost, private networks, cloud metadata endpoints, or unauthorized external destinations.

Can network isolation stop prompt injection?

It cannot prevent the model from being manipulated, but it can prevent a manipulated tool or server from reaching systems and destinations outside its approved network boundary.

Should different MCP servers share one network namespace?

Sensitive servers should preferably be isolated from unrelated servers so that compromise of one server does not provide direct network access to another.

Are Kubernetes NetworkPolicies sufficient by themselves?

No. They require a compatible network plugin and must be combined with authentication, authorization, workload hardening, DNS controls, secret isolation, and application-level validation.

What is the safest default network policy for an MCP server?

Deny inbound and outbound network traffic by default, then allow only the exact connections required for the server's documented functionality.

Check your MCP security posture

Generate a Security Score, detect risky tools, and review permissions before exposing APIs to AI agents.