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

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use cosmosdb and tcp proxies to route database traffic through fixed network paths. This setup lets apps and engineers query private cloud databases from outside the virtual network. Cloud databases often sit inside locked private networks to block outside threats. Developers still need a safe way to read and write data during daily work. A network forwarder bridges that gap by passing raw packets between the client and the database. How cosmosdb and tcp proxies move traffic and check k

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.

Teams use cosmosdb and tcp proxies to route database traffic through fixed network paths. This setup lets apps and engineers query private cloud databases from outside the virtual network.

Cloud databases often sit inside locked private networks to block outside threats. Developers still need a safe way to read and write data during daily work. A network forwarder bridges that gap by passing raw packets between the client and the database.

How cosmosdb and tcp proxies move traffic and check keys

A transport forwarder operates at layer four of the network stack. It takes incoming packets from a client tool and sends them to the database endpoint. The forwarder does not read the database queries inside those packets.

Because the forwarder works at the transport layer, the client handles the login step. The engineer or app must hold the database master key or role token on their machine. The client starts a TLS handshake that passes straight through the forwarder to the cloud endpoint.

The database checks the key or identity token once the TLS link opens. If the check passes, the database sends query results back through the same network path. The client SDK also needs the right connection mode to work with a fixed port.

Many cloud database drivers try to talk to dozens of backend storage nodes at once. That direct mode fails when traffic must pass through one narrow port. Teams set their client drivers to gateway mode so traffic stays on known ports.

Common failure modes and how to scope roles and network paths

Passing raw packets solves the network routing problem, but it leaves big gaps in control. Since the forwarder only sees bytes, it cannot log which person ran a specific query. Every request looks like it came from the internal IP address of the forwarder.

Teams often share one read-write master key across the whole group to save time. When a bad query deletes records, the database logs only show the shared key. Nobody knows which user or script sent the command.

CosmosDB RBAC + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Broad network rules also create risk when anyone on the VPN can reach the open port. If an attacker gets onto a laptop, they can use the local key to dump records. Transport forwarders cannot mask sensitive fields like emails, phone numbers, or card numbers in results.

To lower these risks, teams must lock down both the network path and the database roles. First, turn off public network endpoints on the database account and use private endpoints. Only allow the forwarder subnet to send packets to the private database IP address.

Next, stop sharing master keys among engineers and scripts. Set up role-based access in your cloud identity provider with narrow permissions for each task. Give human users read-only roles by default and keep write roles for approved tasks.

Routing different database APIs over private networks

This cloud database supports several wire APIs, including document, key-value, and graph formats. Each API uses specific ports and wire protocols when clients send queries over the network. Your network routing setup must match the wire protocol that your app uses.

For example, the document API can send traffic over standard HTTPS ports in gateway mode. Wire protocols for document or table compatibility use their own dedicated port ranges instead. Make sure your firewall rules only open the exact ports needed for your chosen API.

Keep health checks active on your routing nodes to spot dropped links early. Long-lived database sessions can stall when network firewalls drop idle sockets without warning. Setting short keep-alive timers on the transport node stops silent timeouts during long reads.

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 do direct client connections fail through a transport forwarder?

Direct mode tries to open dynamic ports to many backend storage partitions at once. A standard port forwarder only listens on a fixed set of ports. Switching the client to gateway mode routes traffic through a single known port.

Can a basic layer four forwarder record individual database queries?

No, a layer four forwarder only moves raw encrypted packets between two IP addresses. It cannot read TLS traffic or parse the database wire protocol to log queries. You need a system that understands the database protocol to log queries by user.

How should teams protect sensitive fields in document query results?

Basic port forwarders pass every record intact without checking the payload. To protect sensitive values, use data masking that rewrites matched fields in results. This replaces emails, phone numbers, or national IDs before the payload reaches the client.

The query runs. The emails stay hidden.