chore: encrypt tenant NWC URL at rest and stop secret exposure in tenant APIs #58
Reference in New Issue
Block a user
Delete Branch "userAdityaa/caravel:encrypt-tenant-key"
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?
Summary
This PR fixes #57 by encrypting tenant NWC URLs in storage, decrypting only for internal backend use, and redacting tenant API responses so secrets are never returned to clients.
Problem
Tenant NWC URLs were stored in plaintext and exposed through tenant API payloads, creating a high-risk secret leakage path.
closes #57
@@ -0,0 +107,4 @@.decode(value).or_else(|_| base64::engine::general_purpose::URL_SAFE_NO_PAD.decode(value)).map_err(|e| anyhow!("NWC_URL_CIPHER_KEY must be 32-byte hex or base64: {e}"))}What if we just used nip 44? It would keep things a little lighter, one fewer dependency.
@@ -40,0 +61,4 @@}Ok(())}We don't need the migration, no data exists yet.
This all feels very coupled, can't we just parse the key and encrypt using rust-nostr? The nwc_url_cipher file seems like it should be unnecessary
I’ll dig into this further and assess whether it can be simplified and updated accordingly.
This feels both over and under-engineered. The NWC url is just a string field, on write it should be encrypted and stored, when sent to the frontend it should be converted into nwc_is_set or whatever. When we need to use it, we can decrypt on demand.
Some concrete changes:
@@ -39,0 +77,4 @@return Err(anyhow!("unsupported legacy encrypted nwc_url envelope; re-save tenant configuration"));}Why would this ever be true?
Sorry, that was an oversight on my side. Removed the unnecessary guard.
af3f48168fto95f9f0c0bfApologies for the code changes earlier, I’ll make sure to be more careful when submitting changes for review in future PRs.
Way better, thanks.