Encryption at rest uses a hardcoded, source-derivable key ("hero_db_default_key"); HERO_DB_ENCRYPTION_KEY is never read #46
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_db#46
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
hero_db's headline "ChaCha20-Poly1305 encryption at rest" runs with a single hardcoded key shared by every instance, and the documented override (
HERO_DB_ENCRYPTION_KEY) is never read. The at-rest encryption therefore provides essentially no confidentiality against anyone with access to the (open) source.Evidence (
main@aacaad1)crates/hero_db_server/src/main.rs:129—let encryption_key = None;crates/hero_db_server/src/main.rs:223—let encryption_key = encryption_key.unwrap_or_else(|| "hero_db_default_key".to_string());crates/hero_db_server/src/lib.rs:133—let encryption_key = "hero_db_default_key";(same constant in the lib entry path)HERO_DB_ENCRYPTION_KEYis advertised in the--helpENV VARSsection (main.rs:118) but there is noenv::var("HERO_DB_ENCRYPTION_KEY")anywhere, and — unlike the RESP port — no hero_proc-secret read for it either.crates/hero_db/src/db/crypto.rsEncryptionKey::from_secret()=SHA-256(secret)→ 32-byte ChaCha20-Poly1305 key. So every value is encrypted withChaCha20Poly1305(SHA256("hero_db_default_key")).The nonce is randomly generated per value (
crypto.rs, 12-byte random prepended) — that part is correct — but the key is universal and recoverable from the public source.Impact
stringsthe binary) can decrypt any hero_db data file.README.md:3, feature list), which overstates the guarantee given the fixed key.Suggested fix
core, keyHERO_DB_ENCRYPTION_KEY) — mirrorresolve_resp_port()which already does this for the port.HERO_DB_ENCRYPTION_KEYfrom the OS-env help section once it's wired through the secret store (see the doc-accuracy issue #44).Notes
Found while verifying the doc-accuracy issue #44 — escalated to its own issue because it is a security/correctness bug, not just stale documentation.