Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

refactor(encryption): replace kekFingerprint with kekLabel in key rotation logic

Victor Hugo dos Santos43cf445279ac
diff --git a/backend/CLAUDE.md b/backend/CLAUDE.md
index f24d34110d..28f3f8c678 100644
--- a/backend/CLAUDE.md
+++ b/backend/CLAUDE.md
@@ -458,8 +458,9 @@ rotatable, and three invariants hold that up.
`KMS_ROOT_CONFIG_UUID` is always the current one. That id is no longer "the config row", it is a
compatibility handle: an app version predating rotation looks the row up by id and knows nothing about
pending rotations or retained copies, so keeping the active key there is what lets such a version boot. New
-code never looks rows up by id — it **trial-decrypts** in a fixed order (sentinel, pending, retained), which
-is why there is no `kekFingerprint` column. Fingerprints exist only as human labels in `kms_kek_history`.
+code never looks rows up by id — it **trial-decrypts** in a fixed order (sentinel, pending, retained), so
+`kekLabel` is never a lookup key. It exists on both tables purely as a human label, derived from the key so
+an operator can recompute it and match an archived key to a backup; nothing resolves a row by it.
**A rotation is inert until a pod boots with the new key.** `POST /admin/encryption/rotations` writes a
*pending* row and does not touch the sentinel, so generating a key changes nothing and discarding it is a row
diff --git a/backend/src/db/migrations/20260819120000_kek-rotation.ts b/backend/src/db/migrations/20260819120000_kek-rotation.ts
index 7ed7de27e5..07174c0253 100644
--- a/backend/src/db/migrations/20260819120000_kek-rotation.ts
+++ b/backend/src/db/migrations/20260819120000_kek-rotation.ts
@@ -10,9 +10,9 @@ export async function up(knex: Knex): Promise<void> {
const hasActivatedAt = await knex.schema.hasColumn(TableName.KmsServerRootConfig, "activatedAt");
const hasSupersededAt = await knex.schema.hasColumn(TableName.KmsServerRootConfig, "supersededAt");
const hasLastResolvedAt = await knex.schema.hasColumn(TableName.KmsServerRootConfig, "lastResolvedAt");
- const hasKekFingerprint = await knex.schema.hasColumn(TableName.KmsServerRootConfig, "kekFingerprint");
+ const hasKekLabel = await knex.schema.hasColumn(TableName.KmsServerRootConfig, "kekLabel");
- if (!hasActivatedAt || !hasSupersededAt || !hasLastResolvedAt || !hasKekFingerprint) {
+ if (!hasActivatedAt || !hasSupersededAt || !hasLastResolvedAt || !hasKekLabel) {
await knex.schema.alterTable(TableName.KmsServerRootConfig, (t) => {
// NULL means a pending rotation nobody has booted with yet.
if (!hasActivatedAt) t.timestamp("activatedAt");
@@ -21,7 +21,7 @@ export async function up(knex: Knex): Promise<void> {
// Stamped by each instance at boot on the row its key opened. Positive evidence that an instance
// still holds that key; absence proves nothing, since an instance that never restarts never stamps.
if (!hasLastResolvedAt) t.timestamp("lastResolvedAt");
- if (!hasKekFingerprint) t.string("kekFingerprint", 64);
+ if (!hasKekLabel) t.string("kekLabel", 64);
});
}
@@ -45,11 +45,11 @@ export async function up(knex: Knex): Promise<void> {
}
// Survives the ciphertext it describes: once the GC deletes a superseded copy, this is the only
- // record tying a fingerprint to the window it was active.
+ // record tying a label to the window it was active.
if (!(await knex.schema.hasTable(TableName.KmsKekHistory))) {
await knex.schema.createTable(TableName.KmsKekHistory, (t) => {
t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid());
- t.string("kekFingerprint", 64).notNullable();
+ t.string("kekLabel", 64).notNullable();
t.timestamp("activatedAt").notNullable();
t.timestamp("supersededAt");
t.timestamp("retiredAt");
@@ -62,7 +62,7 @@ export async function up(knex: Knex): Promise<void> {
export async function down(knex: Knex): Promise<void> {
// Only the sentinel is readable by pre-rotation code, so the other rows cannot survive.
- const columns = ["activatedAt", "supersededAt", "lastResolvedAt", "kekFingerprint"];
+ const columns = ["activatedAt", "supersededAt", "lastResolvedAt", "kekLabel"];
const present: string[] = [];
for (const column of columns) {
// eslint-disable-next-line no-await-in-loop
diff --git a/backend/src/db/schemas/kms-kek-history.ts b/backend/src/db/schemas/kms-kek-history.ts
index b8542f2b5c..780494feeb 100644
--- a/backend/src/db/schemas/kms-kek-history.ts
+++ b/backend/src/db/schemas/kms-kek-history.ts
@@ -9,7 +9,7 @@ import { TImmutableDBKeys } from "./models";
export const KmsKekHistorySchema = z.object({
id: z.string().uuid(),
- kekFingerprint: z.string(),
+ kekLabel: z.string(),
activatedAt: z.date(),
supersededAt: z.date().nullable().optional(),
retiredAt: z.date().nullable().optional(),
diff --git a/backend/src/db/schemas/kms-root-config.ts b/backend/src/db/schemas/kms-root-config.ts
index d4fd09e499..a506dc1afe 100644
--- a/backend/src/db/schemas/kms-root-config.ts
+++ b/backend/src/db/schemas/kms-root-config.ts
@@ -18,7 +18,7 @@ export const KmsRootConfigSchema = z.object({
activatedAt: z.date().nullable().optional(),
supersededAt: z.date().nullable().optional(),
lastResolvedAt: z.date().nullable().optional(),
- kekFingerprint: z.string().nullable().optional()
+ kekLabel: z.string().nullable().optional()
});
export type TKmsRootConfig = z.infer<typeof KmsRootConfigSchema>;
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index 8d8949e092..cdf2022f32 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -3953,12 +3953,12 @@ export const ENCRYPTION_KEY_ROTATION = {
STATUS: {
description:
"Report the state of the instance encryption key: which key is active, whether a rotation is staged or awaiting completion, and what is blocking one.",
- activeFingerprint:
- "A non-reversible label for the key this instance is currently running with. Use it to identify which archived key a database backup needs.",
+ activeLabel:
+ "A non-reversible label derived from the key this instance is currently running with. Recompute it from an archived key to confirm which one a database backup needs.",
pendingRotation:
"A generated key that has not been applied yet. Staging a rotation changes nothing until an instance starts with the new key.",
- pendingFingerprint:
- "Fingerprint of the generated key, so you can confirm the value you are about to deploy is the one you copied.",
+ pendingLabel:
+ "Label of the generated key, so you can confirm the value you are about to deploy is the one you copied.",
lastResolvedAt:
"When an instance last started using the previous key. Recent means one is probably still running and would fail to restart if the key were removed. Null only means none has started since the rotation, not that none exists.",
history:
@@ -3969,8 +3969,8 @@ export const ENCRYPTION_KEY_ROTATION = {
"Generate a new value for ENCRYPTION_KEY. The key is returned once and never stored, and nothing changes until an instance starts with it.",
replacePending:
"Replace an already-generated key that has not been applied yet. The replaced key stops working immediately.",
- fingerprint:
- "A non-reversible label for the new key. Record it alongside the key so a backup can be matched to it later.",
+ label:
+ "A non-reversible label derived from the new key. Record it alongside the key so a backup can be matched to it later.",
key: "The new value for ENCRYPTION_KEY. Shown only in this response and never recoverable. Store it before closing.",
removesRetainedKey:
"Present when the previous rotation's key has not been removed yet. Applying this key removes it immediately, so any instance still running it will fail to restart."
diff --git a/backend/src/server/routes/v1/admin-router.ts b/backend/src/server/routes/v1/admin-router.ts
index 9b4003d5b4..b5fa3b4563 100644
--- a/backend/src/server/routes/v1/admin-router.ts
+++ b/backend/src/server/routes/v1/admin-router.ts
@@ -651,13 +651,13 @@ export const registerAdminRouter = async (server: FastifyZodProvider) => {
response: {
200: z.object({
status: z.object({
- activeFingerprint: z.string().nullable().describe(ENCRYPTION_KEY_ROTATION.STATUS.activeFingerprint),
+ activeLabel: z.string().nullable().describe(ENCRYPTION_KEY_ROTATION.STATUS.activeLabel),
encryptionStrategy: z.string().nullable(),
pendingRotation: z
.object({
id: z.string().uuid(),
createdAt: z.date(),
- fingerprint: z.string().nullable().describe(ENCRYPTION_KEY_ROTATION.STATUS.pendingFingerprint)
+ label: z.string().nullable().describe(ENCRYPTION_KEY_ROTATION.STATUS.pendingLabel)
})
.nullable()
.describe(ENCRYPTION_KEY_ROTATION.STATUS.pendingRotation),
@@ -666,12 +666,12 @@ export const registerAdminRouter = async (server: FastifyZodProvider) => {
id: z.string().uuid(),
supersededAt: z.date(),
lastResolvedAt: z.date().nullable().describe(ENCRYPTION_KEY_ROTATION.STATUS.lastResolvedAt),
- fingerprint: z.string().nullable()
+ label: z.string().nullable()
})
.nullable(),
history: z
.object({
- kekFingerprint: z.string(),
+ label: z.string(),
activatedAt: z.date(),
supersededAt: z.date().nullish(),
retiredAt: z.date().nullish()
@@ -711,10 +711,10 @@ export const registerAdminRouter = async (server: FastifyZodProvider) => {
201: z.object({
rotation: z.object({
id: z.string().uuid(),
- fingerprint: z.string().describe(ENCRYPTION_KEY_ROTATION.CREATE.fingerprint),
+ label: z.string().describe(ENCRYPTION_KEY_ROTATION.CREATE.label),
key: z.string().describe(ENCRYPTION_KEY_ROTATION.CREATE.key),
removesRetainedKey: z
- .object({ fingerprint: z.string().nullable(), lastResolvedAt: z.date().nullable() })
+ .object({ label: z.string().nullable(), lastResolvedAt: z.date().nullable() })
.optional()
.describe(ENCRYPTION_KEY_ROTATION.CREATE.removesRetainedKey)
})
diff --git a/backend/src/services/encryption-key-rotation/encryption-key-rotation-gc.test.ts b/backend/src/services/encryption-key-rotation/encryption-key-rotation-gc.test.ts
index 792097795d..e1ab2ec0c4 100644
--- a/backend/src/services/encryption-key-rotation/encryption-key-rotation-gc.test.ts
+++ b/backend/src/services/encryption-key-rotation/encryption-key-rotation-gc.test.ts
@@ -9,7 +9,7 @@ const DAY_MS = 24 * 60 * 60 * 1000;
const retainedRow = (overrides: Record<string, unknown> = {}) => ({
id: "11111111-1111-1111-1111-111111111111",
- kekFingerprint: "a".repeat(32),
+ kekLabel: "a".repeat(32),
supersededAt: new Date(Date.now() - (RETENTION_DAYS + 1) * DAY_MS),
lastResolvedAt: null,
activatedAt: new Date(Date.now() - (RETENTION_DAYS + 2) * DAY_MS),
@@ -41,7 +41,7 @@ const buildService = (snapshot: ReturnType<typeof retainedRow>, underLock: unkno
updateById: vi.fn()
};
const service = encryptionKeyRotationServiceFactory({
- kmsService: { encryptRootKeyForKek: vi.fn(), getCurrentKekFingerprint: vi.fn() },
+ kmsService: { encryptRootKeyForKek: vi.fn(), getCurrentKekLabel: vi.fn() },
kmsRootConfigDAL: kmsRootConfigDAL as never,
kmsKekHistoryDAL: kmsKekHistoryDAL as never,
envConfig: { KMS_ROOT_KEY_RETENTION_DAYS: RETENTION_DAYS },
diff --git a/backend/src/services/encryption-key-rotation/encryption-key-rotation-service.ts b/backend/src/services/encryption-key-rotation/encryption-key-rotation-service.ts
index 445d03da28..6193917890 100644
--- a/backend/src/services/encryption-key-rotation/encryption-key-rotation-service.ts
+++ b/backend/src/services/encryption-key-rotation/encryption-key-rotation-service.ts
@@ -7,7 +7,7 @@ import { CronJobName, TCronJobFactory } from "@app/lib/cron/cron-job";
import { crypto } from "@app/lib/crypto/cryptography";
import { BadRequestError, NotFoundError } from "@app/lib/errors";
import { logger } from "@app/lib/logger";
-import { getKekFingerprint, KMS_ROOT_CONFIG_UUID } from "@app/services/kms/kms-fns";
+import { getKekLabel, KMS_ROOT_CONFIG_UUID } from "@app/services/kms/kms-fns";
import { TKmsKekHistoryDALFactory } from "@app/services/kms/kms-kek-history-dal";
import { TKmsRootConfigDALFactory } from "@app/services/kms/kms-root-config-dal";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
@@ -30,7 +30,7 @@ const ABANDONED_ROTATION_MAX_AGE_MS = 30 * 24 * 60 * 60 * 1000; // 30 days
const STRAGGLER_EVIDENCE_WINDOW_MS = 60 * 60 * 1000; // 1 hour
type TEncryptionKeyRotationServiceFactoryDep = {
- kmsService: Pick<TKmsServiceFactory, "encryptRootKeyForKek" | "getCurrentKekFingerprint">;
+ kmsService: Pick<TKmsServiceFactory, "encryptRootKeyForKek" | "getCurrentKekLabel">;
kmsRootConfigDAL: Pick<
TKmsRootConfigDALFactory,
| "findById"
@@ -74,13 +74,13 @@ export const encryptionKeyRotationServiceFactory = ({
const [retained] = retainedRows;
return {
- activeFingerprint: kmsService.getCurrentKekFingerprint(),
+ activeLabel: kmsService.getCurrentKekLabel(),
encryptionStrategy: sentinel?.encryptionStrategy ?? null,
pendingRotation: pendingRows[0]
? {
id: pendingRows[0].id,
createdAt: pendingRows[0].createdAt,
- fingerprint: pendingRows[0].kekFingerprint ?? null
+ label: pendingRows[0].kekLabel ?? null
}
: null,
retainedKey: retained
@@ -88,11 +88,11 @@ export const encryptionKeyRotationServiceFactory = ({
id: retained.id,
supersededAt: retained.supersededAt as Date,
lastResolvedAt: retained.lastResolvedAt ?? null,
- fingerprint: retained.kekFingerprint ?? null
+ label: retained.kekLabel ?? null
}
: null,
- history: history.map(({ kekFingerprint, activatedAt, supersededAt, retiredAt }) => ({
- kekFingerprint,
+ history: history.map(({ kekLabel, activatedAt, supersededAt, retiredAt }) => ({
+ label: kekLabel,
activatedAt,
supersededAt,
retiredAt
@@ -148,32 +148,32 @@ export const encryptionKeyRotationServiceFactory = ({
const isFipsEnabled = crypto.isFipsModeEnabled();
const key = generateRootEncryptionKey(isFipsEnabled);
const kekBuffer = resolveKekBuffer(key, isFipsEnabled);
- const fingerprint = getKekFingerprint(kekBuffer);
+ const label = getKekLabel(kekBuffer);
const row = await kmsRootConfigDAL.create(
{
encryptedRootKey: kmsService.encryptRootKeyForKek(kekBuffer),
encryptionStrategy: RootKeyEncryptionStrategy.Software,
- kekFingerprint: fingerprint,
+ kekLabel: label,
activatedAt: null
},
tx
);
- return { row, retained, key, fingerprint };
+ return { row, retained, key, label };
});
const pending = staged.row;
- logger.info(`Encryption key rotation staged [rotationId=${pending.id}] [fingerprint=${staged.fingerprint}]`);
+ logger.info(`Encryption key rotation staged [rotationId=${pending.id}] [label=${staged.label}]`);
return {
id: pending.id,
- fingerprint: staged.fingerprint,
+ label: staged.label,
key: staged.key,
...(staged.retained
? {
removesRetainedKey: {
- fingerprint: staged.retained.kekFingerprint ?? null,
+ label: staged.retained.kekLabel ?? null,
lastResolvedAt: staged.retained.lastResolvedAt ?? null
}
}
@@ -190,9 +190,9 @@ export const encryptionKeyRotationServiceFactory = ({
const deleted = await kmsRootConfigDAL.deleteById(row.id, tx);
if (!deleted) return false;
- if (row.kekFingerprint) {
+ if (row.kekLabel) {
const history = await kmsKekHistoryDAL.findHistory(tx);
- const entry = history.find((e) => e.kekFingerprint === row.kekFingerprint && !e.retiredAt);
+ const entry = history.find((e) => e.kekLabel === row.kekLabel && !e.retiredAt);
if (entry) await kmsKekHistoryDAL.updateById(entry.id, { retiredAt: new Date() }, tx);
}
@@ -222,9 +222,7 @@ export const encryptionKeyRotationServiceFactory = ({
});
}
- logger.info(
- `Encryption key rotation discarded [rotationId=${rotationId}] [fingerprint=${row.kekFingerprint ?? "unknown"}]`
- );
+ logger.info(`Encryption key rotation discarded [rotationId=${rotationId}] [label=${row.kekLabel ?? "unknown"}]`);
});
};
@@ -264,7 +262,7 @@ export const encryptionKeyRotationServiceFactory = ({
}
logger.info(
- `Encryption key rotation completed, previous key removed [retainedKeyId=${rotationId}] [fingerprint=${row.kekFingerprint ?? "unknown"}]`
+ `Encryption key rotation completed, previous key removed [retainedKeyId=${rotationId}] [label=${row.kekLabel ?? "unknown"}]`
);
});
};
@@ -286,7 +284,7 @@ export const encryptionKeyRotationServiceFactory = ({
});
if (removed)
logger.info(
- `Discarded an encryption key rotation that was never applied [rotationId=${row.id}] [fingerprint=${row.kekFingerprint ?? "unknown"}]`
+ `Discarded an encryption key rotation that was never applied [rotationId=${row.id}] [label=${row.kekLabel ?? "unknown"}]`
);
}
@@ -318,7 +316,7 @@ export const encryptionKeyRotationServiceFactory = ({
});
if (removed)
logger.info(
- `Removed a superseded encryption key [retainedKeyId=${row.id}] [fingerprint=${row.kekFingerprint ?? "unknown"}]`
+ `Removed a superseded encryption key [retainedKeyId=${row.id}] [label=${row.kekLabel ?? "unknown"}]`
);
}
diff --git a/backend/src/services/encryption-key-rotation/encryption-key-rotation-types.ts b/backend/src/services/encryption-key-rotation/encryption-key-rotation-types.ts
index 81395ac848..b043ec6bf9 100644
--- a/backend/src/services/encryption-key-rotation/encryption-key-rotation-types.ts
+++ b/backend/src/services/encryption-key-rotation/encryption-key-rotation-types.ts
@@ -4,17 +4,17 @@ export enum RotationBlocker {
}
export type TEncryptionStatus = {
- activeFingerprint: string | null;
+ activeLabel: string | null;
encryptionStrategy: string | null;
- pendingRotation: { id: string; createdAt: Date; fingerprint: string | null } | null;
+ pendingRotation: { id: string; createdAt: Date; label: string | null } | null;
retainedKey: {
id: string;
supersededAt: Date;
lastResolvedAt: Date | null;
- fingerprint: string | null;
+ label: string | null;
} | null;
history: {
- kekFingerprint: string;
+ label: string;
activatedAt: Date;
supersededAt?: Date | null;
retiredAt?: Date | null;
@@ -33,12 +33,12 @@ export type TCompleteRotationDTO = {
export type TCreatedRotation = {
id: string;
- fingerprint: string;
+ label: string;
/** Returned exactly once. Never stored, never logged. */
key: string;
/**
* Set when the previous rotation's key has not been removed yet. Applying this key removes it
* immediately, so an instance still running it will fail to restart.
*/
- removesRetainedKey?: { fingerprint: string | null; lastResolvedAt: Date | null };
+ removesRetainedKey?: { label: string | null; lastResolvedAt: Date | null };
};
diff --git a/backend/src/services/kms/kms-fns.ts b/backend/src/services/kms/kms-fns.ts
index d1b264b626..321ac6d008 100644
--- a/backend/src/services/kms/kms-fns.ts
+++ b/backend/src/services/kms/kms-fns.ts
@@ -52,14 +52,15 @@ export const resolveInstanceEncryptionKeyBuffer = (envCfg: {
return buffer;
};
-const KEK_FINGERPRINT_DOMAIN = "infisical:kek-fingerprint:v1";
+const KEK_LABEL_DOMAIN = "infisical:kek-fingerprint:v1";
/**
* A label, never a lookup key: it lets an operator match a restored dump against an archived key.
+ * Derived from the key, so an operator holding an archived key can recompute it and confirm the match.
* Truncated SHA-256 over a 128-bit-minimum key is not reversible, so it is safe to log and expose.
*/
-export const getKekFingerprint = (keyBuffer: Buffer) =>
- crypto.nativeCrypto.createHash("sha256").update(KEK_FINGERPRINT_DOMAIN).update(keyBuffer).digest("hex").slice(0, 32);
+export const getKekLabel = (keyBuffer: Buffer) =>
+ crypto.nativeCrypto.createHash("sha256").update(KEK_LABEL_DOMAIN).update(keyBuffer).digest("hex").slice(0, 32);
export const getByteLengthForSymmetricEncryptionAlgorithm = (encryptionAlgorithm: SymmetricKeyAlgorithm) => {
switch (encryptionAlgorithm) {
diff --git a/backend/src/services/kms/kms-service.ts b/backend/src/services/kms/kms-service.ts
index e339dd24ed..c5a4176028 100644
--- a/backend/src/services/kms/kms-service.ts
+++ b/backend/src/services/kms/kms-service.ts
@@ -31,7 +31,7 @@ import { requestMemoKeys } from "@app/lib/request-context/memo-keys";
import { requestMemoize } from "@app/lib/request-context/request-memoizer";
import {
getByteLengthForSymmetricEncryptionAlgorithm,
- getKekFingerprint,
+ getKekLabel,
KMS_LEGACY_ENCRYPTION_KEY_UUID,
KMS_ROOT_CONFIG_UUID,
MAX_HMAC_IMPORT_KEY_BYTE_LENGTH,
@@ -1484,9 +1484,9 @@ export const kmsServiceFactory = ({
};
/** Null under HSM, where no env key is involved. */
- const $currentKekFingerprint = () => {
+ const $currentKekLabel = () => {
try {
- return getKekFingerprint($getBasicEncryptionKey());
+ return getKekLabel($getBasicEncryptionKey());
} catch {
return null;
}
@@ -1507,7 +1507,7 @@ export const kmsServiceFactory = ({
* The moment a rotation takes effect. Driven by a booting pod rather than the rotate endpoint, so
* that generating a key is inert and an operator who never deploys it has changed nothing.
*/
- const $promoteRotation = async (pendingId: string, fingerprint: string | null) => {
+ const $promoteRotation = async (pendingId: string, label: string | null) => {
return kmsRootConfigDAL.transaction(async (tx) => {
await tx.raw("SELECT pg_advisory_xact_lock(?)", [PgSqlLock.KmsRootKeyInit]);
@@ -1529,7 +1529,7 @@ export const kmsServiceFactory = ({
{
encryptedRootKey: sentinel.encryptedRootKey,
encryptionStrategy: sentinel.encryptionStrategy,
- kekFingerprint: sentinel.kekFingerprint,
+ kekLabel: sentinel.kekLabel,
activatedAt: sentinel.activatedAt ?? sentinel.createdAt,
supersededAt: now
},
@@ -1541,7 +1541,7 @@ export const kmsServiceFactory = ({
{
encryptedRootKey: pending.encryptedRootKey,
encryptionStrategy: pending.encryptionStrategy,
- kekFingerprint: pending.kekFingerprint ?? fingerprint,
+ kekLabel: pending.kekLabel ?? label,
activatedAt: now,
supersededAt: null
},
@@ -1550,11 +1550,11 @@ export const kmsServiceFactory = ({
await kmsRootConfigDAL.deleteAllPending(tx);
- const promotedFingerprint = pending.kekFingerprint ?? fingerprint;
+ const promotedLabel = pending.kekLabel ?? label;
const previous = await kmsKekHistoryDAL.findCurrent(tx);
if (previous) await kmsKekHistoryDAL.updateById(previous.id, { supersededAt: now }, tx);
- if (promotedFingerprint) {
- await kmsKekHistoryDAL.create({ kekFingerprint: promotedFingerprint, activatedAt: now }, tx);
+ if (promotedLabel) {
+ await kmsKekHistoryDAL.create({ kekLabel: promotedLabel, activatedAt: now }, tx);
}
// Exactly one retained key survives a promotion.
@@ -1562,14 +1562,12 @@ export const kmsServiceFactory = ({
for (const stale of olderRetained) {
// eslint-disable-next-line no-await-in-loop -- at most a couple of rows
await kmsRootConfigDAL.deleteById(stale.id, tx);
- const entry = stale.kekFingerprint
- ? history.find((e) => e.kekFingerprint === stale.kekFingerprint && !e.retiredAt)
- : undefined;
+ const entry = stale.kekLabel ? history.find((e) => e.kekLabel === stale.kekLabel && !e.retiredAt) : undefined;
// eslint-disable-next-line no-await-in-loop
if (entry) await kmsKekHistoryDAL.updateById(entry.id, { retiredAt: now }, tx);
logger.info(
- `KMS: Removed a key superseded by an earlier rotation [rootConfigId=${stale.id}] [fingerprint=${
- stale.kekFingerprint ?? "unknown"
+ `KMS: Removed a key superseded by an earlier rotation [rootConfigId=${stale.id}] [label=${
+ stale.kekLabel ?? "unknown"
}]`
);
}
@@ -1636,26 +1634,24 @@ export const kmsServiceFactory = ({
if (skipRotationState) return rootKey;
if (!row.activatedAt && row.id !== KMS_ROOT_CONFIG_UUID) {
- const fingerprint = $currentKekFingerprint();
+ const label = $currentKekLabel();
// eslint-disable-next-line no-await-in-loop
- const promoted = await $promoteRotation(row.id, fingerprint);
+ const promoted = await $promoteRotation(row.id, label);
if (promoted) {
logger.info(
- `KMS: Promoted pending encryption key rotation [fingerprint=${fingerprint ?? "hsm"}] [rotationId=${
- row.id
- }]`
+ `KMS: Promoted pending encryption key rotation [label=${label ?? "hsm"}] [rotationId=${row.id}]`
);
}
}
// Rows written before the label existed get it from the pod that can actually decrypt them,
// which is the only place the value is derivable.
- if (!row.kekFingerprint) {
- const fingerprint = $currentKekFingerprint();
- if (fingerprint) {
+ if (!row.kekLabel) {
+ const label = $currentKekLabel();
+ if (label) {
// eslint-disable-next-line no-await-in-loop
await kmsRootConfigDAL
- .updateById(row.id, { kekFingerprint: fingerprint })
+ .updateById(row.id, { kekLabel: label })
.catch((err: unknown) => logger.warn({ err }, "KMS: Failed to label a root key row"));
}
}
@@ -1670,8 +1666,8 @@ export const kmsServiceFactory = ({
.updateById(row.id, { lastResolvedAt: new Date() })
.catch((err: unknown) => logger.warn({ err }, "KMS: Failed to record use of a superseded root key"));
logger.warn(
- `KMS: This instance started on a superseded encryption key [rootConfigId=${row.id}] [fingerprint=${
- $currentKekFingerprint() ?? "hsm"
+ `KMS: This instance started on a superseded encryption key [rootConfigId=${row.id}] [label=${
+ $currentKekLabel() ?? "hsm"
}]. Roll it onto the current key before the previous one is removed.`
);
}
@@ -1680,14 +1676,14 @@ export const kmsServiceFactory = ({
}
}
- const fingerprint = $currentKekFingerprint();
+ const label = $currentKekLabel();
const history = await kmsKekHistoryDAL.findHistory().catch(() => []);
- const known = history.map((entry) => entry.kekFingerprint).join(", ");
+ const known = history.map((entry) => entry.kekLabel).join(", ");
logger.error({ err: errors[0] }, "KMS: No stored root key could be decrypted with the configured encryption key");
throw new InternalServerError({
- message: `The configured encryption key (fingerprint ${fingerprint ?? "unknown"}) does not decrypt this database's root key. ${
+ message: `The configured encryption key (label ${label ?? "unknown"}) does not decrypt this database's root key. ${
known
- ? `This database was last written with encryption key fingerprint(s): ${known}. Set the matching key and restart.`
+ ? `This database was last written with encryption key label(s): ${known}. Set the matching key and restart.`
: "Set the encryption key this database was created with and restart."
}`
});
@@ -1748,12 +1744,12 @@ export const kmsServiceFactory = ({
};
/**
- * Backfills the key an instance already runs with, so a pre-rotation dump still has a fingerprint an
+ * Backfills the key an instance already runs with, so a pre-rotation dump still has a label an
* operator can match against an archived key.
*/
const $ensureKekHistory = async () => {
- const fingerprint = $currentKekFingerprint();
- if (!fingerprint) return;
+ const label = $currentKekLabel();
+ if (!label) return;
const current = await kmsKekHistoryDAL.findCurrent();
if (current) return;
@@ -1764,7 +1760,7 @@ export const kmsServiceFactory = ({
await tx.raw("SELECT pg_advisory_xact_lock(?)", [PgSqlLock.KmsRootKeyInit]);
if (await kmsKekHistoryDAL.findCurrent(tx)) return;
await kmsKekHistoryDAL.create(
- { kekFingerprint: fingerprint, activatedAt: sentinel?.activatedAt ?? sentinel?.createdAt ?? new Date() },
+ { kekLabel: label, activatedAt: sentinel?.activatedAt ?? sentinel?.createdAt ?? new Date() },
tx
);
})
@@ -1802,7 +1798,7 @@ export const kmsServiceFactory = ({
return cipher.encrypt(ROOT_ENCRYPTION_KEY, kekBuffer);
};
- const getCurrentKekFingerprint = () => $currentKekFingerprint();
+ const getCurrentKekLabel = () => $currentKekLabel();
const updateEncryptionStrategy = async (strategy: RootKeyEncryptionStrategy) => {
// A fleet-wide cutover. Unguarded, a switch to HSM would not take effect while a retained software
@@ -1834,10 +1830,10 @@ export const kmsServiceFactory = ({
}
if (kmsRootConfig.encryptionStrategy === RootKeyEncryptionStrategy.Software) {
- const currentFingerprint = $currentKekFingerprint();
- if (kmsRootConfig.kekFingerprint && currentFingerprint && kmsRootConfig.kekFingerprint !== currentFingerprint) {
+ const currentLabel = $currentKekLabel();
+ if (kmsRootConfig.kekLabel && currentLabel && kmsRootConfig.kekLabel !== currentLabel) {
throw new BadRequestError({
- message: `This instance is running with encryption key fingerprint '${currentFingerprint}', but the active root key was written with '${kmsRootConfig.kekFingerprint}'. Restart it with the current encryption key before changing the root key encryption strategy.`
+ message: `This instance is running with encryption key label '${currentLabel}', but the active root key was written with '${kmsRootConfig.kekLabel}'. Restart it with the current encryption key before changing the root key encryption strategy.`
});
}
}
@@ -1878,7 +1874,7 @@ export const kmsServiceFactory = ({
{
encryptedRootKey,
encryptionStrategy: strategy,
- kekFingerprint: strategy === RootKeyEncryptionStrategy.Software ? $currentKekFingerprint() : null
+ kekLabel: strategy === RootKeyEncryptionStrategy.Software ? $currentKekLabel() : null
},
tx
);
@@ -1890,7 +1886,7 @@ export const kmsServiceFactory = ({
return {
startService,
encryptRootKeyForKek,
- getCurrentKekFingerprint,
+ getCurrentKekLabel,
generateKmsKey,
rotateKmsKey,
deleteInternalKms,
diff --git a/docs/self-hosting/guides/rotating-the-encryption-key.mdx b/docs/self-hosting/guides/rotating-the-encryption-key.mdx
index 3ead89b6ec..cbd31ea284 100644
--- a/docs/self-hosting/guides/rotating-the-encryption-key.mdx
+++ b/docs/self-hosting/guides/rotating-the-encryption-key.mdx
@@ -34,7 +34,7 @@ one, think about it, and discard it with no consequences.
<Step title="Store the key">
The key is shown once and is never recoverable. Copy it into your secret store before closing the
- dialog, together with the **fingerprint** shown beside it.
+ dialog, together with the **label** shown beside it.
If you think the key was exposed while copying it, select **Discard generated key**. It stops working
immediately and you can generate another.
@@ -84,14 +84,14 @@ one, think about it, and discard it with no consequences.
Pick one of these and make it explicit, rather than leaving it to chance:
- **Archive the old key.** Keep it in your secret store for at least as long as your oldest restorable
- backup, labelled with the fingerprint from the **Key history** table. That table is kept permanently, so
+ backup, tagged with the label from the **Key history** table. That table is kept permanently, so
a restored backup can always be matched to the key it needs.
- **Crypto-shred.** Remove the old key, take a fresh full backup immediately, and expire backups taken
before the rotation. A backup nobody can decrypt is also a backup that cannot leak.
The **Key history** table lists every key the instance has used and when. If an instance ever fails to
start with "the configured encryption key does not decrypt this database's root key", the error names the
-fingerprint it needs, which you can look up there.
+label it needs, which you can look up there.
## Rolling back
diff --git a/frontend/src/hooks/api/admin/types.ts b/frontend/src/hooks/api/admin/types.ts
index 8925fe04a2..e32ad887da 100644
--- a/frontend/src/hooks/api/admin/types.ts
+++ b/frontend/src/hooks/api/admin/types.ts
@@ -247,17 +247,17 @@ export enum EncryptionRotationBlocker {
}
export type TEncryptionStatus = {
- activeFingerprint: string | null;
+ activeLabel: string | null;
encryptionStrategy: string | null;
- pendingRotation: { id: string; createdAt: string; fingerprint: string | null } | null;
+ pendingRotation: { id: string; createdAt: string; label: string | null } | null;
retainedKey: {
id: string;
supersededAt: string;
lastResolvedAt: string | null;
- fingerprint: string | null;
+ label: string | null;
} | null;
history: {
- kekFingerprint: string;
+ label: string;
activatedAt: string;
supersededAt?: string | null;
retiredAt?: string | null;
@@ -267,9 +267,9 @@ export type TEncryptionStatus = {
export type TCreatedEncryptionKeyRotation = {
id: string;
- fingerprint: string;
+ label: string;
key: string;
- removesRetainedKey?: { fingerprint: string | null; lastResolvedAt: string | null };
+ removesRetainedKey?: { label: string | null; lastResolvedAt: string | null };
};
export type TCompleteEncryptionKeyRotationDTO = {
diff --git a/frontend/src/pages/admin/EncryptionPage/components/EncryptionKeyRotationSection.tsx b/frontend/src/pages/admin/EncryptionPage/components/EncryptionKeyRotationSection.tsx
index 408e772e09..42646dd171 100644
--- a/frontend/src/pages/admin/EncryptionPage/components/EncryptionKeyRotationSection.tsx
+++ b/frontend/src/pages/admin/EncryptionPage/components/EncryptionKeyRotationSection.tsx
@@ -119,15 +119,15 @@ export const EncryptionKeyRotationSection = () => {
<KeyRoundIcon className="size-4 text-foreground/60" />
<span className="text-foreground/70">Active key</span>
<Badge variant="neutral" className="font-mono">
- {status.activeFingerprint ?? "managed by HSM"}
+ {status.activeLabel ?? "managed by HSM"}
</Badge>
</div>
- {status.pendingRotation?.fingerprint && (
+ {status.pendingRotation?.label && (
<div className="flex items-center gap-2 text-sm">
<span className="text-foreground/70">Generated key awaiting deployment</span>
<Badge variant="info" className="font-mono">
- {status.pendingRotation.fingerprint}
+ {status.pendingRotation.label}
</Badge>
</div>
)}
@@ -203,21 +203,21 @@ export const EncryptionKeyRotationSection = () => {
<div>
<p className="mb-2 text-sm font-medium">Key history</p>
<p className="mb-2 text-xs text-foreground/60">
- Kept after a key is removed. Use the fingerprint to work out which archived key a
- restored backup needs.
+ Kept after a key is removed. Use the label to work out which archived key a restored
+ backup needs.
</p>
<Table>
<TableHeader>
<TableRow>
- <TableHead>Fingerprint</TableHead>
+ <TableHead>Label</TableHead>
<TableHead>Active from</TableHead>
<TableHead>Status</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{status.history.map((entry) => (
- <TableRow key={entry.kekFingerprint + entry.activatedAt}>
- <TableCell className="font-mono text-xs">{entry.kekFingerprint}</TableCell>
+ <TableRow key={entry.label + entry.activatedAt}>
+ <TableCell className="font-mono text-xs">{entry.label}</TableCell>
<TableCell>{new Date(entry.activatedAt).toLocaleString()}</TableCell>
<TableCell>
{!entry.supersededAt && <Badge variant="success">Active</Badge>}
@@ -257,8 +257,8 @@ export const EncryptionKeyRotationSection = () => {
</div>
<div>
- <p className="mb-1.5 text-sm font-medium">Fingerprint</p>
- <p className="font-mono text-xs text-foreground/70">{generatedKey?.fingerprint}</p>
+ <p className="mb-1.5 text-sm font-medium">Label</p>
+ <p className="font-mono text-xs text-foreground/70">{generatedKey?.label}</p>
<p className="mt-1 text-xs text-foreground/60">
Store this alongside the key. It is how you identify which key a database backup
needs.