DataSunrise Sponsors AWS re:Invent 2026. Learn more →

Database Security Runs Deeper

Executive summary

Connecting to a database to read its catalog is a well-understood integration problem. Operating a security control in the live path of production traffic is a different one. That control has to understand each database’s wire protocol and SQL dialect. It must change results without confusing client drivers and identify the real user behind a shared account. It also needs to follow clients through redirects and failover, with a small, predictable delay. This article explains those challenges so engineering leaders can estimate what building such a control point involves. It also shows why years of production edge cases matter more than any single feature.

A metadata connector reads. A control point carries traffic.

A typical metadata connector authenticates to a database, reads system catalogs or samples a few tables, and sends the results to a platform on its own schedule. It is a client like any other. If it fails, a scan runs late and someone retries it. The application’s requests do not pass through the connector.

A control point in the data path is a different kind of component. For traffic routed through the control, it processes requests before they reach the database and responses before they return to the client. Misreading a message can return an error to the application. A stalled control slows the application down. An incorrect change to a result can affect a report, a payment or a customer screen. The standard moves from “able to read the database” to “preserving expected application behavior unless a policy says otherwise.” The two are complementary: discovery supplies sensitive-data context, while a runtime control applies configured policies to requests routed through it.

That is the layer where the decisions described in Seeing Is Not Stopping take effect: rejecting a query, masking values in a live result, or recording exactly what happened. Making those decisions is the visible part. The engineering underneath is less visible, and it is the subject of this article.

Database security iceberg: metadata above the surface; protocols, masking, identity, redirects, latency and deployment modes below it.
What a metadata connector covers, and what sits below the surface.

Every database speaks its own language

The first difficulty is the most basic one. Each database has its own wire protocol, the binary conversation between a client driver and the server, and its own SQL dialect.

Protocols differ in how they frame messages, authenticate, prepare statements, send batches, stream large results and report errors. The PostgreSQL frontend/backend protocol and Microsoft’s Tabular Data Stream (TDS) protocol both have published specifications, but they are not variations of one design. Documentation for other protocols is less complete, and details can change between versions. A control point has to follow each conversation exactly, including the parts an ordinary application rarely exercises.

SQL dialects and dynamic SQL

Dialects add a second layer. Identifier quoting, procedural extensions, vendor-specific functions and the way a statement refers to an object all vary. Consider a policy that says “record every read of the customer table.” The control must recognize that table through aliases, schema-qualified names, views and stored procedures. It must also recognize it in SQL generated inside the database at runtime. That dynamic SQL can present a visibility challenge because the client request may not contain the SQL ultimately executed. DataSunrise can audit, mask and block dynamic SQL for PostgreSQL, MySQL, SQL Server and MariaDB. This requires enabling dynamic SQL processing and configuring its handler and rules.

Correct parsing is the foundation for everything else in this article. Masking, blocking and attribution all depend on knowing what a request does. DataSunrise supports databases such as Oracle, SQL Server, PostgreSQL and IBM Db2, including z/OS and IBM i, as well as cloud data warehouses, file storage and AI services. Each additional source brings another set of protocols, dialects and client behaviors to support; the available controls vary by source.

A customer requirement for MongoDB involved clients authenticating with X.509 certificates rather than passwords. The proxy needed to handle two separate TLS connections: one from the client and another to MongoDB. DataSunrise added certificate-based authentication mapping, using the client’s certificate subject to select the certificate and private key for the database connection. Certificate-authenticated clients could then connect through the proxy, with their sessions and database activity recorded in the audit trail.

Changing results without breaking clients

Recording traffic is demanding. Changing it is harder. Dynamic masking replaces sensitive values in a live result before they reach the client, even though the client does not expect the change.

Client drivers interpret results using metadata the server sends first. In PostgreSQL, the RowDescription message gives each column a data type, a data type size and a type modifier, and every value that follows carries its own length. In TDS, the COLMETADATA token is used, in Microsoft’s words, “to tell the client the data type and length of the column data.” Drivers, ORMs and reporting tools rely on that contract.

A masked value therefore has to remain a valid value of the promised type. A date replaced with a string of asterisks can make a driver throw an error. A value longer than the declared size can be truncated or rejected. NULL handling, character encoding and numeric precision all have to stay consistent. Some applications also cache metadata or validate results against their own schema, so a change that is technically valid can still surprise them.

There is also the question of what the masked result is used for. A masked value may be fine on a screen and wrong in a calculation, an export or a join performed later by the application. Those are decisions for the policy owner, but the control point has to carry out each of them without corrupting the data stream. DataSunrise dynamic masking changes configured values in live results, keeps the stored originals unchanged and returns results that applications can still use.

In one customer environment, dynamic masking needed to work alongside SQL Server’s Always Encrypted with secure enclaves. DataSunrise updated its query handling to preserve the enclave information when rewriting requests for masking, allowing masked queries to execute without breaking the connection.

Who is really asking

Databases authenticate connections, not people. Most business applications connect with a small number of service accounts, and connection pools reuse each session for many end users. From the database’s point of view, thousands of employees may all be the same login.

The application knows the real user and has to pass that knowledge on. Microsoft’s row-level security documentation describes the pattern for a middle-tier application. After opening a connection, the application sets the current application user ID in session context. It can mark the value read-only to keep it unchanged until it closes the connection and returns it to the pool. Other platforms and applications use other conventions, and many legacy applications use none at all.

To attribute activity correctly, a control point must find that identity wherever the application exposes it. It must keep the identity attached to the right requests as the application reuses sessions. A mistake in either direction is costly. Attributing a query to the wrong person undermines an investigation, and a policy keyed to a user that the control cannot see simply never applies. DataSunrise’s application-user attribution links activity to the real end user behind a shared database account, using the identity the application passes on.

Redirects, failover and clusters

A client does not always stay connected to the address it first dialed. Modern high-availability and cloud databases move connections deliberately.

In SQL Server Always On availability groups, read-only routing sends read-intent connection requests that arrive at the listener to a readable secondary replica. In Azure SQL Database, the Redirect connection policy first connects the client through a gateway and then redirects the session to the database cluster. From then on, all packets bypass the gateway and travel on a different port range. Oracle Net supports listener redirects, which send a client to a new listener address, for example after a pluggable database has moved.

Keeping sessions on the controlled path

For a control point, every one of these mechanisms is a way to lose the session. If it only knows the first address, the redirected connection may fail, or it may succeed on a path that the control never sees. The control has to understand the redirect, present an address that keeps the client on the controlled path, and do so again after a failover. Encryption makes the task harder, because the control must process encrypted traffic without weakening it. DataSunrise supports proxy handling of redirect-based connections for SQL Server, Oracle, SAP HANA and Vertica, including SQL Server connections through an Always On listener or Azure SQL. For encrypted connections, administrators must also configure the proxy for the database’s TLS and authentication requirements.

The control point also has to be at least as available as the database it protects. A security layer that becomes a single point of failure rarely survives the first outage it causes. DataSunrise supports high-availability deployments. If the remote configuration database becomes unavailable, Emergency Dictionary mode uses a local backup of the configuration. Backup creation must remain enabled and a usable copy must be available; the backup may lag behind the latest changes.

Performance under production load

Every request that passes through a control point pays for it. The budget is small, and predictability matters as much as the average. Application owners notice a slow tail, a pause during connection setup, or a large result that streams more slowly than before, even when typical queries look unaffected.

The cost comes from everything described above: following the protocol, analyzing each statement, evaluating policies, rewriting results and recording events. The design must handle each step at production volume, not just in a demonstration. The added latency depends on the workload and the controls enabled, so measure it under a representative workload, as the first article in this series recommends.

Different constraints, different deployment modes

No single architecture fits every environment. Some teams can route application traffic through an inline component. Others cannot change the network path, cannot install software on a database host, or work with a managed service that exposes only native logs.

Five DataSunrise deployment modes: proxy for audit, masking and blocking; web application for traffic analysis; sniffer and native audit logs for visibility; agent on the database host.
Proxy: inline between clients and the database; audit, mask and block.Web application: analyzes traffic to supported web apps such as Salesforce and ChatGPT.Sniffer: analyzes a copy of database traffic for visibility.Native audit logs: reads the database audit records for visibility.Agent: captures database activity on the database host while clients connect directly to the database.
Five deployment modes for different environment constraints.

DataSunrise offers five deployment modes for those constraints:

  • Proxy: inline between clients and the database; can audit, mask and block.
  • Web application: captures traffic between users and supported web applications, including Salesforce and supported generative AI services, for analysis.
  • Sniffer: analyzes a copy of the traffic; provides visibility without changing the original request.
  • Native audit log trailing: reads the database’s own audit records; visibility without being in the data path.
  • Agent: runs on the database server and captures traffic without a proxy.

A partner deployment used EDB Advanced Server rather than standard PostgreSQL. Its database process was named edb-postgres, which the host-based agent needed to recognize. DataSunrise extended the agent’s process handling, enabling it to capture database activity on EDB Advanced Server 16 on Linux.

Each mode answers a different constraint. Engineers must build, test and support it across the sources where it applies. The deployment choice follows the action a team needs. For a platform vendor, supporting several modes means maintaining what are effectively several products under one policy model.

What to count when estimating the build

For a team deciding whether to build this layer, the useful exercise is to count the work rather than the features:

  • Sources and versions: which engines, protocol versions and client drivers have to work, and how each will be tested.
  • Statement coverage: how the control will recognize objects in every syntactic form, including dynamic SQL.
  • Result rewriting: how masked values will stay valid for every type, driver and application in use.
  • Identity: where real users appear in each application’s traffic, and how they will stay attached to reused sessions.
  • Topology: which redirects, listeners, replicas and failover paths exist, and how encrypted sessions stay on the controlled path.
  • Operations: the latency budget, high availability of the control itself, upgrades without downtime, and a way to restore previous behavior.
  • Deployment modes: which environments need inline control and which need visibility without changing traffic.

Each line hides its own test matrix. The total is the honest estimate.

Conclusion: the work is in the edge cases

None of these problems is unsolvable on its own. A capable team can parse one protocol, mask one column type or follow one redirect. The difficulty lies in the combination, and in the long tail that appears only in production: a driver version that handles metadata differently, an unusual authentication sequence, or a failover in the middle of a long transaction. Teams discover those cases one customer environment at a time, over years.

For vendors considering database controls as part of a wider platform, the question is not whether a metadata connector can reach the database. Can the control sit in the production traffic path and understand the requests it must act on? Can it reject requests or mask returned values when a policy requires it, while maintaining application compatibility? That capability is built from accumulated edge cases, and it is the part of database security that a new metadata connector does not provide.

Previously in this series: Seeing Is Not Stopping: From Database Visibility to Database Security Enforcement.

Protect Your Data with DataSunrise

Secure your data across every layer with DataSunrise. Detect threats in real time with Activity Monitoring, Data Masking, and Database Firewall. Enforce Data Compliance, discover sensitive data, and protect workloads across 50+ supported cloud, on-prem, and AI system data source integrations.

Start protecting your critical data today

Request a Demo Download Now

Need Our Support Team Help?

Our experts will be glad to answer your questions.

General information:
[email protected]
Customer Service and Technical Support:
support.datasunrise.com
Partnership and Alliance Inquiries:
[email protected]