Documentation Index

Fetch the complete documentation index at: https://docs.revsure.cloud/llms.txt

Use this file to discover all available pages before exploring further.

Skip to main content

Security: Keys, Credentials and Tokens Stored with Revsure

Overview

RevSure protects sensitive values (API keys, Client Credentials, Oauth or API tokens) by encrypting them with Google Cloud Key Management Service (KMS) before storing in the database. Each sensitive value is encrypted using a specific CryptoKey, allowing for strong isolation, granular control, and easier rotation.

How It Works

  1. CryptoKey Management

    • We maintain different KMS CryptoKeys for different contexts (e.g., per service, per tenant, or per data domain).

    • Each CryptoKey has a unique identifier and usage policy.

  2. Encryption Flow

    • Application calls encrypt() and passes the right CryptoKey.

    • Google KMS encrypts the value using that CryptoKey.

    • The application receives ciphertext bytes, Base64-encodes them, and stores them in the database.

  3. Decryption Flow

    • When needed, the application calls decrypt() with the same CryptoKey reference.

    • KMS verifies IAM permissions and returns the plaintext securely.

Why Multiple CryptoKeys?

1. Granular Access Control

  • Different applications or teams can be granted access only to the keys they require.

  • Even if one key is compromised (misconfigured), it does not grant access to other data.

2. Blast Radius Reduction

  • If a key ever needs to be revoked, only the subset of data encrypted with that key is affected.

  • This makes incident response faster and safer.

3. Easier Rotation Policies

  • Keys can have independent rotation schedules.

  • Example: Customer data keys rotated every 90 days, internal system keys every 180 days.

4. Audit & Traceability

  • KMS logs show which key was used to encrypt/decrypt each piece of data.

  • This helps with compliance and forensic investigations.

Security Benefits

  • Keys stay inside KMS — Application never handles raw keys.

  • IAM + CryptoKey separation — Different keys allow role-based restrictions at a fine-grained level.

  • Automatic Key Rotation — Each CryptoKey can rotate on its own schedule.

  • Audit Logging — Each encryption/decryption operation tied to a specific CryptoKey and identity.

  • Defense-in-Depth — Even with DB compromise, encrypted values are useless without both:

    • Access to the correct CryptoKey in KMS.

    • Proper IAM permissions.

Best Practices

  1. Key Scoping

    • We use separate keys per environment (dev, staging, prod) as well as per region (US, Europe).

    • We use per-tenant, per-service CryptoKeys to ensure data isolation.

  2. Key Rotation

    • We enable automatic rotation in KMS.

    • Review rotation intervals based on data sensitivity.

  3. Least Privilege IAM

    • Grant roles/cloudkms.cryptoKeyEncrypterDecrypter only to service accounts that require it.

    • Avoid giving wide access to multiple keys.

  4. Audit Monitoring

    • Regularly review Cloud Audit Logs for unusual access patterns.

  5. Envelope Encryption for Scale

    • For high throughput, we generate a Data Encryption Key (DEK) per object, encrypt the DEK with KMS, and use DEK for local encryption.

    • Store (Encrypted DEK + Ciphertext) together.

Summary

By encrypting sensitive values with different Google Cloud KMS CryptoKeys, we gain:

  • Stronger isolation between datasets.

  • Fine-grained IAM controls.

  • Reduced blast radius in case of compromise.

  • Flexible key rotation policies.

This ensures that even if attackers gain access to the database, they cannot retrieve plaintext values without both the correct CryptoKey and the appropriate IAM permissions.