The Simplest Way to Make Istio and Tcp Proxies Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Running istio and tcp proxies together lets teams route and lock down raw network traffic. This setup checks service keys, encrypts data in flight, and directs packets to the right apps. Many backend databases and message queues do not speak HTTP. They use raw TCP streams to send and receive data. A service mesh handles web traffic well, but raw streams need clear port rules. Pairing mesh sidecars with dedicated TCP listeners solves this routing problem for engineering teams. How istio and tc

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Running istio and tcp proxies together lets teams route and lock down raw network traffic. This setup checks service keys, encrypts data in flight, and directs packets to the right apps.

Many backend databases and message queues do not speak HTTP. They use raw TCP streams to send and receive data. A service mesh handles web traffic well, but raw streams need clear port rules. Pairing mesh sidecars with dedicated TCP listeners solves this routing problem for engineering teams.

How istio and tcp proxies route data and check keys

In a cluster, each app pod runs a sidecar container next to the main process. The mesh control plane sends routing rules and TLS keys to every sidecar. When an app opens a raw connection, the local sidecar catches those packets first.

The sidecar wraps the raw TCP stream in mutual TLS before sending it out. It checks the workload identity tied to the client service account. Then it forwards the encrypted stream to the target TCP listener on the receiving end.

The receiving listener unwraps the TLS layer and checks the sender role against mesh policies. If the policy allows the role, the listener passes the raw packets to the database. If the role fails the check, the listener drops the connection right away.

Teams must name every port in their service definitions so the mesh knows the protocol. Without clear port names, the sidecar treats the stream as plain bytes and skips policy checks. Clear port rules tell the mesh to use TCP routing logic from start to finish.

Common failure modes and how to scope network paths

A common mistake is using one shared service account across many backend apps. If ten apps share one identity, the TCP listener cannot tell which app sent the traffic. Any app in that group can reach the database, even if it has no need.

End-to-End Encryption + Istio Authorization Policies: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Broad network rules cause another big risk for production clusters. By default, every sidecar holds a full map of all services in the cluster. This lets a compromised pod open a raw TCP path to any internal port.

Unlogged raw streams also leave blind spots during security audits. A basic TCP listener only logs the source IP, byte count, and connection time. It cannot read the database queries or commands inside the raw byte stream. If teams share static database passwords, the logs never show which person ran a bad query.

To fix this, give each app its own service account and unique mesh identity. Set up strict export rules so services only see the ports they actually need. Use network policies to block traffic that tries to bypass the sidecar container.

Keeping connection timeouts and health checks in sync

Raw TCP connections often keeps the session active for hours or days between backend services. If the mesh sidecar and the TCP listener have different idle timeouts, connections drop without warning. The client app tries to send data on a dead socket and throws an error.

Platform teams should align keepalive timers across the app, the sidecar, and the downstream listener. Set the app keepalive shorter than the network idle limit so the path stays warm. Also, check that health probes use a separate port with clear access rules. This stops health checks from filling up your connection logs with noise.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Why does my raw TCP traffic bypass mesh policy rules?

This usually happens when the service port lacks a clear protocol prefix in its name. Give the port a clear TCP name so the sidecar applies the right routing rules.

How do we stop pods from talking to every TCP port in the cluster?

Write a default deny rule for the namespace and add allow rules for specific service accounts. You can also limit sidecar scope so pods only load routes for approved backend targets.

Can a mesh sidecar see the queries inside a raw database stream?

No, a standard TCP listener only sees raw bytes, IP addresses, and port numbers. To read queries or mask fields like emails and card numbers, you need protocol-aware inspection.

The query runs. The emails stay hidden.