Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
06859f8
alerts: keep destination endpoint, header values and credentials encr…
TeddyCr Oct 24, 2026
303165f
fix(alerts): address destination secret handling regressions
TeddyCr Oct 26, 2026
23228fb
fix(alerts): preserve distinct destinations and unrelated patch values
TeddyCr Oct 26, 2026
e671684
fix: address automated review findings (cycle 1)
TeddyCr Oct 27, 2026
d14c2b0
Merge remote-tracking branch 'upstream/main' into fix/alert-destinati…
TeddyCr Oct 27, 2026
007a988
fix(alerts): a PATCH that moves a destination's target must write eve…
TeddyCr Oct 27, 2026
c983f5d
fix(alerts): a PATCH may not carry a stored secret into a channel tha…
TeddyCr Oct 28, 2026
70c0fa5
Merge remote-tracking branch 'upstream/main' into fix/alert-destinati…
TeddyCr Oct 28, 2026
bbe9ddc
fix(alerts): resolve masked destinations on the template test send an…
TeddyCr Oct 29, 2026
d4a1264
Merge remote-tracking branch 'upstream/main' into fix/alert-destinati…
TeddyCr Oct 29, 2026
a52f892
fix(alerts): keep the destination id on a template test send
manerow Oct 29, 2026
5c49a33
Merge main into fix/alert-destination-secret-handling
manerow Oct 31, 2026
6227d40
Merge main into fix/alert-destination-secret-handling
manerow Oct 31, 2026
1bb2bda
test(alerts): send the test destination as a client reads it
manerow Nov 1, 2026
7b11df6
Merge main into fix/alert-destination-secret-handling
manerow Nov 1, 2026
df1eab9
fix(alerts): tighten destination secret checks on patch and test send
manerow Nov 1, 2026
84fe08f
fix(alerts): mask destination configs on every read and event path
manerow Nov 1, 2026
070b54d
revert(alerts): keep unregistered-channel destination configs as main…
manerow Nov 1, 2026
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# An alert destination's endpoint, header values and credentials are encrypted at rest, masked in every response, and restored from the stored alert when the mask is sent back

- **Status:** Accepted
- **Revisions:** v1 2026-10-23 (initial); v2 2026-10-26 (bind stored OAuth2 test credentials to their token URL); v3 2026-10-27 (a stored secret does not follow a moved target; a destination keeps its served channel); v4 2026-10-27 (a PATCH that moves a target must itself write every secret, since a row stored in plaintext reads as entered); v5 2026-10-28 (a PATCH may not carry a stored value into a channel that does not name it a secret); v6 2026-10-29 (a receivers list is a target; a template send resolves masks as a test send does)
- **Deciders:** Teddy Crepineau
- **Guard:** `DestinationSecretsTest`, `DestinationSecretGuardsTest`, `EventSubscriptionResourceIT#test_destinationSecretsAreMaskedEncryptedAndRestored`, `EventSubscriptionResourceIT#test_patchCannotCarryAStoredSecretIntoAChannelThatDoesNotMaskIt`, `EventSubscriptionResourceIT#test_receiversCannotRedirectStoredCredentials`, `TemplateTestSendIT`
- **Related:** ADR:2026-10-20-mcp-responses-mask-stored-credentials

## Context

A webhook destination's configuration is read by anyone who may view the alert. The bearer and
OAuth2 credentials were stored encrypted, but an incoming-webhook URL (Slack, Teams, Google Chat
and many generic webhooks) is itself the credential, and a custom header is where an
`Authorization` or API-key value goes. Both were stored and returned as written. The governance
workflow sinks already follow a complete model (`WorkflowDefinitionMasker`, `WorkflowSinkSecrets`):
encrypt before the store, mask on every read, restore the stored value when a caller sends the
mask back, decrypt only at the point of use.

## Decision

- A channel names its secrets in one place, `ConfigRules.secretFields`. For every webhook-family
channel (`SecretWebhookConfigRules`) that is the `endpoint`, every value under `headers`, and
`authType.secretKey`, `authType.clientId`, `authType.clientSecret`. `queryParams` and a
destination's `receivers` are not secrets.
- `DestinationSecrets` encrypts those fields before an alert is stored (create and every update
path, before the diff, so the change description holds ciphertext too), decrypts them only where
a configuration is read to send (`WebhookConfigRules.stored` / `submitted`), and masks them with
`PasswordEntityMasker.PASSWORD_MASK` in every response of `EventSubscriptionResource` and of the
MCP tools — for every caller, bots included — including version history and change descriptions.
- A request that sends the mask back keeps the stored value: by destination id, or, for a PUT that
carries no ids, by position when type and channel match. A plaintext secret equal to what the
stored ciphertext decrypts to keeps the stored ciphertext, so re-sending a configuration changes
nothing. A mask with no stored value, ciphertext that is not the stored value, and a PATCH `copy`
or `move` of a stored secret into another field are refused with 400.
- A test send of a destination that carries masks uses the stored secrets, only for a caller
allowed to edit the alert that holds them, and only when every secret and the OAuth2 token URL
are the stored ones; a destination whose credentials or token URL changed is tested once all
credentials are entered. `testDestination` and `POST /v1/notificationTemplates/send` resolve a
destination the same way (v6:2026-10-29), so a template can be test-sent to an existing alert's
destination read back as it is.
- A stored secret is restored from the mask only while the destination still sends where it is
stored: its `endpoint` and, for OAuth2 credentials, `tokenUrl`. A request (v3:2026-10-27) that
moves either, and keeps any stored or masked value at another secret field, is refused with 400
and asked to enter every credential again — a caller who only ever read the mask may not choose
where someone else's credentials are delivered. Re-entering every secret, the stored values
included, moves the destination as it reads them fresh. A PATCH is applied to the alert as
stored, so on a row stored before this change (v4:2026-10-27) it carries the plaintext of every
secret it does not write, which by value reads as entered; the patch is replayed on the stored
alert with a marker at every secret, and a destination whose target moved is refused unless the
patch wrote each of its secrets. A PUT carries only what its caller typed, since reads are masked.
(v6:2026-10-29) Each entry of a destination's `receivers` list replaces the endpoint at send
time and is sent the same headers and credentials, so a receivers list is a target too: a
request that changes it, and keeps any stored or masked value at another secret field, is
refused the same way.
- A destination an update keeps by its id serves through the channel it is stored under; the
update that names another channel is refused, since the channel's rules would no longer name
the secrets its configuration carries. A replacement destination carries a new id and chooses
its channel when it is added. A PATCH is applied to the alert as stored, so replacing a
destination's id or type keeps its configuration while changing the channel that judges it;
(v5:2026-10-28) the patch must then write every value the stored channel named a secret, or the
value would be stored and read back as written. A whole-list replacement writes every field and
is judged by value.
- Changed destinations are compared with their secrets decrypted, so a stored destination an
earlier release accepted is still not re-validated when the alert is otherwise edited; a
destination the users do not configure (`Owners`, `Teams`, …) is judged from its configuration
as it would be sent, decrypted, so an update of one stays editable while its endpoint sits
encrypted at rest.

## Consequences

- The alert form and the SDK round-trip an alert unchanged: unchanged fields come back as the
mask and are restored. The form shows the mask where it showed the URL or header value, and a
save that changes one or more destinations sends that list in one whole-list move, so an edit
or removal of one destination is never mis-paired with its neighbour.
- Moving a destination's endpoint or token URL asks for every credential again; keeping a
destination otherwise edits it as the masks round-trip.
- A client that re-creates an alert from a read copy must supply the real values; that is the
same contract as a service connection.
- Rows stored before this change keep plaintext until their alert is next saved; reads are masked
either way. A migration encrypting existing rows is a separate change.
- A new channel with secrets implements `secretFields` and gets storage, masking and restoring
without touching the resource or repository.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@
import org.openmetadata.it.util.SdkClients;
import org.openmetadata.it.util.TestNamespace;
import org.openmetadata.schema.api.events.CreateEventSubscription;
import org.openmetadata.schema.api.policies.CreatePolicy;
import org.openmetadata.schema.api.teams.CreateRole;
import org.openmetadata.schema.api.teams.CreateUser;
import org.openmetadata.schema.entity.events.AlertType;
import org.openmetadata.schema.entity.events.EventSubscription;
import org.openmetadata.schema.entity.events.EventSubscriptionOffset;
import org.openmetadata.schema.entity.events.SubscriptionDestination;
import org.openmetadata.schema.entity.policies.Policy;
import org.openmetadata.schema.entity.policies.accessControl.Rule;
import org.openmetadata.schema.entity.teams.Role;
import org.openmetadata.schema.type.MetadataOperation;
import org.openmetadata.schema.type.Webhook;
import org.openmetadata.schema.utils.JsonUtils;
import org.openmetadata.sdk.client.OpenMetadataClient;
import org.openmetadata.service.Entity;
import org.openmetadata.service.events.consumer.AlertRows;
import org.openmetadata.service.events.consumer.ledger.LedgerKeys;
Expand All @@ -35,6 +43,37 @@ final class AlertFixtures {

private AlertFixtures() {}

/**
* A user who may create alerts and try notification templates, and may edit no alert it did not
* create.
*/
static OpenMetadataClient alertCreatorClient() {
String name = "alertcreator" + UUID.randomUUID().toString().substring(0, 8);
String email = name + "@open-metadata.org";
OpenMetadataClient admin = SdkClients.adminClient();
Rule create =
new Rule()
.withName(name + "Create")
.withOperations(List.of(MetadataOperation.CREATE))
.withResources(List.of(Entity.EVENT_SUBSCRIPTION, Entity.NOTIFICATION_TEMPLATE))
.withEffect(Rule.Effect.ALLOW);
Policy policy =
admin
.policies()
.create(new CreatePolicy().withName(name + "Policy").withRules(List.of(create)));
Role role =
admin
.roles()
.create(
new CreateRole()
.withName(name + "Role")
.withPolicies(List.of(policy.getFullyQualifiedName())));
admin
.users()
.create(new CreateUser().withName(name).withEmail(email).withRoles(List.of(role.getId())));
return SdkClients.createClient(name, email, new String[] {});
}

static SubscriptionDestination external(
SubscriptionDestination.SubscriptionType type, String endpoint) {
return new SubscriptionDestination()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,13 @@ void cascadeDeleteRemovesTheJobAndRows(TestNamespace ns) throws Exception {
@Test
void testSendLeavesLiveHealthUnchanged(TestNamespace ns) throws Exception {
EventSubscription alert = create(ns, "test_send_health", true);
SubscriptionDestination destination = alert.getDestinations().getFirst();
// Sent as a client reads it: the stored copy holds encrypted secrets a caller may not send.
SubscriptionDestination destination =
SdkClients.adminClient()
.eventSubscriptions()
.get(alert.getId().toString())
.getDestinations()
.getFirst();
String before = health(alert);
String storedBefore =
JsonUtils.pojoToJson(AlertFixtures.stored(alert.getId()).getDestinations());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.openmetadata.service.events.consumer.AbstractEventConsumer;
import org.openmetadata.service.events.consumer.AlertingSettings;
import org.openmetadata.service.events.consumer.ledger.AlertRecord;
import org.openmetadata.service.fernet.Fernet;
import org.openmetadata.service.jdbi3.CollectionDAO;

/**
Expand Down Expand Up @@ -78,6 +79,44 @@ void everyChannelReceivesEachMatchingEventOnce(TestNamespace ns) throws Exceptio
}
}

// The stored row holds ciphertext; what reaches the channel is the configuration as written.
@Test
void aDestinationIsSentToAsConfiguredWhileStoredEncrypted(TestNamespace ns) throws Exception {
try (RecordingReceiver receiver = new RecordingReceiver()) {
String headerValue = ns.prefix("header-token");
SubscriptionDestination slack =
AlertFixtures.external(SLACK, receiver.url("/slack-secret"))
.withConfig(
new Webhook()
.withEndpoint(URI.create(receiver.url("/slack-secret")))
.withHeaders(Map.of("Authorization", headerValue)));
EventSubscription alert = createAlert(ns, "dispatch_secret", List.of(slack));
QuietAlert.settle(alert);
Map<String, Object> stored =
JsonUtils.convertValue(alert.getDestinations().getFirst().getConfig(), Map.class);
assertTrue(((String) stored.get("endpoint")).startsWith(Fernet.FERNET_PREFIX));
assertFalse(JsonUtils.pojoToJson(stored).contains(headerValue));

FixtureEvents.insert(FixtureEvents.tableEvents());
DirectTick.run(alert);

List<RecordingReceiver.Received> sends =
receiver.received().stream().filter(send -> "/slack-secret".equals(send.path())).toList();
assertEquals(EVENTS_ABOUT_THE_TABLE, sends.size());
assertTrue(
sends.stream().allMatch(send -> headerValue.equals(authorizationOf(send))),
"the header is sent as written");
}
}

private static String authorizationOf(RecordingReceiver.Received send) {
return send.headers().entrySet().stream()
.filter(header -> header.getKey().equalsIgnoreCase("Authorization"))
.map(Map.Entry::getValue)
.findFirst()
.orElse(null);
}

// Every tick of this test stops after one event and runs again at once. What the ticks send
// and record together must be what one tick sends and records.
@Test
Expand Down
Loading
Loading