Skip to content

dr.secure keys

The core-credentials Secret holds two dr.secure keys:

  • drsecurekey: DataRobot uses this key to encrypt credentials, secure configurations, and other secrets that it stores in MongoDB. Set it with the core.services.core.drsecurekey value.
  • asymmetrickey: No DataRobot service reads or writes data with this key, but the Secret must still contain it. Set it with the core.services.core.asymmetrickey value.

FIPS 140-3 requires that keys are generated by an approved random bit generator (DRBG) in a FIPS 140-3 validated module running in approved mode. A dr.secure key from any other source doesn't meet that requirement, even if it has the right format. For the sources that meet it and the ones that don't, see Supply your own keys.

This page covers:

Key generation on a new installation

When global.fips.enabled is true, the DataRobot Helm chart doesn't generate dr.secure keys itself. It creates the core-credentials Secret with only the keys you supply. It then runs a drsecure-fips-keygen Job that adds each missing key:

  • The Job runs in the DataRobot runtime image and generates each key with dr.secure under the OpenSSL FIPS provider. It loads the FIPS OpenSSL configuration itself, so the keys come from the FIPS provider even if global.fips.selfTest.enforce is false.
  • Before generating a key, the Job checks that OpenSSL runs in FIPS mode, and that both AES-256-GCM and the DRBG behind the key come from the fips provider. If any check fails, the Job generates nothing.
  • The Job generates aesgcm256 keys and never logs key material.
  • The Job adds only missing keys. It never replaces a key that you supplied in core.services.core.drsecurekey or core.services.core.asymmetrickey, or a key that's already in the Secret.
  • Pods that mount the core-credentials Secret wait in the ContainerCreating state until the Job has stored the keys.

The Job runs only while a key is missing. Its name includes the Helm release revision, for example drsecure-fips-keygen-1. Once drsecurekey and asymmetrickey are both in the Secret, later upgrades don't run the Job again and remove it.

If the installation is managed by Argo CD, the Job is an Argo CD Sync hook. Argo CD renders the chart without access to the cluster, so it can't see that the keys are already in the Secret, and it runs the Job on every sync. Each sync deletes the previous Job and starts a new one, which finds the keys already set and leaves them unchanged.

The Job doesn't run when an external secret store is enabled or when core.services.core.createSecret is false. In those cases, supply both keys yourself, as described in Supply your own keys.

Check the key-generation evidence

Save the Job's logs right after the installation. They're your evidence that the keys were generated inside the FIPS module. For each key it generates, the Job logs the module and DRBG that generated the key. The next helm upgrade or Argo CD sync deletes the Job and its logs.

kubectl -n ${NAMESPACE} get jobs | grep drsecure-fips-keygen
kubectl -n ${NAMESPACE} logs job/drsecure-fips-keygen-<revision>

Each generated key produces a line similar to the following:

[datarobot-fips] generated dr.secure key core-credentials/drsecurekey (aesgcm256) inside the FIPS module: DRBG CTR-DRBG in provider fips, AES-256-GCM in provider fips, libcrypto /usr/lib/libcrypto.so.3, OPENSSL_CONF <venv>/etc/ssl/openssl-fips.cnf

A key that was already set produces the following line instead. It isn't evidence of how that key was generated—only keys the Job generates come from the FIPS module. A key that you supplied, or that was already in the Secret, keeps whatever origin it had.

[datarobot-fips] core-credentials/drsecurekey is already set; leaving it unchanged. This Job did not generate it, so this log is no evidence of how it was generated

Note

If prependReleaseName is true for the core chart, the Job and the Secret names start with the release name, for example dr-drsecure-fips-keygen-1 and dr-core-credentials.

Supply your own keys

Supply your own keys if an external secret store is enabled or core.services.core.createSecret is false. Any other installation can also supply them, with the core.services.core.drsecurekey and core.services.core.asymmetrickey values. A key you supply always takes precedence over a key the Job would generate.

Each key must meet these requirements:

  • Generated by an approved DRBG in a FIPS 140-3 validated module running in approved mode: The module doesn't have to be DataRobot's. Whoever provisions the keys is responsible for meeting this requirement.
  • An aesgcm256: key: Fernet keys can't encrypt data in FIPS 140-3 mode. A Fernet key has a fernet: prefix or no prefix. For details, see Fernet keys.

The following sources meet the first requirement:

The following sources don't meet it:

  • Terraform's random_password.
  • The DataRobot Helm chart's random generator, which generates the keys on a standard installation.
  • openssl rand on a host whose OpenSSL FIPS provider isn't active, or whose provider state is unknown. This includes macOS, whose openssl is LibreSSL, and an openssl binary in a container or toolbox, even on a host in FIPS mode.
  • A key copied from another installation, unless you have a record that it came from a source that meets the requirement.

Each source generates one key per run. To supply both keys, generate two: one for drsecurekey and one for asymmetrickey. Use an aesgcm256: key for asymmetrickey too. It's a dr.secure key like drsecurekey; its name comes from the asymmetric key pairs it used to encrypt, not from its own key type.

A key from a tool other than datarobot-drsecure-fips-keygen needs the prefix added: aesgcm256: followed by 32 random bytes in base64. Any other byte count, or bytes that are base64-encoded twice, fails the key-shape check when you run helm upgrade.

The key is a secret. The examples below write each key to a file that only the current user can read, instead of printing it, so that it doesn't end up in shell history, terminal output, or CI logs. Move the key from the file into your values file or secret store, then delete the file.

Generate a key with openssl

The FIPS mode of the host's kernel (/proc/sys/crypto/fips_enabled contains 1) doesn't prove that a given openssl uses the FIPS provider. An openssl in a container or toolbox, or one run with a custom OPENSSL_CONF, can run without it. Check the provider with the same openssl binary and environment that generates the key:

openssl list -providers

The output must list the fips provider with status: active. If it also lists the default provider, openssl rand can take its random bytes from the default provider instead; use a configuration that loads only the fips and base providers, or that sets default_properties = fips=yes.

Then generate the key:

(umask 077; printf 'aesgcm256:%s' "$(openssl rand -base64 32)" > drsecurekey.txt)

Generate a key with AWS KMS

Request exactly 32 bytes. The Plaintext output of the AWS CLI is already base64, so don't encode it again:

(umask 077; printf 'aesgcm256:%s' "$(aws kms generate-random --number-of-bytes 32 --query Plaintext --output text)" > drsecurekey.txt)

In AWS GovCloud (US), use the KMS FIPS endpoint, for example by adding --endpoint-url https://kms-fips.us-gov-west-1.amazonaws.com.

Keep a record of how each key was generated

DataRobot keeps evidence only for keys that the drsecure-fips-keygen Job generates. For a key you supply, keep your own record of which module generated it:

  • datarobot-drsecure-fips-keygen: the evidence line that the command prints to standard error.
  • openssl rand: from the host and environment that generated the key, the output of openssl list -providers and openssl version, and the content of /proc/sys/crypto/fips_enabled.
  • AWS KMS: the AWS CloudTrail GenerateRandom event for the request, which records the time, the caller, and the endpoint.

Generate a key inside the FIPS module

The datarobot-drsecure-fips-keygen --print-key command generates one aesgcm256 dr.secure key with the same checks as the drsecure-fips-keygen Job. It doesn't read or change any Secret. It prints the key to standard output, and the evidence line to standard error:

[datarobot-fips] generated dr.secure key for stdout (aesgcm256) inside the FIPS module: DRBG CTR-DRBG in provider fips, AES-256-GCM in provider fips, libcrypto /usr/lib/libcrypto.so.3, OPENSSL_CONF <venv>/etc/ssl/openssl-fips.cnf

Run the command in a pod that uses the DataRobot runtime image of the FIPS 140-3 release, on a node that runs in FIPS mode. The command loads the FIPS OpenSSL configuration itself, so it works even if global.fips.selfTest.enforce is false.

On an installation that's already running, use an app pod. Replace <pod-suffix> with the unique hash of a running mmapp-app pod:

kubectl exec -n ${NAMESPACE} mmapp-app-<pod-suffix> -- bash -c "sbin/datarobot-drsecure-fips-keygen --print-key" 2> drsecure-keygen-evidence.txt

Before the first installation, when no DataRobot pod exists yet, start a temporary pod from the core chart's image instead, with the image pull secret your installation uses, and run /entrypoint datarobot-drsecure-fips-keygen --print-key in it.

The command exits with the same codes as the Job (see Troubleshoot the key-generation Job) and prints no key when a check fails. Keep the evidence line as your record of which module generated the key. The key itself is a secret; don't store it in shell history or logs.

Troubleshoot the key-generation Job

If pods stay in the ContainerCreating state on a new installation, check the status and logs of the drsecure-fips-keygen-<revision> Job. The Job retries up to three times (drsecureFipsKeygen.backoffLimit in the core chart).

Exit code or message Cause Action
Exit code 78, [datarobot-fips] FATAL: ... openssl-fips.cnf is missing The runtime image has no FIPS OpenSSL configuration. Check that the installation uses the FIPS images for this release.
Exit code 1, [datarobot-fips] FATAL: refusing to generate ... The FIPS provider isn't active, or the AES-256-GCM cipher or DRBG doesn't come from it. The message names the check that failed. Check that the nodes run in FIPS mode and that the installation uses the FIPS images. No key was generated.
Exit code 1, could not store keys in Secret ... The Job couldn't write the keys to the Secret, for example because another process changed it. The Job retries automatically. If all attempts fail, check the Kubernetes API error in the log.
Pod can't reach the Kubernetes API With global.networkPolicy.enabled, the network policy that applies to DataRobot pods also applies to the Job. Allow egress from DataRobot pods to the Kubernetes API server.
Pod can't authenticate to the Kubernetes API global.serviceAccount.automountServiceAccountToken is false, which removes the service account token the Job uses. Don't set global.serviceAccount.automountServiceAccountToken to false on a FIPS 140-3 installation.

To run the Job again after you fix the cause, run helm upgrade again with the same values. The upgrade removes the failed Job and creates a new one for the new release revision.

If the installation is managed by Argo CD, sync again instead. The release revision is always 1 under Argo CD, so the Job keeps the name drsecure-fips-keygen-1, but each sync deletes the previous Job and starts a new one.

Rotate dr.secure on an existing installation

An existing installation that turns on FIPS 140-3 mode keeps the dr.secure key it was installed with. That key wasn't generated by an approved DRBG in a validated module. FIPS 140-3 key generation calls for a key that was, so DataRobot recommends rotating to one, as described in Supply your own keys. Whether to rotate is your decision, except for a Fernet key, which needs rotation before FIPS 140-3 mode can encrypt with it (see Fernet keys). Rotation makes the new key the encryption key, keeps the old key for decryption only, re-encrypts the stored data with the new key, and then removes the old key.

Rotation applies to drsecurekey only. Rotating asymmetrickey isn't required, because no DataRobot service reads or writes data with it.

Keys that the key-generation Job generated

This procedure doesn't rotate a drsecurekey that the drsecure-fips-keygen Job generated. Rotating a Job-generated key through the Helm values isn't supported. The Job lists each key it generates in the datarobot.com/drsecure-fips-generated-keys annotation of the core-credentials Secret. To check whether it lists drsecurekey, run:

kubectl -n ${NAMESPACE} get secret core-credentials \
    -o jsonpath='{.metadata.annotations.datarobot\.com/drsecure-fips-generated-keys}'

If the output includes drsecurekey, a helm upgrade that sets replaceDrsecurekey to true fails when Helm renders the chart, before it changes anything, with this error:

services.core.replaceDrsecurekey is set, but the drsecurekey in core-credentials was generated by the drsecure-fips-keygen Job: rotating a Job-generated dr.secure key is not supported through Helm, because the rendered replacement would be deleted from the Secret by a later upgrade or rollback

Helm never renders a Job-generated key, which keeps it in the Secret through upgrades and rollbacks. A replacement key would be rendered, while the annotation still marks drsecurekey as Job-generated, so a later upgrade without replaceDrsecurekey, or a rollback, would delete it from the Secret.

Instead, leave replaceDrsecurekey unset, or set it to false, and keep the key. The Job generated it inside the FIPS module, so it already meets the FIPS 140-3 key-generation requirement and doesn't need this rotation.

If the installation is managed by Argo CD, the chart can't read the existing Secret, so it doesn't run this check. Don't set replaceDrsecurekey for a Job-generated key there either.

Check the current key type

To print the type prefix of the current key without printing the key itself, run:

kubectl -n ${NAMESPACE} get secret core-credentials -o jsonpath='{.data.drsecurekey}' | base64 -d | cut -s -d: -f1

The command prints aeshex256, aesgcm256, or fernet. Empty output means the key has no prefix, which makes it a Fernet key.

Fernet keys

If your installation has a Fernet dr.secure key, rotate it before you turn on FIPS 140-3 mode or in the same helm upgrade that sets global.fips.enabled to true. To rotate it, make a new aesgcm256: key current, as described in Step 2.

Older installations can have a Fernet key—a key with no type prefix or with a fernet: prefix. Fernet isn't an approved FIPS 140-3 encryption scheme. In FIPS 140-3 mode, a Fernet key can still decrypt existing data, but encrypting with it fails. Until you rotate the key, DataRobot can't save new credentials or secure configurations, and it returns a FipsModeError:

FIPS mode is enabled and the dr.secure encryption key is a Fernet key (a key with no type prefix, or a 'fernet:' key). Fernet is not an approved FIPS 140-3 encryption scheme, so a Fernet key can only decrypt existing data. Make an 'aesgcm256:' key the encryption key and keep this key as an additional decryption key.

aeshex256: and aesgcm256: keys keep working in FIPS 140-3 mode, so rotating them is optional. If one wasn't generated by an approved DRBG in a validated module, DataRobot recommends rotating it to meet the FIPS 140-3 key-generation requirement.

Before you begin

Prepare the following before starting the rotation:

  • Back up the database and the secrets. See Back up secrets. A backup taken before the rotation can only be restored with the old key, so keep the old key with it.
  • Read the old key. Save the decoded value of the current key, referred to here as OLD_DRSECURE_KEY:

    kubectl -n ${NAMESPACE} get secret core-credentials -o jsonpath='{.data.drsecurekey}' | base64 -d
    
  • Generate the new key, referred to here as NEW_DRSECURE_KEY, from a source that meets the requirements in Supply your own keys, for example with datarobot-drsecure-fips-keygen --print-key, as described in Generate a key inside the FIPS module. Keep the record of how it was generated, as described in Keep a record of how each key was generated.

Both keys are secrets. Store the values file that holds them with the same care as the core-credentials Secret. While drsecurePreviousKeys lists the old key, Helm stores it in the datarobot-secrets Secret and in every Helm release revision created during that time. Step 6 removes it from the release history.

Note

If prependReleaseName is true for the core chart, the Secret is named <release>-core-credentials. Use that name in the commands on this page. The checks that replaceDrsecurekey runs in Step 2 compare against that Secret. If it doesn't exist yet, the chart starts from the key in the core-credentials Secret of the same namespace instead.

Each entry in drsecurePreviousKeys, and the new drsecurekey, must be shaped like a dr.secure key, or the helm upgrade fails:

  • aesgcm256: followed by 44 base64 characters. Both the standard and the URL-safe base64 alphabets are accepted.
  • aeshex256: followed by 64 hexadecimal digits.
  • A 44-character Fernet key, with or without the fernet: prefix.

During the rotation, the DataRobot chart writes the previous keys to the datarobot-secrets Secret as DRSECURE_MONGO_PREVIOUS_ENCRYPTION_KEYS. Pods read the previous keys only when they start. The current key works differently: running pods pick up a new drsecurekey from the core-credentials Secret within about a minute, without a restart. Restart every DataRobot deployment after each helm upgrade in the procedure, so that every pod has the current list of previous keys:

kubectl -n ${NAMESPACE} rollout restart deployment

Wait until the restarted pods are ready before continuing to the next step.

Step 1: Let every pod read both keys

List the new key and the old key, in that order, as previous keys, and run helm upgrade with the same chart version:

core:
  services:
    core:
      drsecurePreviousKeys:
        - NEW_DRSECURE_KEY
        - OLD_DRSECURE_KEY

Restart every DataRobot deployment. A pod ignores whichever listed key is the current key, so every pod still encrypts with the old key, and can now also decrypt data written with the new key.

This step keeps the rotation free of errors. In Step 2, running pods switch to the new key before they restart, but keep the list of previous keys they started with. Because that list already holds both keys, a pod that switched still decrypts data written with the old key, and a pod that hasn't switched yet decrypts data written with the new key.

Step 2: Make the new key current

Set the new key as the current key, and keep both keys as previous keys:

core:
  services:
    core:
      drsecurekey: NEW_DRSECURE_KEY
      replaceDrsecurekey: true
      drsecurePreviousKeys:
        - NEW_DRSECURE_KEY
        - OLD_DRSECURE_KEY

Listing only OLD_DRSECURE_KEY in drsecurePreviousKeys also works.

Value Purpose
core.services.core.drsecurekey The new key. On an existing installation, this value is ignored unless replaceDrsecurekey is true.
core.services.core.replaceDrsecurekey Replaces the key in the existing core-credentials Secret with drsecurekey.
core.services.core.drsecurePreviousKeys Keys used only to decrypt data that the current key doesn't decrypt yet. A list; defaults to []. The current key is ignored if it's listed.

Run helm upgrade, then restart every DataRobot deployment. If the installation is turning on FIPS 140-3 mode in this upgrade, include the FIPS 140-3 values in the same helm upgrade.

The helm upgrade fails without changing anything in these cases:

  • replaceDrsecurekey is true and drsecurekey is empty.
  • drsecurekey isn't shaped like a dr.secure key, for example because of a truncated paste.
  • The key in the core-credentials Secret isn't listed in drsecurePreviousKeys. This protects data encrypted with the old key from becoming unreadable. Leading and trailing whitespace, such as a trailing newline, is ignored in this comparison.
  • The existing core-credentials Secret has no drsecurekey item, so the key being replaced can't be checked. Restore the item from a backup of the Secret first.
  • An entry in drsecurePreviousKeys isn't shaped like a dr.secure key. The error names the entry's position in the list, not the key.

Warning

If the installation is managed by Argo CD, the chart can't read the existing core-credentials Secret, so it doesn't run the checks that compare against it. Make sure drsecurePreviousKeys lists the old key before you change drsecurekey.

If the installation uses an external secret store, or sets core.services.core.createSecret to false, change the key there instead. See External secret stores.

Step 3: Re-encrypt the stored data

The sbin/datarobot-drsecure-key-rotation command re-encrypts every stored item that only a previous key decrypts. It covers app secrets, secure configurations, credentials, compute resource credentials, and compute job secrets that are stored in MongoDB. It never overwrites an item that DataRobot changes while the command runs, and it's safe to run more than once.

Before re-encrypting, wait for jobs that started before Step 2 to finish. A pod that started before Step 2 can still encrypt with the old key.

Run the following commands in a DataRobot app pod, in order. Replace <pod-suffix> with the unique hash of a running mmapp-app pod.

  1. Report what would be re-encrypted, without writing anything:

    kubectl exec -n ${NAMESPACE} -it mmapp-app-<pod-suffix> -- bash -c "sbin/datarobot-drsecure-key-rotation reencrypt --dry-run"
    
  2. Re-encrypt the stored data:

    kubectl exec -n ${NAMESPACE} -it mmapp-app-<pod-suffix> -- bash -c "sbin/datarobot-drsecure-key-rotation reencrypt"
    
  3. Check that every stored item is on the new key:

    kubectl exec -n ${NAMESPACE} -it mmapp-app-<pod-suffix> -- bash -c "sbin/datarobot-drsecure-key-rotation verify"
    

Each command prints, for each collection, how many items are on the current key, how many are on a previous key, how many it re-encrypted, and how many no configured key decrypts, with up to 20 of their _id values. An item that's malformed counts as one that no configured key decrypts. Both reencrypt and verify exit with these codes:

Exit code Meaning Action
0 verify: every item is on the current key. reencrypt: no item is left to re-encrypt. Continue to the next command, or to Step 4 after verify.
1 verify: some items are still on a previous key. reencrypt: a process that still encrypts with the old key rewrote some items while reencrypt ran. Make sure every pod has restarted since Step 2, then run reencrypt again, then verify. Don't remove the previous keys.
2 Some items decrypt with no configured key. The output lists up to 20 of their _id values per collection. If the key that wrote them is known, add it to drsecurePreviousKeys, run helm upgrade, restart, and run reencrypt again. Removing the previous keys doesn't change these items.
3 The keys are misconfigured: the current key is missing or can't be loaded, a previous key can't be loaded, or reencrypt has no previous key to re-encrypt from. Nothing was read or written. Fix drsecurekey or drsecurePreviousKeys, run helm upgrade, restart, and run the command again.
4 Any other error, for example MongoDB is unreachable. The log shows the cause. Fix the cause and run the command again.

reencrypt --dry-run doesn't exit with 1, because it reports items on a previous key without re-encrypting them.

If a previous key can't be loaded, DataRobot pods still start: they log an error that names the entry's position, never the key, and skip that entry. Items that only that key decrypts stay unreadable until the entry is fixed.

Step 4: Check for pods and Jobs that use the old key

A passing verify isn't enough on its own. A pod or Job that started before Step 2 can still encrypt with the old key, and anything it writes after verify passes becomes unreadable once the old key is removed. kubectl rollout restart deployment doesn't restart worker pods or Jobs and CronJobs that are already running.

List when each pod and Job started:

kubectl -n ${NAMESPACE} get pods --sort-by=.status.startTime \
    -o custom-columns=NAME:.metadata.name,STARTED:.status.startTime,PHASE:.status.phase
kubectl -n ${NAMESPACE} get jobs \
    -o custom-columns=NAME:.metadata.name,STARTED:.status.startTime,ACTIVE:.status.active

Every running pod and active Job must have started after the Step 2 restart. Wait for the others to finish, or delete them. Then run verify again, and continue only if it still exits with 0.

Step 5: Remove the old key

Remove the previous keys. Keep the new key as drsecurekey:

core:
  services:
    core:
      drsecurekey: NEW_DRSECURE_KEY
      replaceDrsecurekey: true
      drsecurePreviousKeys: []

Run helm upgrade, restart every DataRobot deployment, and run verify again. It must exit with 0. This upgrade also removes DRSECURE_MONGO_PREVIOUS_ENCRYPTION_KEYS from the datarobot-secrets Secret.

Leaving replaceDrsecurekey set to true with the same drsecurekey has no further effect. If you set it back to false, the installation keeps the key that's in the Secret.

Step 6: Delete Helm revisions that hold the old key

Every Helm release revision created while drsecurePreviousKeys listed the old key still stores it, in the values of that revision. This includes every revision from Step 1 up to, but not including, the Step 5 upgrade. Do this step only after Step 5, when verify exits with 0: once these revisions are deleted, rolling back to them isn't possible, which is the intent.

  1. List the revisions, and check which ones list the old key:

    helm -n ${NAMESPACE} history <release>
    helm -n ${NAMESPACE} get values <release> --revision <N>
    

    helm get values prints the keys in the values. Run it where its output isn't logged.

  2. Delete the release Secret of each revision that lists it. Keep the current revision:

    kubectl -n ${NAMESPACE} delete secret sh.helm.release.v1.<release>.v<N>
    
  3. Check that only the revisions you kept remain:

    kubectl -n ${NAMESPACE} get secret -l owner=helm,name=<release>
    

Setting --history-max isn't enough on its own: Helm never prunes the deployed revision, so the Step 5 upgrade keeps the revision it replaces, and that revision still holds the old key.

Helm release history isn't the only copy. Also remove the old key from the values files used during the rotation, and from wherever those files are kept, such as a Git repository or a CI system. Keep the old key only with the backups taken before the rotation.

After the rotation, back up the core-credentials Secret again. See Back up secrets.

External secret stores

When the dr.secure keys don't come from the DataRobot chart, change the current key where they're stored instead of setting replaceDrsecurekey:

  • External secret store (ESO or VSO): In Step 2, set the drsecurekey property of the core-credentials entry in the store to the new key. See External secrets. Wait until the operator has synced the core-credentials Secret before restarting.
  • core.services.core.createSecret set to false: In Step 2, set the drsecurekey item of your core-credentials Secret to the new key.

The chart doesn't check the key change on these installations, so make sure drsecurePreviousKeys lists the old key before you change drsecurekey.

Previous keys are kept in Helm values only

The external secret store holds only the current key. Previous keys can't be read from it, or from a core-credentials item, so in both cases you still set core.services.core.drsecurePreviousKeys in the Helm values, as in the procedure. While the old key is listed, it's stored in the datarobot-secrets Secret and in every Helm release revision created during that time, even though the store holds the current key. The Step 5 upgrade removes it from the datarobot-secrets Secret. Do Step 6 to remove it from the Helm release history and from your values files.