Skip to content

[2.0] Fixes #28299: encrypt the connection secrets that are still saved in plain text - #38118

Merged
Khairajani merged 24 commits into
2.0from
secrets-remaining-converters-2.0
Nov 20, 2026
Merged

Khairajani merged 24 commits into
2.0from
secrets-remaining-converters-2.0

Conversation

@Khairajani

@Khairajani Khairajani commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #28299

[2.0] backport of #38117, #37565 (and #38190, now part of #38117), follow-up to #37962.

Changes

Tests

  • All org.openmetadata.service.secrets tests pass, plus ReflectionUtilCollectionKeysTest.
  • McpServiceResourceIT passes, including the rename and duplicate name cases.
  • SecretsManagerUpdateSoftDeletedIT checks that a soft-deleted service and workflow holding a plain text password are stored encrypted after the update.
  • Python unit tests for the changed connectors: same results as origin/2.0.

End-to-end test: 2.0.7 upgraded to this branch (MySQL, ES 9.3)

  • On 2.0.7, seeded 248 services with a unique marker in each of 632 secret fields, plus a Test Connection workflow each. Soft-deleted 4 services and their workflows before the upgrade.
  • Before the upgrade, 264 plain text fields in current services and 264 in workflows.
  • migrate exited 0 with no failed updates. Only the OpenMetadata service's securityConfig.jwtToken is left in plain text, by design (DO_NOT_ENCRYPT_CLASSES).
  • The ingestion bot reads every secret of all 248 services back with its original value, including the soft-deleted ones. The admin sees every secret masked.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 4/5

The latest changes introduce no new blocking behavior, but earlier repository-rule findings still need to be addressed before merging.

Findings

  1. P2 New interfaces use forbidden types. ▶
  2. P2 New cache has no limit. ▶
  3. P2 Unchanged locals lack required final. ▶

Summary

This PR expands encryption and masking for connection secrets, including nested settings and MCP server lists.

  • Nested connection settings now reach the secret-encryption path.
  • MCP server keys stay with their servers when the list changes.
  • migrate updates stored workflows and soft-deleted records too.
  • AWS session tokens and Fivetran API keys now use password fields.

Reviews (18) · Last reviewed commit: "Five parameters at most in the masker wa..." · Reviewed by Greptile

- SSIS: type databaseConnection through the MSSQL converter, so its sslConfig
  and authType are typed and encrypted.
- Qlik Sense certificates: its oneOf branches were inline definitions, which
  jsonschema2pojo generates no class for; move them to their own schema files
  (titles unchanged) and register a converter.
- migrate now re-encrypts stored workflows (Test Connection requests) the way
  it does services; the unused updateWorkflow also saved through the wrong DAO.
- The coverage test also checks typed connection properties whose own oneOf
  holds secrets, which is how SSIS slipped through.
@Khairajani
Khairajani requested review from a team as code owners November 18, 2026 12:31
@Khairajani
Khairajani requested review from ShaileshParmar11, harshsoni2024 and pmbrull and removed request for a team November 18, 2026 12:31
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

Its oneOf branches were inline definitions with no generated class; move them
to dashboard/sapS4Hana/{basicAuth,oAuthCredentials}.json (titles and javaTypes
unchanged) and register a converter. KNOWN_UNCONVERTIBLE is now empty.

The generated Python classes move with them: Collate's SAP S/4HANA connector
imports them, so it needs the matching import change.
Backport of the secrets part of #33477: the masker and the secrets manager
now walk lists, so mcpConnection.servers[].apiKey is masked and encrypted, and
awsSessionToken, Fivetran apiKey and GCP privateKeyId are password fields; the
ingestion code that reads them unwraps the SecretStr.
Both sat below a oneOf whose branches had no generated class, so they were
saved in plain text and returned unmasked to editors.

- dataStorageConfig moves out of connectionBasicType.json into its own schema;
  the converter factory wraps every connection that carries a
  sampleDataStorageConfig so its config, and the S3 credentials in it, are
  typed after the connection's own converter runs.
- Delta Lake's metastore connection branches move to deltalake/metastore/*.json
  and get a converter. configSource tries StorageConfig first: both accept a
  connection, but only StorageConfig rejects the other kind.
- The ingestion code imports the moved classes from their new modules.
- KNOWN_UNCONVERTIBLE is now empty.
- The new Qlik Sense and SAP S/4HANA schema files use draft-07, like 2.0.
…split rule

# Conflicts:
#	openmetadata-service/src/test/java/org/openmetadata/service/secrets/converter/NestedSecretConverterCoverageTest.java
*/
prefix?: string;
storageConfig?: AwsCredentials;
[property: string]: any;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 New interfaces use forbidden types. The added index signature uses any, contrary to the repository directive “NEVER use any type” and its instruction to use unknown for unknown values. The same pattern appears in the new Qlik certificate interfaces. Update the generated output and its source so regeneration keeps the required types.

Context Used: CLAUDE.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!


@Getter private static final Map<Class<?>, ClassConverter> converterMap;

private static final Map<Class<?>, Boolean> SAMPLE_DATA_HOLDERS = new ConcurrentHashMap<>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 New cache has no limit. SAMPLE_DATA_HOLDERS caches results in a bare ConcurrentHashMap. The repository requires every cache to have an explicit size cap. Use a bounded cache or remove this cache.

Context Used: CLAUDE.md (source)

Comment on lines +201 to +202
PASSWORD_MASK.equals(value)
? passwordsMap.getOrDefault(fieldKey, PASSWORD_MASK)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On 2.0 this now masks MCP servers[].apiKey, and on save each masked value is matched to its stored secret by server name. When no stored secret matches, getOrDefault keeps *********, and that is saved as the key.

How to hit it, with the key left masked in the form each time:

  • rename a server
  • delete one of two servers with the same name
  • add a second server with a name that already exists

Impact: the save succeeds, and the connector then sends ********* to the MCP server and fails to authenticate. Before this PR the key came back in plain text, so a save never lost it.

On main, PR #37565 covers this case: it rejects a masked value with no stored secret, and it requires unique server names. That PR is not on 2.0.

Comment on lines +121 to +122
boolean usable = name != null && occurrences.get(name) == 1;
keys.add(usable ? name : POSITION_KEY_PREFIX + index);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A position key (#<index>) can equal a real server name. With server names ["#1", "dup", "dup"] the keys are #1, #1, #2. The first two collide, which the comment on line 34 says cannot happen.

Impact: after a save with masked values, server #1 ends up with the first dup server's key, and its own key is lost.

"oneOf": [
{
"$ref": "#/definitions/sapS4HanaBasicAuthType"
"$ref": "sapS4Hana/basicAuth.json"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving these branches changes the generated Python modules. Collate's 2.0 branch still imports SapS4HanaBasicAuthType and SapS4HanaOAuthType from sapS4HanaConnection (ingestion-extension/.../saps4hana/client.py, lines 27 and 29). So once this merges, the SAP S/4HANA connector on Collate 2.0 fails at import. PR #8684 makes that change on main only, and there is no 2.0 version yet.

…#37565)

* fix(mcp): validate MCP service server names and masked values on save

An MCP service's servers are matched to their stored settings by name.
Require server names to be unique, and refuse a masked value that has
no stored value under the same server (e.g. after a rename), so the
caller is asked to enter it again instead of the placeholder being kept.

* fix(mcp): check server names whenever a service's servers change

The unique-name check now runs when the servers list differs from the
stored one in anything but the keys, order included, not only when the
names change. A service saved with repeated server names keeps saving
edits outside its servers.

(cherry picked from commit 58f1774)
Comment on lines +48 to +49
String serviceId = softDeletedServiceWithPlainPassword(ns);
String workflowId = softDeletedWorkflowWithPlainPassword(ns);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Unchanged locals lack required final. The new test declares serviceId and workflowId without final, although neither is reassigned. The repository requires final on locals and parameters that do not change. The same pattern appears in the new elementKeys() helper and elsewhere in the added code.

Context Used: CLAUDE.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

A position id moved when servers were reordered, so replacing or clearing one key wrote over, or deleted, the secret the other server still referenced. Such names now get an id from a hash of the exact name.
Comment on lines +44 to +45
"type": "string",
"format": "password"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On main, #33477 was followed by #33889, which made privateKeyId a plain string again: it is not a secret (Google shows key IDs to anyone with read-only Viewer access; the secret is privateKey, which is already encrypted), and as a password field it also has to be stored in the secrets manager when ingestion runs on a Hybrid Runner.

This backport brings #33477 without #33889. So 2.0.9 would save privateKeyId encrypted, and after the upgrade 2.1 would not decrypt it. I ran the 2.1.0-rc2 server code on a BigQuery connection saved this way: privateKey comes back decrypted, but privateKeyId stays fernet:..., both in the config sent to ingestion and in the API response.

Suggestion: including #33889 in the backport keeps 2.0 in line with main:

Suggested change
"type": "string",
"format": "password"
"type": "string"

"type": gcp_values.type,
"project_id": project_id,
"private_key_id": gcp_values.privateKeyId,
"private_key_id": gcp_values.privateKeyId.get_secret_value() if gcp_values.privateKeyId else None,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ingestion side of #33889, so privateKeyId is read as a plain string, like main:

Suggested change
"private_key_id": gcp_values.privateKeyId.get_secret_value() if gcp_values.privateKeyId else None,
"private_key_id": gcp_values.privateKeyId,

Comment on lines 25 to 27
from metadata.generated.schema.entity.services.connections.dataStorageConfig import (
DataStorageConfig,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

py-checkstyle fails on this import order (ruff I001). Moving this dataStorageConfig import below the database.datalakeConnection one, or running make py_format, fixes it; the rest of the tree then passes.

Khairajani and others added 3 commits November 19, 2026 18:59
* Revert privateKeyId from password format back to plain string

an identifier, not a secret; restore it to a plain string in the spec,
the generated UI schemas, and build_google_credentials_dict.

* Update generated TypeScript types and dereferenced schemas

---------

Co-authored-by: Rohit Jain <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…d or moved

A save kept an existing secret reference, so a renamed MCP server still read its old name's secret and a server later added under that name overwrote it. Before a list is written, a reference to another element's secret is read back into its value and stored under the element's own id. A reference that cannot be read is kept.
A move read every source first, which protects a save that succeeds; one that failed part way could leave a server reading another's key. The value at the element's own id is now read as well and written back if the save fails, and a refused value is rejected before any key moves.
@gitar-bot

gitar-bot Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 🔴 High risk 3 closed / 3 findings

The secrets migration re-encrypts credentials across services and workflows, changing stored-data protection; incorrect conversion could expose secrets or break credential access.

Encrypts and masks connection secrets still stored in plain text, including SSIS database connections, Qlik Sense and SAP S/4HANA oneOf branches, MCP server API keys, and sample-data storage configs. Renaming a collection element no longer drops its masked secret, names differing only by case get distinct secret ids, and restoring a newly created moved secret no longer blocks Azure retries. No open issues found.

✅ 3 closed
✅ Edge Case: Renaming a collection element drops its masked secret

📄 openmetadata-service/src/main/java/org/openmetadata/service/util/ReflectionUtil.java:108-122 📄 openmetadata-service/src/main/java/org/openmetadata/service/secrets/masker/PasswordEntityMasker.java:196-205 📄 openmetadata-service/src/main/java/org/openmetadata/service/secrets/masker/PasswordEntityMasker.java:251-260
getCollectionElementKeys now uses an element's name as its key. On unmask, buildPasswordsMap keys the original's secrets by the old name, and unmaskPasswordFields looks them up under the edited name with getOrDefault(fieldKey, PASSWORD_MASK). If a user renames an MCP server and leaves its API key masked, the lookup misses and the literal ********* gets saved as the key. The original secret is lost without any error.

The key can also change without a rename. If a second server called alpha is added next to an existing alpha, both fall back to #0/#1, so the existing masked key no longer matches alpha. Deleting one of two servers that share a name does the same in reverse: the survivor goes from #1 back to alpha.

Fix: when the identity key misses, fall back to the positional key from the original collection, or reject a masked value that cannot be resolved instead of saving the mask. Add a test that renames a server.

✅ Bug: Names differing only by case share one external secret id

📄 openmetadata-service/src/main/java/org/openmetadata/service/util/ReflectionUtil.java:111-123 📄 openmetadata-service/src/main/java/org/openmetadata/service/secrets/SecretsManager.java:497-507 📄 openmetadata-service/src/main/java/org/openmetadata/service/secrets/SecretsManager.java:611-625
getCollectionElementKeys checks name uniqueness case-sensitively, so Prod and prod both count as unique keys. buildSecretId then cleans each part with secretIdPattern and lowercases the whole id, so both servers' apiKey end up under the same secret id in a managed secrets manager (AWS, Azure, etc.). The second write overwrites the first, both servers decrypt to the same key, and deleting one service removes the secret the other still uses. The same collision happens with names that are equal once the pattern strips special characters.

Fix: check uniqueness against the normalised form (lowercased and cleaned the same way buildSecretId does) and fall back to position on any collision.

✅ Bug: Restoring a newly created moved secret by deleting it blocks Azure retries

📄 openmetadata-service/src/main/java/org/openmetadata/service/secrets/ExternalSecretsManager.java:162-169 📄 openmetadata-service/src/main/java/org/openmetadata/service/secrets/SecretsManager.java:507-510 📄 openmetadata-service/src/main/java/org/openmetadata/service/secrets/SecretsManager.java:596-610
When a move writes to an element id that did not exist yet (previous is empty), a failed save makes restoreMovedSecret call deleteSecretInternal. On Azure Key Vault that is beginDeleteSecret, which soft-deletes the secret. Soft-delete is always on, so the name stays reserved until it is purged. The stored entity still holds the old cross-element reference, so the next save tries the same move to the same id. readMove sees the id as not found and upsertSecret then calls setSecret on the soft-deleted name, which Azure rejects with a 409 Conflict. The service cannot be saved again until the secret is purged or the retention period ends. To fix this, don't delete in this case: leave the created secret in place, since nothing references it yet and the retry will overwrite it. Alternatively, purge after deleting on providers that soft-delete.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@Khairajani
Khairajani requested a review from manerow November 20, 2026 07:38
@Khairajani
Khairajani merged commit 0e20894 into 2.0 Nov 20, 2026
77 of 86 checks passed
@Khairajani
Khairajani deleted the secrets-remaining-converters-2.0 branch November 20, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants