Skip to content

docs: state the catalog trust boundary for the credential encryption key - #228

Merged
jcshepherd merged 5 commits into
mainfrom
docs/catalog-trust-boundary
Nov 11, 2026
Merged

jcshepherd merged 5 commits into
mainfrom
docs/catalog-trust-boundary

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Jul 27, 2026 •

Copy link
Copy Markdown
Collaborator

What

State the catalog trust boundary for the credential encryption key in the security model. The doc noted that the key lives in the catalog database and that a catalog backup includes it. It left the consequence to inference and did not say how to rotate the key.

  • Add the catalog database contents as an explicit trust boundary. The encryption key and the ciphertext it protects share one trust domain, so catalog read access yields every stored access key secret.
  • Scope that boundary to direct database access: the management API and console redact encryption_key from settings responses.
  • Record that extenddb has no command to rotate the key, and give the order of a rotation by hand. The steps replace the key, restart every server, delete every access key and create a new one, and then give each client its new credentials. From the restart on, each request signed with an old access key or session credential fails.
  • Replace the "use a KMS-backed encryption layer at the PostgreSQL level" guidance with what extenddb does and does not do. Say what protection below extenddb can and cannot achieve.
  • State that a catalog dump is credential-equivalent and should not be copied to less-protected environments.
  • The design guide no longer calls the key immutable. The configuration design no longer says that the key is not a setting.

Why

The security model understated a trust boundary. Making it explicit lets operators
protect the catalog database and its backups to the standard the credentials require.
#707 tracks keeping the key outside the catalog and rotating it.

Refs #707

Testing done

Documentation only, no code change:

  • Key storage location and unwrapped form: bootstrap_encryption_key in each backend's bootstrapper.rs (PostgreSQL: INSERT INTO settings (key, value) VALUES ('encryption_key', $1)).
  • encryption_key redacted from the settings responses of the management API and the web console: REDACTED_CONFIG_KEYS in crates/config/src/display.rs.
  • No rotation command: nothing in crates/ replaces encryption_key or re-encrypts the stored secrets under a new key. A grep for rotat finds only TLS certificates, backup data files, rotated access keys in the credential caches, and partition and stream label rotation.
  • Rotation by hand: every backend reads the key once at startup, and CreateAccessKey and AssumeRole encrypt with that copy. Each backend's credential store answers a failed decrypt with InternalServerError. extenddb settings set refuses encryption_key, which is not in KNOWN_KEYS (crates/server/src/management/ops_settings.rs).
  • AssumeRole is the admin endpoint behind extenddb manage assume-role, with HTTP Basic authentication (crates/server/src/management/assume_role.rs).

Checklist

  • I have read CONTRIBUTING.md
  • All tests pass (cargo test --workspace)
  • Code is formatted (cargo fmt --check)
  • Clippy is clean (cargo clippy -- -W clippy::pedantic)
  • I have added or updated tests for new functionality
  • I have updated documentation if behavior changed
  • Breaking changes are noted below (if any)
  • If this changes the wire protocol, Storage trait, auth model, on-disk
    format, or public CLI surface, an RFC has been accepted or is linked
    below. Otherwise, an ADR captures the decision (link below).

ADR / RFC: n/a, documentation only, no behavior change.

Breaking changes

None.


By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO). See CONTRIBUTING.md for details.

Comment thread docs/manuals/10-security-model.md Outdated
- **PostgreSQL security**: extenddb relies on PostgreSQL access controls and network security. Securing the PostgreSQL instance (firewall rules, TLS, authentication) is the operator's responsibility.
- **Operating system security**: File permissions on `extenddb.toml`, TLS keys, and the PID file are the operator's responsibility.
- **Key management**: Access key secrets are encrypted with a locally generated AES key stored in the catalog database. For HSM-grade key management, use a KMS-backed encryption layer at the PostgreSQL level.
- **Key management**: extenddb generates the credential encryption key locally and stores it unwrapped in the catalog database. It does not wrap the key with an external KMS or HSM, derive it from an operator passphrase, or rotate it. Deployments that require any of those must add protection below extenddb — for example PostgreSQL transparent data encryption, an encrypted volume, or a managed database with a customer-managed KMS key — which protects the key at rest but not from a principal that can query the catalog.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe something for the backlog here: pluggable support for generating/managing credential encryption keys. Seems like this would be important for a lot of users.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Filed as #707: wrapping the key with a KMS or an HSM, a passphrase supplied at start-up, a pluggable key provider, and a rotation path that re-encrypts the stored secrets.

It also lists the questions an RFC would need to settle, such as what the server does when the provider is unreachable at start-up and how an existing deployment moves over.

@jcshepherd jcshepherd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for documenting this. I think it'd be good to cut an issue to support other, more secure, mechanisms for handling the credential encryption key like the ones you mentioned: HSM, passcodes, etc. Status quo is probably not sufficient for many production uses.

The security model noted that the encryption key lives in the catalog
database and that a catalog backup includes it, but left the consequence for
the reader to infer and did not mention that no rotation path exists.

- Add the catalog database contents as an explicit trust boundary: the key
  and the ciphertext it protects share one trust domain, so catalog read
  access yields every stored access key secret.
- Scope that boundary to direct database access: the management API and
  console redact `encryption_key` from settings responses.
- Record that there is no key rotation path; re-keying means re-creating the
  affected access keys.
- Replace the "use a KMS-backed encryption layer at the PostgreSQL level"
  guidance with what extenddb does and does not do, and what protection
  below extenddb can and cannot achieve.
- State that a catalog dump is credential-equivalent and should not be copied
  to less-protected environments.
Comment thread docs/manuals/10-security-model.md Outdated
- Encryption key generated during `extenddb init` and stored unwrapped in the catalog `settings` table, under the key `encryption_key`
- The encryption key and the ciphertext it protects therefore share one trust domain: anyone who can read the catalog database can decrypt every stored access key secret. Restrict catalog database access to the extenddb service account, and protect catalog backups to the same standard as the credentials themselves.
- The management API and web console redact `encryption_key` from settings responses. The key is readable only with catalog database access: a database client, or `extenddb settings get encryption_key --show-secret` on a host that holds the catalog connection string.
- extenddb provides no key rotation path. Re-keying requires re-creating the affected access keys.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If I'm understanding correctly, this is too terse: it's not making the key rotation path, even if manual, very clear. This might be better:
Extenddb has no command to rotate the encryption key. Rotating it by hand makes every stored access key and session credential unreadable. Re-create all access keys using the new encryption key, and restart the server."

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Taken, with session credentials added, and the restart now says why: the server keeps the old key and the decrypted secrets in memory.

Comment thread docs/manuals/10-security-model.md Outdated
1. **Client ↔ extenddb**: Untrusted. All input is validated. SigV4 signatures are verified. IAM policies are evaluated.
2. **extenddb ↔ PostgreSQL**: Trusted network. The PostgreSQL connection string contains credentials. Use TLS for the PostgreSQL connection in production (`sslmode=require` in the connection string).
3. **Admin ↔ Management API/Console**: Authenticated via admin credentials or IAM user credentials. CSRF tokens protect the web console.
4. **Catalog database contents**: Credential-equivalent. The AES-256-GCM key that encrypts access key secrets lives in the catalog `settings` table alongside the ciphertext it protects, so read access to the catalog database yields every stored access key secret. Treat catalog read access, and any catalog backup, as equivalent to holding those credentials. See [Credential Storage](#credential-storage).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It might be important to note that on PostgreSQL, read access to the Catalog db gives you read access to the data_database_connection_string settings, which gives you log-in credentials directly to PostgreSQL, which essentially (if I understand those credentials correctly) gives you root-like permissions for ExtendDB. I'm not sure why we need unredacted db credentials to be stored in the db.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added to the catalog item: on PostgreSQL the same table holds data_database_connection_string, which the console, the management API and the CLI mask, but a reader of the catalog database gets in full. Keeping it out of the catalog is a code change, so I filed #789 for it.

Comment thread docs/manuals/10-security-model.md Outdated
- The management API and web console redact `encryption_key` from settings responses. The key is readable only with catalog database access: a database client, or `extenddb settings get encryption_key --show-secret` on a host that holds the catalog connection string.
- extenddb provides no key rotation path. Re-keying requires re-creating the affected access keys.
- Console passwords hashed with bcrypt (cost factor 12)
- No in-process credential cache — every request reads directly from PostgreSQL

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This hasn't been true for a while: unencrypted credentials are in-memory with a running extenddb server.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Right. #786 rewrites this bullet with a section on the credential and policy caches, so I left this line to it, to keep the two PRs from conflicting. The new Server host item in Trust Boundaries says the running server keeps the key and recently used decrypted secrets in memory.

Comment thread docs/manuals/10-security-model.md Outdated
1. **Client ↔ extenddb**: Untrusted. All input is validated. SigV4 signatures are verified. IAM policies are evaluated.
2. **extenddb ↔ PostgreSQL**: Trusted network. The PostgreSQL connection string contains credentials. Use TLS for the PostgreSQL connection in production (`sslmode=require` in the connection string).
3. **Admin ↔ Management API/Console**: Authenticated via admin credentials or IAM user credentials. CSRF tokens protect the web console.
4. **Catalog database contents**: Credential-equivalent. The AES-256-GCM key that encrypts access key secrets lives in the catalog `settings` table alongside the ciphertext it protects, so read access to the catalog database yields every stored access key secret. Treat catalog read access, and any catalog backup, as equivalent to holding those credentials. See [Credential Storage](#credential-storage).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We may also want to add that access to extenddb.toml is "credential-equivalent" as well.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added as a fifth item, Server host: extenddb.toml holds the catalog connection string and the process memory holds the key and recently used secrets, so read access to the config file, a core dump or a memory read are credential-equivalent too.

@jcshepherd jcshepherd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

On second look, this could probably use another pass, partly because Things Have Changed. On that note, there are outdated statements elsewhere in the documentation:
10-security-model.md:236 says access key secrets "cannot be retrieved afterward". The new line 59 says a catalog reader can decrypt them all.
02-design-guide.md:40 and :129 put the key in an encryption_keys table. No backend has that table.
02-design-guide.md:131 repeats "no in-process cache for credentials".
docs/design/08-component-config.md:55, :124 and :432 describe an auth.encryption_key setting from EXTENDDB__AUTH__ENCRYPTION_KEY. AuthConfig has no such field (crates/config/src/lib.rs:246-256). A reader can think the key can be kept out of the catalog. All at base. Line 236 and the 02-design-guide.md lines are worth fixing in this PR, because they now conflict with it on the same topic.

@navareamol navareamol added this to the 1.0 milestone Nov 3, 2026
- 10-security-model.md: the catalog trust boundary names the PostgreSQL
  data database login held in settings; a Server host boundary covers
  extenddb.toml and the server's memory; the rotation bullet says what a
  manual rotation breaks and why the server must restart; and the
  Operational Security bullet no longer says secrets cannot be
  retrieved.
- 02-design-guide.md: the key is a settings row, not an encryption_keys
  table.
- 08-component-config.md: drop the auth.encryption_key setting and
  EXTENDDB__AUTH__ENCRYPTION_KEY, which AuthConfig does not have.
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@jcshepherd the new head merges main and addresses your second pass:

Comment thread docs/manuals/10-security-model.md Outdated
- Encryption key generated during `extenddb init` and stored unwrapped in the catalog `settings` table, under the key `encryption_key`
- The encryption key and the ciphertext it protects therefore share one trust domain: anyone who can read the catalog database can decrypt every stored access key secret. Restrict catalog database access to the extenddb service account, and protect catalog backups to the same standard as the credentials themselves.
- The management API and web console redact `encryption_key` from settings responses. The key is readable only with catalog database access: a database client, or `extenddb settings get encryption_key --show-secret` on a host that holds the catalog connection string.
- extenddb has no command to rotate the encryption key. Rotating it by hand makes every stored access key secret and session credential unreadable: re-create all access keys under the new key, then restart the server, which keeps the old key and decrypted secrets in memory.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think my suggested wording got the order wrong and also omits a major difficulty with this.

The working order is: replace the encryption key, restart every server (which still is using the old encryption key it has in memory), then re-create the access keys.

However, that means that after the restart every stored access key and session credential will fail to decrypt, so every signed request fails. The user will have to not only recreate all access keys needed by clients, but also distribute the new keys and secrets to each client to enable that client to successfully log in. Major headache people should be aware of before attempting a rotation.

Could the bullet say that plainly? For example:

"Extenddb has no command to rotate the encryption key. Replacing it by hand invalidates every access key and session credential. Replace the key, restart every server, then re-create all access keys and give each client its new credentials. After the restart, each client's requests will until the client has its new credentials."

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Changed in 9c2a4b8, in the order you gave. The bullet is now four numbered steps. They replace the key, restart every server, delete every access key and create a new one, and then give each client its new credentials.

From the restart on, a request signed with an old key or an unexpired session credential fails with InternalServerError. Step 1 says what to write, 32 random bytes in standard base64, because the server checks only that a key is present. Session credentials come from extenddb manage assume-role, which signs in with the admin password, so an admin issues new ones after the restart.

The design guide no longer says the key never changes. 4355d99 merges main, where the Credential Handling list conflicted.

@jcshepherd jcshepherd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One minor but important adjustment requested below, so people know what a headache they'll create if they do rotate the encryption key.

The Credential Handling list of the security model conflicted with
main. The resolution keeps the two lines from main about the password
of `extenddb manage`, and the access key line of this branch.

Signed-off-by: Lee Hannigan <29015211+LeeroyHannigan@users.noreply.github.com>
The server reads the encryption key at startup and keeps it in memory.
The server encrypts an access key created before the restart with the
old key. So the steps are: replace the key, restart every server, then
delete every access key and create a new one.

The new key is 32 random bytes in standard base64. The server checks
only that the key is present, so a value of any other form makes every
signed request fail.

From the restart on, a request signed with an old access key or an
unexpired session credential fails with InternalServerError. Each
client needs its new key, and an admin calls AssumeRole again for each
client that uses session credentials. The web console and extenddb
manage sign in with a password, so they still work for the new keys.
extenddb settings set refuses encryption_key, so the operator replaces
the key in the settings table by hand.

The design guide no longer calls the key immutable. The configuration
design no longer says that the key is not a setting.

Signed-off-by: Lee Hannigan <29015211+LeeroyHannigan@users.noreply.github.com>

@jcshepherd jcshepherd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the updates!

@jcshepherd
jcshepherd added this pull request to the merge queue Nov 11, 2026
Merged via the queue into main with commit 8709626 Nov 11, 2026
50 checks passed
@jcshepherd
jcshepherd deleted the docs/catalog-trust-boundary branch November 11, 2026 19:56
LeeroyHannigan added a commit that referenced this pull request Nov 12, 2026
Main at 06534e1 adds #228, #923, #475, #732 and #900 since the last
merge. One file conflicted: crates/storage-postgres/src/backup_catalog.rs.

#900 moves the insert statement of insert_backup_row into a new
function, insert_unowned_row. The legacy reader's
replace_with_index_row runs that function inside its own transaction.
On this branch, the same insert stores source_table_details_json
through escape_json. The merge keeps main's function and adds the
escape to it, so both callers store the escaped form that
row_from_tuple reads back. The module comment now names
insert_unowned_row in place of insert_backup_row.

Main adds no other write of a catalog document that carries attribute
names. #900's legacy reader takes the source table from restore_source,
which reads the stored documents through from_catalog_json and
unescape_json.

Against main, the merged tree changes the same 44 files, with the same
line counts, as this branch did against its merge base. In
backup_catalog.rs the escape of the unowned insert is in
insert_unowned_row, and the module comment names that function.
LeeroyHannigan added a commit that referenced this pull request Nov 16, 2026
Main added text to two architecture documents after this branch removed
their dashes and wrote the product name as ExtendDB. The backup and restore
design's decision 33 (#740) carried a dash, which is now a colon. The design
guide's two sentences on the credential encryption key (#228) wrote the
product name in lower case, which is now ExtendDB.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-blocker Must ship for its milestone's release security v1 Needed for the 1.0 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants