Security and Data Protection

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

Change data capture copies data, and a migration copies it more than once. Every row of the legacy BOOKSHOP schema ends up as events in Kafka topics, as rows in the PostgreSQL mirror tables, as rows in the new bookshop model, and sometimes in dead-letter topics, connector logs and test fixtures. Every update adds the previous version of the row (the before image) to that history. A pipeline that is secure on day one can therefore turn into the largest uncontrolled copy of customer data in the company by the end of the migration, held in a system (Kafka) that the legacy database administrators never reviewed.

This page covers the controls that keep the pipeline within the same security rules as the legacy database: separate least-privilege users for every connector, encryption on every network hop, secrets that never appear in connector configurations, columns that are excluded, truncated, masked or pseudonymised before they leave the connector, access control on the topics, and retention rules for the personal data that change events carry. Kafka’s own security mechanisms (listeners, TLS, SASL, ACLs) are explained on Kafka Security; this page applies them to the Debezium pipeline.

Checked on 2026-11-09 against Debezium 3.7.1.Final, Kafka 4.3 (the version in quay.io/debezium/connect:3.7.1.Final), PostgreSQL 18 and Oracle AI Database 26ai Free (image gvenzl/oracle-free:23.26.3). Two things on this page were run with Docker and Testcontainers on 2026-11-09: the FileConfigProvider and EnvVarConfigProvider set-up of the Debezium Connect image (a PostgreSQL source connector registered with ${file:...} and ${env:...} placeholders reached RUNNING, and the stored configuration kept the placeholder), and the column.mask.hash.v2 formula (see Testing CDC Pipelines). The rest is derived from the official documentation and was not run.

Where the legacy data ends up

The first step is an inventory. For the Bookshop pipeline, data from the legacy schema is stored in all these places, and each needs an owner, an access rule and a retention rule:

flowchart LR ora[(Oracle BOOKSHOP)] --> src[bookshop-oracle-source] src --> topics[Topics legacy.BOOKSHOP.*] src --> hist[Topic legacy.schema-history] src --> logs[Connect worker logs] topics --> sink[bookshop-pg-mirror-sink] topics --> app[bookshop application] sink --> mirror[(PostgreSQL legacy_* tables)] sink --> dlq[Topic bookshop-pg-mirror-sink.dlq] app --> pg[(PostgreSQL bookshop model)] app --> dlt[Topics legacy.BOOKSHOP.*.DLT] topics --> fixtures[Recorded test fixtures]
  • Data topics (legacy.BOOKSHOP.BOOK, legacy.BOOKSHOP.CUSTOMER and so on) hold every change with its before and after images for as long as the topic retention allows.

  • The schema history topic (legacy.schema-history) holds DDL statements, not row data, but it describes the whole legacy schema and is kept forever.

  • Dead-letter topics hold the records that could not be applied, including their full values.

  • Connect worker logs can contain record keys and values, depending on errors.log.include.messages and on the log level of the connectors.

  • The mirror tables and the new model are the intended copies, governed by the new database’s own access rules.

  • Test fixtures recorded from the real pipeline (see Testing CDC Pipelines) end up in a source code repository unless someone scrubs them.

The rest of the page reduces what reaches each of these places and controls who can read it.

Least-privilege users for every connector

Every connector gets its own database user, with only the privileges that its documentation lists. A shared "debezium" user with DBA rights is the most common shortcut and the most dangerous one: it can read every schema, it hides which pipeline made which change in the database audit trail, and it makes it impossible to revoke one pipeline without stopping the others. Separate users also make the loop prevention of reverse replication possible, because the Oracle connector filters changes by the user that made them (Filtering by user).

Connector Database user Privileges

bookshop-oracle-source

C##DBZUSER (common user)

CREATE SESSION, SET CONTAINER, LOGMINING, SELECT on the V$ views that LogMiner needs, SELECT and FLASHBACK on the captured tables, the flush-table privileges, and INSERT and DELETE on the signal table BOOKSHOP.DEBEZIUM_SIGNAL (for the incremental snapshot watermarks). The complete grant script, and how to replace SELECT ANY TABLE and FLASHBACK ANY TABLE with grants on the BOOKSHOP tables, is on the Oracle Connector page.

bookshop-pg-mirror-sink

bookshop_mirror

SELECT, INSERT, UPDATE, DELETE on the three legacy_* tables only. No DDL, because the tables are created by the schema migrations (schema.evolution=none).

bookshop-pg-source (reverse replication)

dbz_reverse (REPLICATION and LOGIN)

SELECT on the captured tables. Create the publication bookshop_reverse_pub as an administrator and set publication.autocreate.mode=disabled, so the connector needs neither CREATE on the database nor ownership of the tables.

bookshop-oracle-reverse-sink

BOOKSHOP_SYNC

INSERT, UPDATE, DELETE (and SELECT) on the BOOKSHOP tables that receive changes back. No DDL.

bookshop-mongo-source

a dedicated MongoDB user

Read on the bookshop database (with capture.scope=database) and the right to run the hello command; read on config.shards only for a sharded cluster.

A MySQL source (labs)

a dedicated MySQL user

SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT, as listed in the MySQL connector documentation.

The PostgreSQL source user for the reverse direction, with a publication that an administrator (or the table owner) creates beforehand, looks like this. The role, the publication and its table list are those of Cut-over & Reverse Replication: the publication holds exactly the tables whose source of truth has moved, starting with the catalogue.

A least-privilege PostgreSQL source user with a pre-created publication
-- As an administrator (or the owner of the tables) of the new bookshop database
CREATE ROLE dbz_reverse WITH LOGIN REPLICATION PASSWORD 'change-me';
GRANT CONNECT ON DATABASE bookshop TO dbz_reverse;
GRANT USAGE ON SCHEMA public TO dbz_reverse;
GRANT SELECT ON book, book_author, author TO dbz_reverse;

-- The publication is created by the administrator, not by the connector
CREATE PUBLICATION bookshop_reverse_pub FOR TABLE book, book_author, author;
The matching connector settings (fragment)
{
  "database.user": "dbz_reverse",
  "plugin.name": "pgoutput",
  "slot.name": "bookshop_reverse",
  "publication.name": "bookshop_reverse_pub",
  "publication.autocreate.mode": "disabled"
}

With publication.autocreate.mode=disabled, the connector fails at start-up if the publication does not exist, which is the behaviour you want: nobody can widen what is published by changing a connector property. The default all_tables would create a publication FOR ALL TABLES, which publishes every table of the database (including ones that the include list then filters out on the connector side).

The connector host must also be allowed to connect in pg_hba.conf. The Debezium documentation shows replication entries with the trust method; for production, use hostssl with scram-sha-256 and restrict the address range. Note that the replication keyword in the database column of pg_hba.conf matches only physical replication connections. A logical replication connection, which is what the Debezium connector opens, names a database and is matched by the database name, as the PostgreSQL documentation explains.

pg_hba.conf entries for the Debezium connector host
# TYPE   DATABASE  USER          ADDRESS        METHOD
hostssl  bookshop  dbz_reverse   10.20.0.0/24   scram-sha-256

The users in this table belong to the migration and have an end date. When a pipeline is decommissioned, drop its database user, its replication slot and its publication, as part of the decommissioning steps on Cut-over & Reverse Replication.

Encryption in transit

A Debezium pipeline has three kinds of network connection, and each must be encrypted and authenticated separately.

Connectors to databases

Each connector configures TLS to its database in its own way. The settings below verify the server certificate and the host name, which is what prevents a man-in-the-middle; the modes that only "prefer" encryption fall back to plain text silently.

Connector Settings

PostgreSQL source

database.sslmode=verify-full (default prefer), database.sslrootcert, and for client certificates database.sslcert, database.sslkey, database.sslpassword.

MySQL source

database.ssl.mode=verify_identity (default preferred), database.ssl.truststore, database.ssl.truststore.password, and database.ssl.keystore, database.ssl.keystore.password for client certificates.

Oracle source

A TCPS connect descriptor in database.url, with the Java key and trust stores (or an Oracle Wallet) passed as driver.* properties. The full example is in Oracle Connector.

MongoDB source

TLS options in mongodb.connection.string, or mongodb.ssl.enabled=true with the mongodb.ssl.* key and trust store properties.

JDBC sink

TLS parameters of the target’s JDBC driver in connection.url, for PostgreSQL ?sslmode=verify-full&sslrootcert=....

TLS from the mirror sink to PostgreSQL (fragment)
{
  "connection.url": "jdbc:postgresql://postgres:5432/bookshop?sslmode=verify-full&sslrootcert=/kafka/secrets/pg-ca.crt&stringtype=unspecified",
  "connection.username": "bookshop_mirror",
  "connection.password": "${file:/kafka/secrets/bookshop-mirror.properties:password}"
}

The TLS parameters are added to the URL that the mirror sink already uses; stringtype=unspecified stays, because the Bookshop source sends every Oracle NUMBER as a string (decimal.handling.mode=string) and PostgreSQL has to cast those strings to bigint and numeric (JDBC Sink Connector).

TLS from the PostgreSQL source to the database (fragment)
{
  "database.hostname": "postgres",
  "database.sslmode": "verify-full",
  "database.sslrootcert": "/kafka/secrets/pg-ca.crt"
}

verify-full checks that the host name in database.hostname matches the server certificate, so the certificate must be issued for the name the connector uses (here the Compose service name postgres; in production the real DNS name).

Kafka Connect and the connectors to Kafka

A Kafka Connect worker talks to Kafka through several clients, and a secured cluster needs the security settings for each of them. The Kafka documentation puts it plainly: on a secured cluster the parameters must be set up to three times in the worker configuration, once for the worker’s own management clients, once (with the producer. prefix) for source connectors and once (with the consumer. prefix) for sink connectors. Debezium adds clients of its own:

  • the schema history producer and consumer, configured with schema.history.internal.producer.* and schema.history.internal.consumer.* in the connector configuration;

  • the consumer of the Kafka signal channel, configured with signal.consumer.*.

A source connector whose data topics work but which cannot read its schema history at start-up is the typical symptom of a forgotten prefix.

Worker security settings in the Debezium Connect image (SASL_SSL with SCRAM, Compose fragment)
services:
  connect:
    image: quay.io/debezium/connect:3.7.1.Final
    environment:
      BOOTSTRAP_SERVERS: kafka:9093
      GROUP_ID: bookshop-connect
      CONFIG_STORAGE_TOPIC: connect_configs
      OFFSET_STORAGE_TOPIC: connect_offsets
      STATUS_STORAGE_TOPIC: connect_statuses
      # The worker's own clients
      CONNECT_SECURITY_PROTOCOL: SASL_SSL
      CONNECT_SASL_MECHANISM: SCRAM-SHA-512
      CONNECT_SASL_JAAS_CONFIG: org.apache.kafka.common.security.scram.ScramLoginModule required username="bookshop-connect" password="${BOOKSHOP_CONNECT_KAFKA_PASSWORD}";
      CONNECT_SSL_TRUSTSTORE_LOCATION: /kafka/secrets/kafka-truststore.p12
      CONNECT_SSL_TRUSTSTORE_TYPE: PKCS12
      CONNECT_SSL_TRUSTSTORE_PASSWORD: ${KAFKA_TRUSTSTORE_PASSWORD}
      # Producers of source connectors
      CONNECT_PRODUCER_SECURITY_PROTOCOL: SASL_SSL
      CONNECT_PRODUCER_SASL_MECHANISM: SCRAM-SHA-512
      CONNECT_PRODUCER_SASL_JAAS_CONFIG: org.apache.kafka.common.security.scram.ScramLoginModule required username="bookshop-connect" password="${BOOKSHOP_CONNECT_KAFKA_PASSWORD}";
      CONNECT_PRODUCER_SSL_TRUSTSTORE_LOCATION: /kafka/secrets/kafka-truststore.p12
      CONNECT_PRODUCER_SSL_TRUSTSTORE_TYPE: PKCS12
      CONNECT_PRODUCER_SSL_TRUSTSTORE_PASSWORD: ${KAFKA_TRUSTSTORE_PASSWORD}
      # Consumers of sink connectors
      CONNECT_CONSUMER_SECURITY_PROTOCOL: SASL_SSL
      CONNECT_CONSUMER_SASL_MECHANISM: SCRAM-SHA-512
      CONNECT_CONSUMER_SASL_JAAS_CONFIG: org.apache.kafka.common.security.scram.ScramLoginModule required username="bookshop-connect" password="${BOOKSHOP_CONNECT_KAFKA_PASSWORD}";
      CONNECT_CONSUMER_SSL_TRUSTSTORE_LOCATION: /kafka/secrets/kafka-truststore.p12
      CONNECT_CONSUMER_SSL_TRUSTSTORE_TYPE: PKCS12
      CONNECT_CONSUMER_SSL_TRUSTSTORE_PASSWORD: ${KAFKA_TRUSTSTORE_PASSWORD}
    volumes:
      - ./secrets:/kafka/secrets:ro

The Debezium image turns every CONNECT_* environment variable into a worker property (lower case, _ replaced by .), and it prints [hidden] instead of the value for the JAAS configuration and the key and trust store passwords when it logs the configuration at start-up. The ${...} values in the Compose file are substituted by Docker Compose from the shell environment or an .env file that is not committed.

Schema history and signal clients on a secured cluster (connector fragment)
{
  "schema.history.internal.kafka.bootstrap.servers": "kafka:9093",
  "schema.history.internal.producer.security.protocol": "SASL_SSL",
  "schema.history.internal.producer.sasl.mechanism": "SCRAM-SHA-512",
  "schema.history.internal.producer.sasl.jaas.config": "${file:/kafka/secrets/kafka-client.properties:sasl.jaas.config}",
  "schema.history.internal.producer.ssl.truststore.location": "/kafka/secrets/kafka-truststore.p12",
  "schema.history.internal.producer.ssl.truststore.type": "PKCS12",
  "schema.history.internal.producer.ssl.truststore.password": "${file:/kafka/secrets/kafka-client.properties:truststore.password}",
  "schema.history.internal.consumer.security.protocol": "SASL_SSL",
  "schema.history.internal.consumer.sasl.mechanism": "SCRAM-SHA-512",
  "schema.history.internal.consumer.sasl.jaas.config": "${file:/kafka/secrets/kafka-client.properties:sasl.jaas.config}",
  "schema.history.internal.consumer.ssl.truststore.location": "/kafka/secrets/kafka-truststore.p12",
  "schema.history.internal.consumer.ssl.truststore.type": "PKCS12",
  "schema.history.internal.consumer.ssl.truststore.password": "${file:/kafka/secrets/kafka-client.properties:truststore.password}",

  "signal.kafka.bootstrap.servers": "kafka:9093",
  "signal.consumer.security.protocol": "SASL_SSL",
  "signal.consumer.sasl.mechanism": "SCRAM-SHA-512",
  "signal.consumer.sasl.jaas.config": "${file:/kafka/secrets/kafka-client.properties:sasl.jaas.config}",
  "signal.consumer.ssl.truststore.location": "/kafka/secrets/kafka-truststore.p12",
  "signal.consumer.ssl.truststore.type": "PKCS12",
  "signal.consumer.ssl.truststore.password": "${file:/kafka/secrets/kafka-client.properties:truststore.password}"
}

The Kafka Connect REST API

The REST API on port 8083 is the most powerful interface in the pipeline. Whoever can reach it can read every connector configuration, register a connector that copies any table the connector user can read to any topic, reset offsets, and send configuration that loads classes. The Kafka documentation warns that the REST API is unsecured by default and that exposing it to untrusted users makes it easy to gain arbitrary code execution on the workers. It also recommends, since Kafka 4.2, the Allowlist client override policy (the default from Kafka 5.0), so that connectors can override only the client settings you list. For a migration:

  • Never publish port 8083 outside the private network of the Connect cluster. The http://localhost:8083 in the examples of this section is a local lab.

  • Put an authenticating reverse proxy or the Kafka Connect REST extension mechanism in front of it if people, not just automation, need access.

  • Set connector.client.config.override.policy=Allowlist and list in connector.client.config.override.allowlist only the client settings that your connectors really override (for example the producer’s max.request.size, see Troubleshooting).

  • Treat changes to connector configurations like schema migrations: reviewed, versioned, applied by a pipeline.

Secrets: configuration providers

A connector configuration is a JSON document that Kafka Connect stores in its config topic (connect_configs) and returns from GET /connectors/{name}/config. A password written into it is readable by everyone who can read that topic or call that endpoint, and it ends up in every copy of the JSON in version control. Kafka’s configuration providers solve this: the configuration contains a placeholder such as ${file:/kafka/secrets/bookshop-mirror.properties:password}, the worker resolves it when it starts the connector, and the stored configuration keeps the placeholder.

Kafka 4.x ships three providers. A worker enables them with config.providers and one config.providers.<alias>.class per alias; the alias is the first part of the placeholder.

Provider Reads Placeholder

org.apache.kafka.common.config.provider.FileConfigProvider

One key of a Java properties file. Restrict the readable paths with the allowed.paths parameter.

${file:<path_and_filename>:<property>}

org.apache.kafka.common.config.provider.DirectoryConfigProvider

A directory in which each file is one key and its content the value (the layout of Kubernetes secrets mounted as volumes and of Docker secrets). Restrict with allowed.paths.

${dir:<path_to_dir>:<file_name>}

org.apache.kafka.common.config.provider.EnvVarConfigProvider

An environment variable of the worker process. Restrict the readable names with the allowlist.pattern parameter, a regular expression.

${env:<variable_name>}

Parameters are passed as config.providers.<alias>.param.<name>. Without allowed.paths the file and directory providers can read any file that the worker process can read, which includes the worker’s own key stores; without allowlist.pattern the environment provider exposes every environment variable. Always set both: a connector configuration is user input.

Enable the providers in the Debezium Connect image (Compose fragment)
services:
  connect:
    image: quay.io/debezium/connect:3.7.1.Final
    environment:
      CONNECT_CONFIG_PROVIDERS: file,dir,env
      CONNECT_CONFIG_PROVIDERS_FILE_CLASS: org.apache.kafka.common.config.provider.FileConfigProvider
      CONNECT_CONFIG_PROVIDERS_FILE_PARAM_ALLOWED_PATHS: /kafka/secrets
      CONNECT_CONFIG_PROVIDERS_DIR_CLASS: org.apache.kafka.common.config.provider.DirectoryConfigProvider
      CONNECT_CONFIG_PROVIDERS_DIR_PARAM_ALLOWED_PATHS: /run/secrets
      CONNECT_CONFIG_PROVIDERS_ENV_CLASS: org.apache.kafka.common.config.provider.EnvVarConfigProvider
      CONNECT_CONFIG_PROVIDERS_ENV_PARAM_ALLOWLIST_PATTERN: ^BOOKSHOP_.*
      BOOKSHOP_ORACLE_CDC_USER: c##dbzuser
    volumes:
      - ./secrets:/kafka/secrets:ro

The entrypoint maps CONNECT_CONFIG_PROVIDERS_FILE_PARAM_ALLOWED_PATHS to config.providers.file.param.allowed.paths and CONNECT_CONFIG_PROVIDERS_ENV_PARAM_ALLOWLIST_PATTERN to config.providers.env.param.allowlist.pattern, because both parameter names contain dots where the variable names contain underscores.

secrets/bookshop-mirror.properties (readable only by the Connect container user)
password=change-me
Connector configurations with placeholders instead of secrets (fragments)
{
  "name": "bookshop-pg-mirror-sink",
  "config": {
    "connection.username": "bookshop_mirror",
    "connection.password": "${file:/kafka/secrets/bookshop-mirror.properties:password}"
  }
}

{
  "name": "bookshop-oracle-source",
  "config": {
    "database.user": "${env:BOOKSHOP_ORACLE_CDC_USER}",
    "database.password": "${dir:/run/secrets:bookshop_oracle_cdc_password}"
  }
}

This set-up was run with the Debezium Connect 3.7.1.Final image: a PostgreSQL source connector whose user came from ${env:...} and whose password came from ${file:...} reached RUNNING, and GET /connectors/{name}/config still returned the placeholder, not the password.

A few properties cannot be protected this way, because providers substitute values, not names. The most important is the salt of column.mask.hash.v2, which is part of the property name (see below). Protect the connector configuration itself, through access to the REST API and ACLs on the config topic.

Kubernetes. With Strimzi, the KubernetesSecretConfigProvider (io.strimzi.kafka.KubernetesSecretConfigProvider) reads keys of Kubernetes Secret objects directly, with placeholders such as ${secrets:<namespace>/<secret>:<key>}, and the Connect service account needs RBAC permission to read those secrets. Mounting the secret as a volume and using the DirectoryConfigProvider works without extra RBAC. Both are shown on Running on Kubernetes and in the official Debezium on Kubernetes guide.

HashiCorp Vault and other secret managers. Kafka has no built-in Vault provider. The two options are an agent that renders the secrets into files (for example a Vault Agent sidecar or a CSI secrets driver), read with the file or directory provider, or a custom provider: a class that implements org.apache.kafka.common.config.provider.ConfigProvider, packaged as a JAR on the worker’s plugin path. Prefer the first; it needs no code on the worker.

Not migrating sensitive data

The safest personal data is the data that never leaves the legacy database. Debezium relational connectors can remove, shorten, blank out or pseudonymise columns inside the connector, before the event is serialised. That means the values never reach Kafka, the dead-letter queues, the logs or the fixtures, and the rule applies equally to snapshot and streaming events.

Decide for every column of every captured table:

The new system needs the column…​ Use Property

not at all

Exclude it from the event value

column.exclude.list (or column.include.list)

only partially (a prefix)

Truncate it

column.truncate.to.<length>.chars

not as a value, but as a stable identifier for joins and reconciliation

Replace it with a salted hash (a pseudonym)

column.mask.hash.v2.<algorithm>.with.salt.<salt>

not in this environment (test or analytics copies)

Replace it with asterisks

column.mask.with.<length>.chars

completely

Leave it, and protect the topic

Topic ACLs and retention, below

All these properties take a comma-separated list of regular expressions that are matched, anchored, against the fully qualified column name, <schemaName>.<tableName>.<columnName> (for Oracle BOOKSHOP.CUSTOMER.EMAIL). The truncation and masking properties apply to character-based columns, and the length is part of the property name. A configuration can contain several of each, with different lengths or algorithms.

  • column.exclude.list removes the column from the event value. A primary key column always stays in the event key, even if it is excluded, so a sensitive natural key cannot be hidden this way. column.include.list is the opposite (an allowlist); set only one of the two.

  • column.truncate.to.<length>.chars shortens values that are longer than the length.

  • column.mask.with.<length>.chars replaces the value with that many asterisks, or with an empty string for a length of 0.

  • column.mask.hash.<algorithm>.with.salt.<salt> and column.mask.hash.v2.<algorithm>.with.salt.<salt> replace the value with the hexadecimal hash of the salt and the value, using any MessageDigest algorithm name of the Java platform (for example SHA-256). The pseudonym is shortened to the column length if necessary. The official documentation recommends the version 2 strategy when the value is hashed in different places or systems.

The official descriptions are in each connector’s property table. In the 3.7 Oracle property table the description of column.truncate.to.length.chars repeats the text of the masking property (asterisks); the PostgreSQL and MySQL tables describe it as truncation, which is what the property does.

Example: a test copy of the legacy data

The production pipeline of Bookshop needs customer names and e-mail addresses, because the new customer table stores them. A second pipeline that feeds a test environment does not. It can use its own source connector, with its own topic prefix, and remove or pseudonymise the personal columns before they leave Oracle. The connector name bookshop-oracle-source-test and the prefix legacy-test are illustrative. Run it against a clone of the legacy database where possible: a second connector on the production database opens a second LogMiner session and doubles the mining load, which is why Best Practices recommends one source connector per legacy database.

Oracle source for a test environment, with personal data removed (fragment)
{
  "name": "bookshop-oracle-source-test",
  "config": {
    "connector.class": "io.debezium.connector.oracle.OracleConnector",
    "topic.prefix": "legacy-test",
    "table.include.list": "BOOKSHOP.BOOK,BOOKSHOP.AUTHOR,BOOKSHOP.CUSTOMER,BOOKSHOP.ORDERS,BOOKSHOP.ORDER_LINE",
    "schema.history.internal.kafka.topic": "legacy-test.schema-history",

    "column.mask.hash.v2.SHA-256.with.salt.Qm9va3Nob3BUZXN0": "BOOKSHOP.CUSTOMER.EMAIL",
    "column.mask.with.12.chars": "BOOKSHOP.CUSTOMER.CUST_NAME",
    "column.truncate.to.40.chars": "BOOKSHOP.BOOK.TITLE"
  }
}

In the test environment every customer keeps a distinct, stable e-mail pseudonym (so joins, uniqueness checks and de-duplication still work), the names are blanked, and the other connection, schema history and snapshot properties are the same as in the production bookshop-oracle-source configuration on the Oracle Connector page.

The version 2 hash is reproducible outside Debezium, which is useful for reconciliation: it is the lower-case hexadecimal digest of the salt followed by the value. The integration test on Testing CDC Pipelines asserts exactly that against Debezium 3.7.1. The same pseudonym can be computed in PostgreSQL to compare a test copy with the source:

Compute the column.mask.hash.v2 SHA-256 pseudonym in PostgreSQL
-- Salt and value concatenated, hashed, hex encoded: equals the value that Debezium writes into EMAIL
SELECT encode(sha256(convert_to('Qm9va3Nob3BUZXN0' || 'ada.reader@example.com', 'UTF8')), 'hex');

The salt is part of the property name, so it cannot come from a configuration provider. The connector configuration must therefore be treated as a secret for as long as the pseudonyms must not be reversible.

What hashing does not do

A salted hash is pseudonymisation, not anonymisation. The official documentation warns that, depending on the algorithm, the salt and the data set, the result might not be completely masked. Values with little variety (status codes, birth dates, postcodes, short names) can be recovered by hashing every possible value with the salt, and anyone who knows the salt can do that. Personal data that is pseudonymised is still personal data under most data protection laws. Use exclusion where you can, hashing where you need a join key, and masking with asterisks for display values in non-production copies.

Two further limits:

  • The column filters act on the row data in change events. The schema history topic still contains the DDL of the table, including the names of excluded columns, and the column names are also in the event schemas.

  • Kafka’s own ReplaceField and MaskField transformations, and Debezium’s own transformations, can also remove or mask fields, but they run after the connector has produced the record, and on a Debezium envelope they see the before and after structures as two nested fields. The connector properties are simpler and cover both images. Transformations are explained on Debezium Transformations.

Access control on the topics

With the data in Kafka, topic ACLs decide who can read it. Name principals after the component, and grant the narrowest operations. For Bookshop:

Principal Needs Must not have

User:bookshop-connect (the Connect workers)

The ACLs that the Kafka documentation lists for workers (group and internal topics), Write and Create on the legacy. prefix, Read on legacy.signals, Read and Write on legacy.schema-history, Read on the three data topics for the mirror sink and on its group connect-bookshop-pg-mirror-sink, Write on bookshop-pg-mirror-sink.dlq

Read on topics of other systems

User:bookshop (the Spring Boot application)

Read on the legacy.BOOKSHOP. prefix and its group bookshop-legacy-sync, Write on the .DLT topics

Write on the data topics, any access to legacy.schema-history or legacy.signals

User:migration-operator

Write on legacy.signals (to trigger snapshots), Read on legacy.notifications

Read on the data topics, unless the person is also allowed to see customer data

ACLs for the Bookshop application and the migration operators
# The application reads every legacy data topic and commits offsets in its consumer group
/kafka/bin/kafka-acls.sh --bootstrap-server kafka:9093 --command-config admin.properties \
  --add --allow-principal User:bookshop --operation Read --operation Describe \
  --topic legacy.BOOKSHOP. --resource-pattern-type prefixed
/kafka/bin/kafka-acls.sh --bootstrap-server kafka:9093 --command-config admin.properties \
  --add --allow-principal User:bookshop --operation Read --group bookshop-legacy-sync

# Operators may send signals and read notifications, nothing else
/kafka/bin/kafka-acls.sh --bootstrap-server kafka:9093 --command-config admin.properties \
  --add --allow-principal User:migration-operator --operation Write --operation Describe --topic legacy.signals
/kafka/bin/kafka-acls.sh --bootstrap-server kafka:9093 --command-config admin.properties \
  --add --allow-principal User:migration-operator --operation Read --operation Describe --topic legacy.notifications

The signal topic deserves the same care as the REST API. A message on legacy.signals can start an incremental snapshot that re-reads whole tables, or, on Oracle, drop a transaction from the buffer (Signaling & Notifications). The same applies to the signal table BOOKSHOP.DEBEZIUM_SIGNAL: besides the connector user C##DBZUSER, which needs INSERT and DELETE on it for the incremental snapshot watermarks, grant INSERT on it only to the operators' database role. The prefixed ACL on legacy.BOOKSHOP. deliberately does not match legacy.signals, legacy.notifications or legacy.schema-history. How ACLs and prefixed patterns work in general is explained in Kafka Security.

Personal data in the change history

Kafka keeps what the retention settings tell it to keep, and a Debezium data topic is a history of personal data: every version of every customer row, with the old values in before. Three settings decide how long that history lives:

  • cleanup.policy=delete with retention.ms. Segments older than the retention are deleted, whatever their content. This is the predictable choice for migration topics: set the retention to the replay window that the migration needs (long enough to rebuild a consumer or re-run a sink, for example 14 days), not to forever.

  • cleanup.policy=compact. Kafka keeps the latest record per key. When a row is deleted, the connector emits the delete event and then a tombstone (a record with the same key and a null value), and compaction eventually removes older records for that key, and later the tombstone itself, after delete.retention.ms. Compaction is not immediate: it runs only on closed segments and depends on min.compaction.lag.ms and the dirty ratio, so a deleted customer’s data can remain readable for some time. Do not turn off tombstones (tombstones.on.delete=false) on compacted topics that hold personal data.

  • Topic creation defaults. When Debezium creates the topics through Kafka Connect topic creation, the topic.creation.default.* properties of the connector set the topic configuration, so the retention is part of the reviewed connector configuration rather than a broker default.

Retention for the topics created by the Oracle source (fragment)
{
  "topic.creation.default.replication.factor": "3",
  "topic.creation.default.partitions": "1",
  "topic.creation.default.cleanup.policy": "delete",
  "topic.creation.default.retention.ms": "1209600000"
}

Topic creation and its groups are covered in more detail on Offsets, Restarts & Exactly-Once. The schema history topic is the exception: it needs infinite retention, which is acceptable because it contains DDL, not rows.

The less obvious copies need rules too:

  • Dead-letter topics. They contain full records. Give them the same ACLs and a short retention, and empty them as part of the incident procedure.

  • Logs. Keep errors.log.include.messages=false (the default) on every connector, which logs the coordinates of a failed record but not its key and value. Debug and trace logging of connectors can include row data; enable it for a limited time and on a limited logger only.

  • Test fixtures. Change events recorded from the real pipeline for tests must be pseudonymised before they are committed. The fixtures on Testing CDC Pipelines are synthetic.

  • The mirror tables. legacy_book, legacy_author and legacy_supplier_catalogue hold no customer data. If a mirror of CUSTOMER is added, it inherits the access rules of the new database and must be dropped at the end of the migration.

  • Erasure requests during the migration. A customer deleted in the legacy system produces a delete event, which the translators and sinks apply to the new database. A deletion requested only in the new system after the cut-over must also reach any reverse-replication target, and the history in the topics expires with their retention.

At decommission, delete the migration topics (data, schema history, signals, notifications, dead-letter topics), the connectors and their offsets, the replication slots and publications, and the database users from the table above.

Checklist

Before the pipeline carries production data:

  1. Each connector has its own database user with only the documented privileges; no DBA role, no SUPERUSER.

  2. The PostgreSQL publication is created by an administrator and publication.autocreate.mode=disabled.

  3. Every database connection verifies the server certificate and host name (verify-full, verify_identity, TCPS).

  4. The Connect workers, source producers, sink consumers, schema history clients and signal consumer all use the secured Kafka listener.

  5. No password appears in any connector configuration, in the Connect config topic or in version control; the providers are restricted with allowed.paths and allowlist.pattern.

  6. The Connect REST API is reachable only from the private network and from automation, and the client override policy is restricted.

  7. Every captured column has a decision: migrate, exclude, truncate, hash or mask.

  8. Topic ACLs follow the table above, and nobody but the Connect workers can read legacy.schema-history.

  9. Data topics, dead-letter topics and notification topics have an explicit retention; the schema history topic has infinite retention.

  10. Connector logs do not include record contents, and test fixtures are synthetic or pseudonymised.