Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
180 changes: 180 additions & 0 deletions adr/0001-kafka-status-producer-security.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
# ADR-0001: Secure connections for the Kafka status-event producer

- **Status:** Accepted
- **Date:** 2026-11-23
- **Module:** `kafka` (`com.netflix.conductor.kafka.status.events`)

## Context

Conductor can publish task and workflow status changes to Kafka
(`conductor.message-publisher.type=kafka`). The events contain task and workflow input and
output, which can include sensitive data.

The producer was built in `KafkaEventServiceImpl` from a fixed set of settings:
`bootstrap.servers`, `acks`, `client.id` and the serializers. `KafkaProperties` exposed only
those and the topic settings, and nothing else was passed to the Kafka client. As a result
the producer always used Kafka's default `security.protocol=PLAINTEXT`:

- events crossed the network unencrypted;
- the broker could not authenticate Conductor;
- there was no configuration option to change either.

Deployments need to connect to brokers that require one of:

| Mode | Encryption | Broker authenticated | Conductor authenticated by |
|---|---|---|---|
| SSL | Yes | Yes | Nothing |
| mTLS (SSL with client certificate) | Yes | Yes | Client certificate |
| SASL_SSL | Yes | Yes | SASL (PLAIN, SCRAM, OAUTHBEARER, GSSAPI) |
| SASL_PLAINTEXT | No | No | SASL |

Certificates come either as PKCS12 keystores (common in Java setups) or as PEM files (common
with Kubernetes secrets and cert-manager).

The project uses `kafka-clients` 3.9.1, which already supports all four modes and PEM
keystores and truststores (KIP-651). The gap is in Conductor, not in the library.

## Decision

### 1. Pass Kafka producer settings through from configuration

`KafkaProperties` gains a `producer` map bound from
`conductor.message-publisher.kafka.producer.*`. Keys are Kafka producer setting names and
are passed to the Kafka client as they are. This is the same approach the
`kafka-event-queue` module uses (`conductor.event-queues.kafka.producer.*`).

The map is `Map<String, String>` rather than `Map<String, Object>`. Spring Boot keeps a
dotted key such as `security.protocol` as a single key for scalar-valued maps, but splits it
into nested maps for `Object` values, which would make the setting invisible to Kafka.

The producer settings are built in one place, `KafkaEventServiceImpl.buildProducerConfig`, in
this order:

1. Defaults: `acks=all`, `client.id` = local host name (falling back to
`conductor-status-producer` if it cannot be resolved).
2. The user's `producer.*` settings, which may override the defaults.
3. `bootstrap.servers` from the existing `bootstrapServers` setting, when not blank.
4. The key and value serializers, which cannot be overridden because the event format
depends on `KafkaJsonSerializer`. Attempts to set them are ignored with a warning.

With no `producer.*` settings the resulting configuration is the same as before, so existing
deployments are unaffected.

### 2. Certificates and keys only as files

Keystores and truststores, in PKCS12 or PEM format, are given by file path
(`ssl.keystore.location`, `ssl.truststore.location`). The inline PEM settings
`ssl.keystore.key`, `ssl.keystore.certificate.chain` and `ssl.truststore.certificates` are
refused, and Conductor fails to start with a message pointing to the `*.location` settings.
The message names the setting but never includes its value.

### 3. Validate at startup, connect on first use

`KafkaEventServiceImpl`'s constructor builds and validates the settings, so a bad
configuration fails Conductor's startup rather than every status event:

- inline certificate settings are refused;
- each keystore and truststore location must exist and be readable;
- Kafka's own `ProducerConfig.configDef().parse(...)` checks types and allowed values
(for example `security.protocol`) without connecting or logging values;
- settings that are not Kafka producer settings are logged as a warning by key name only.
They are still passed through, as Kafka itself ignores unknown settings.

The `KafkaProducer` is still created on the first event, as before. Creating it at startup
would require the bootstrap address to resolve at startup.

### 4. One producer per service instance, closed on shutdown

The producer moves from a `static` field to an instance field, so service instances with
different settings no longer share whichever producer was created first. Conductor creates
one service bean, so runtime behaviour is unchanged. The service implements `AutoCloseable`;
Spring calls `close()` on shutdown, which closes the producer and waits at most 10 seconds
for events still being sent, so a Kafka outage cannot hold up shutdown indefinitely.

### 5. Keep kafka-clients at 3.9.1

No library change is needed, so the version stays as it is.

### 6. Test against a real broker

Besides unit tests of the settings builder, `KafkaSecurityContainerTest` runs a single-node
`apache/kafka:3.9.1` broker (matching the client version) with one listener per mode, and
checks each mode end to end through `KafkaEventServiceImpl` and `TaskStatusKafkaProducer`:

- delivery over SSL (PKCS12 and PEM truststores), mTLS (PKCS12 and PEM keystores), SASL_SSL
(PLAIN and SCRAM-SHA-512) and SASL_PLAINTEXT;
- rejection of a client without a certificate on the mTLS listener, a wrong SASL password,
and a broker certificate the client does not trust. These show the broker really enforces
each mode, so the delivery tests cannot pass by accident.

Certificates are generated per run with the JDK's `keytool`, so no private keys are stored in
the repository and no extra library is needed. The tests are skipped when Docker is not
available.

## Alternatives considered

**Dedicated, typed settings** (for example `kafka.security.mode=MTLS`,
`kafka.security.keystore-path`). Easier to discover, but each new Kafka option (another SASL
mechanism, OAuth settings, TLS protocol versions) would need code changes, and the names
would differ from Kafka's documentation. Passing settings through covers every mode with no
further code and matches `kafka-event-queue`.

**Allowing inline PEM settings.** Kafka supports them, but they put private keys into
configuration, which is more often copied, logged or committed than a mounted secret file.
In `.properties` files every line break must also be escaped. Files work in every target
environment, so inline settings were excluded deliberately.

**Creating the producer at startup.** This would also catch unreadable keystores, but the
Kafka client resolves the bootstrap addresses when it is created, so Conductor could not
start before Kafka's DNS name resolves (for example during a Kubernetes rollout). Checking
that store files are readable covers the most common error without that dependency.

**Failing on unknown settings.** Stricter, but would stop Conductor from starting on a
setting from a newer Kafka version or a harmless extra key. A warning naming the key makes
typos visible without that risk.

**Encrypting at the network level instead** (service mesh mTLS, private network). Useful in
addition, but does not help when the broker itself requires TLS or SASL, as managed Kafka
services usually do, and does not give the broker an identity for ACLs.

**Upgrading kafka-clients.** Not needed for any of the modes, and would affect other modules
that share the version.

## Consequences

**Positive**

- Status events can be encrypted, and Conductor can authenticate to the broker by
certificate or SASL credentials, so broker ACLs can apply to it.
- Any Kafka producer setting can be tuned without code changes.
- Misconfiguration (invalid values, missing files, inline certificates) is reported once at
startup with a clear message.
- Existing deployments without `producer.*` settings behave exactly as before.

**Negative / to be aware of**

- Certificates and credentials are read once, when the producer is created. A renewed
certificate or changed password takes effect only after Conductor restarts, which matters
with short-lived certificates.
- Passwords and `sasl.jaas.config` credentials live in configuration. They should be
supplied with `${...}` placeholders from environment variables or a secret store.
- A misspelt setting only produces a warning.
- SASL_PLAINTEXT is supported but sends events, and with PLAIN the password, unencrypted.
The README warns about this.
- The container tests need Docker and add roughly 30 seconds to the module's tests.

**Not covered**

- The `KAFKA_PUBLISH` system task (`KafkaProducerManager`) and the `kafka-event-queue`
module build their own Kafka clients and are unaffected by this decision.
- Encrypted PEM private keys work through `ssl.key.password`, but the container tests only
use unencrypted keys.

## References

- User documentation: [`kafka/README.md`](../kafka/README.md), section "Kafka Status Events".
- Implementation: `kafka/src/main/java/com/netflix/conductor/kafka/status/events/`.
- Tests: `kafka/src/test/java/com/netflix/conductor/kafka/status/events/services/`.
- Kafka producer settings: <https://kafka.apache.org/39/documentation/#producerconfigs>
- KIP-651, PEM support for keystores and truststores:
<https://cwiki.apache.org/confluence/display/KAFKA/KIP-651+-+Support+PEM+format+for+SSL+certificates+and+private+key>
23 changes: 23 additions & 0 deletions adr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Architecture Decision Records

This directory records significant design decisions made in this fork of Conductor, one
decision per file, using the format from Michael Nygard's
[Documenting Architecture Decisions](https://cognitect.com/blog/2011/11/15/documenting-architecture-decisions).

Files are named `NNNN-short-title.md` with a sequential number. A record is not rewritten
once accepted; if a decision changes, add a new record that supersedes it and update the old
record's status.

Each record has these sections:

- **Status**: Proposed, Accepted, Deprecated, or Superseded by ADR-NNNN.
- **Context**: the problem and the forces at play.
- **Decision**: what was decided.
- **Alternatives considered**: options rejected, and why.
- **Consequences**: what becomes easier or harder as a result.

## Index

| ADR | Title | Status |
|---|---|---|
| [0001](0001-kafka-status-producer-security.md) | Secure connections for the Kafka status-event producer | Accepted |
119 changes: 118 additions & 1 deletion kafka/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,121 @@ kafka.publish.producer.cache.time.ms respectively.
Task status transitions to `COMPLETED`.

The task is marked as `FAILED` if the message could not be published to
the Kafka queue.
the Kafka queue.
## Kafka Status Events

Conductor can publish task and workflow status changes to Kafka topics.

```properties
conductor.message-publisher.type=kafka
conductor.task-status-listener.type=kafka
conductor.workflow-status-listener.type=kafka
conductor.message-publisher.kafka.bootstrapServers=kafka:9092
conductor.message-publisher.kafka.taskStatusTopic=conductor-task-status
conductor.message-publisher.kafka.workflowStatusTopic=conductor-workflow-status
conductor.message-publisher.kafka.allowedTaskStatuses=COMPLETED,FAILED
```

### Security

By default the producer connects without encryption or authentication (`PLAINTEXT`).
Any [Kafka producer setting](https://kafka.apache.org/39/documentation/#producerconfigs)
can be set under `conductor.message-publisher.kafka.producer.*`, which is how SSL, mTLS,
SASL_SSL and SASL_PLAINTEXT are enabled. Examples below omit the
`conductor.message-publisher.kafka.producer.` prefix for brevity; every line needs it.

Conductor checks these settings at startup and fails to start if a value is invalid or a
keystore or truststore file is missing or unreadable. Unknown settings are logged as a warning.
`key.serializer` and `value.serializer` cannot be changed.

#### SSL (encryption, broker authenticated)

```properties
security.protocol=SSL
ssl.truststore.type=PKCS12
ssl.truststore.location=/etc/conductor/kafka/truststore.p12
ssl.truststore.password=${KAFKA_TRUSTSTORE_PASSWORD}
```

With a PEM file holding the CA certificate(s):

```properties
security.protocol=SSL
ssl.truststore.type=PEM
ssl.truststore.location=/etc/conductor/kafka/ca.crt
```

The truststore can be omitted if the broker's certificate is signed by a CA the JVM already
trusts.

#### mTLS (SSL with a client certificate)

The broker listener must have `ssl.client.auth=required`. Add a keystore to the SSL settings:

```properties
ssl.keystore.type=PKCS12
ssl.keystore.location=/etc/conductor/kafka/client.p12
ssl.keystore.password=${KAFKA_KEYSTORE_PASSWORD}
```

or, in PEM format:

```properties
ssl.keystore.type=PEM
ssl.keystore.location=/etc/conductor/kafka/client.pem
# Only when the private key is encrypted:
# ssl.key.password=${KAFKA_KEY_PASSWORD}
```

A PEM keystore file contains the private key in PKCS#8 format (`BEGIN PRIVATE KEY` or
`BEGIN ENCRYPTED PRIVATE KEY`) followed by the client certificate and any intermediate
certificates. Do not set `ssl.keystore.password` for PEM.

#### SASL_SSL (encryption, user name and password)

```properties
security.protocol=SASL_SSL
sasl.mechanism=SCRAM-SHA-512
sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required username="conductor" password="${KAFKA_PASSWORD}";
ssl.truststore.type=PEM
ssl.truststore.location=/etc/conductor/kafka/ca.crt
```

For `PLAIN`, use `sasl.mechanism=PLAIN` and
`org.apache.kafka.common.security.plain.PlainLoginModule`. `SCRAM-SHA-256` works the same way
as `SCRAM-SHA-512`.

#### SASL_PLAINTEXT (user name and password, no encryption)

```properties
security.protocol=SASL_PLAINTEXT
sasl.mechanism=SCRAM-SHA-512
sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required username="conductor" password="${KAFKA_PASSWORD}";
```

Status events, and with `PLAIN` the password, cross the network unencrypted. Use it only on a
trusted network.

#### Certificates and keys

- Certificates and keys must be files. Inline PEM settings (`ssl.keystore.key`,
`ssl.keystore.certificate.chain`, `ssl.truststore.certificates`) are not supported and
stop Conductor from starting.
- Supply passwords and `sasl.jaas.config` credentials through environment variables or a
secret store using `${...}` placeholders rather than writing them into the properties file.
- The producer reads certificates and credentials once. After renewing a certificate or
changing a password, restart Conductor.

Converting between formats with `openssl`:

```shell
# PEM key and certificate to a PKCS12 keystore
openssl pkcs12 -export -inkey client.key -in client.crt -certfile ca.crt -out client.p12

# PKCS12 keystore to a PEM keystore file (unencrypted PKCS#8 key followed by certificates)
openssl pkcs12 -in client.p12 -nocerts -nodes | openssl pkcs8 -topk8 -nocrypt > client.pem
openssl pkcs12 -in client.p12 -nokeys >> client.pem

# Older "BEGIN RSA PRIVATE KEY" files to PKCS#8
openssl pkcs8 -topk8 -nocrypt -in client.key -out client-pkcs8.key
```
2 changes: 2 additions & 0 deletions kafka/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ dependencies {
testImplementation project(':conductor-test-util')
testImplementation project(':conductor-test-util').sourceSets.test.output
testImplementation "redis.clients:jedis:${revJedis}"
testImplementation "org.testcontainers:testcontainers:${revTestContainer}"
testImplementation "org.testcontainers:junit-jupiter:${revTestContainer}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
package com.netflix.conductor.kafka.status.events.config;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.boot.context.properties.ConfigurationProperties;

Expand Down Expand Up @@ -51,6 +53,18 @@ public void setAllowedTaskStatuses(String allowedTaskStatuses) {
this.allowedTaskStatuses = allowedTaskStatuses;
}

/**
* Additional Kafka producer settings, e.g. {@code security.protocol}, {@code ssl.*} and {@code
* sasl.*}. Keys are Kafka producer config names.
*/
public Map<String, String> getProducer() {
return producer;
}

public void setProducer(Map<String, String> producer) {
this.producer = producer;
}

public boolean isAlwaysPublishWorkflowStatusEnabled() {
return alwaysPublishWorkflowStatusEnabled;
}
Expand All @@ -64,4 +78,5 @@ public void setAlwaysPublishWorkflowStatusEnabled(boolean alwaysPublishWorkflowS
private String bootstrapServers = "";
private String taskStatusTopic = "conductor-task-status";
private String workflowStatusTopic = "conductor-workflow-status";
private Map<String, String> producer = new HashMap<>();
}
Loading
Loading