Skip to main content

Secrets security and how it differs from Passwords β€” Master Key, encryption and overall architecture

Β· 10 min

When you hand over your passwords, tokens and access keys to an external service, the main question is whether you can trust it. That's why we decided to show how Tuna Secrets security works under the hood: where the Master Key is stored, what algorithm encrypts data, and β€” most importantly β€” what happens if our infrastructure is breached and the entire database leaks.

In short

Secret values are encrypted before being written to the database using AES-256-GCM. The key needed to decrypt them is not in the database. A leaked DB dump without the Master Key is just a useless set of encrypted data.

Passwords and Secrets: two different security models​

Tuna has two storages for sensitive data β€” the Password Manager and Secrets. They are intentionally built differently because they solve different problems.

Model comparison: passwords are encrypted on the client, secrets on the server

Password Manager β€” zero-knowledge model. Encryption keys are created on your device and never leave the client β€” the browser or app. Encryption and decryption happen only on your side, and only encrypted text is sent to the server. The underlying principle: compromising our infrastructure must not lead to compromising your passwords β€” they can only be decrypted where the Master Key exists, and only you have it. The trade-off is that data is only accessible to the Master Key holder: automatically delivering a password to a script or pipeline without revealing it is impossible in this model.

Secrets β€” server-side encryption. Here the Master Key is on the platform side, and the server performs the encryption. This is a deliberate compromise, made for the primary secrets use case β€” automation. A secret must reach the application at startup, the CI/CD pipeline, the deployment script β€” all on its own, without human involvement. Launching an app with injected variables, service keys for CI, automatic restarts on value changes β€” all of this works precisely because the server can deliver a secret on request from an authorized client, without requiring a master password every time.

The price of this convenience is trust in the platform's infrastructure β€” technically the server can decrypt a secret. So everything described below is about how we justify that trust.

PasswordsSecrets
ModelZero-knowledgeServer-side encryption
Where the key livesClient onlyPlatform side
Where encryption happensOn the clientOn the server
Can Tuna read the dataNoYes, for authorized operations
Automation (CI/CD, scripts)LimitedFull
Primary use caseStoring and sharing passwordsDelivering configuration to applications

Secrets trust model​

Since the server can decrypt secrets, the core principle is: the database must not contain anything that can be used to decrypt secrets. Even if an attacker gets a full table dump, there shouldn't be enough material in it to obtain the original values.

This is achieved through a classic envelope encryption scheme β€” a two-level key hierarchy.

Envelope encryption: two levels of keys​

Key hierarchy: the Master Key wraps the team key, the team key encrypts secret values

There are two levels of keys in the system:

  1. Platform Master Key (KEK, Key Encryption Key). Stored on the Tuna side and never enters the database. It doesn't encrypt any user data directly β€” its only job is to "wrap" (protect) team keys.

  2. Team Key (DEK, Data Encryption Key). A unique random key is generated for each team using a cryptographic random number generator. This is what encrypts the secret values for that team.

The team key is not stored in plaintext: it's encrypted with the Master Key and stored in the database in this "wrapped" form. To use it, the server first unwraps it with the Master Key in memory.

This creates a chain of dependencies: secret values are protected by the team key, and the team key is protected by the Master Key. Break any link, and you can't proceed further.

Interestingly, the Password Manager is built on the same envelope encryption concept β€” with two key differences: the "envelope" is sealed asymmetrically, using a public/private key pair, and the root key stays on the client side rather than the server. The scheme is the same; only the trust distribution differs: secrets are tuned for automation, passwords for zero-knowledge.

Where and how the Master Key is stored​

This is the critical question for the entire scheme, so let's examine each storage location:

  • Not in the database. The Master Key is fundamentally separated from the data it protects. It's not in the dump.
  • Not in the code or repository. It's not hardcoded in the source β€” it's passed to the service from outside, from the platform's secure configuration storage.
  • Only in process memory. The server holds the key in RAM while running and doesn't write it to disk in plaintext.
  • A full 256-bit key. This is enough to make brute-force computationally infeasible.

The key takeaway: access to the database and access to the Master Key are two different access levels with different permissions. Compromising one does not automatically mean compromising the other.

Secret lifecycle: write and read​

Encryption and decryption are built into the data layer and happen transparently β€” the application never writes a plaintext value to the database and never reads one directly from it.

Sequence of saving and reading a secret: encryption before write, decryption after read

On save, the value is encrypted with the team key before writing. A unique random nonce is used for each value β€” so even two identical secrets look different in the database. Only encrypted text enters the storage.

On read, the reverse process happens: the server retrieves the ciphertext, unwraps the team key, and decrypts the data. The plaintext value exists only in process memory for exactly as long as needed to deliver it to the authorized client.

We use GCM (Galois/Counter Mode) β€” this is authenticated encryption. Beyond confidentiality, it guarantees integrity: if someone changes even a single byte of the encrypted data in the database, decryption won't return garbage β€” it will honestly fail with a verification error. Forging or silently replacing a value while bypassing the server is impossible.

In transit, everything is additionally protected by TLS β€” data travels between your client and the API over an encrypted channel.

What's encrypted and what's plaintext in the database​

A breakdown of what data is actually stored in the database and in what form:

Encrypted (AES-256-GCM)Plaintext
Secret valuesVariable names
Secret notesValue types
Team key (in wrapped form)Visibility level
Structure: projects, environments, configurations
Creation and modification timestamps

Yes, metadata is also information. Even without seeing the values, variable names can reveal which services and technologies you use. The secrets themselves remain encrypted. But this is again a small compromise in favor of convenience and performance.

What happens if the database leaks​

This is the scenario the entire scheme was built to prevent. Imagine the worst: an attacker gets a full dump of our database.

Threat model on database leak: without the Master Key, decrypting values is impossible

What they have:

  • Encrypted secret values β€” AES-256-GCM ciphertext, statistically indistinguishable from random noise.
  • The team key β€” but it's encrypted with the Master Key.
  • Metadata β€” names, types, project structure.

What they don't have:

  • The Master Key. It's not in the database β€” it's on the server side, which a database dump doesn't grant access to.

The chain breaks at the very first step. To decrypt a value, you need the team key. To unwrap the team key, you need the Master Key. The Master Key isn't in the dump, and brute-forcing AES-256 is impossible. Secret values remain protected. The attacker sees only the skeleton: names and structure, but not the content.

Protection boundaries​

No scheme protects against everything, and it's important to understand its limits:

  • If both the database AND the Master Key leak simultaneously β€” the protection falls. That's precisely why they're stored separately, with different access permissions: so that a single vulnerability doesn't expose both levels at once.
  • Metadata is visible in a database leak β€” as mentioned above.
  • Incident response. If compromise is suspected, the right step is rotation: changing the Master Key, reissuing service keys, and updating the secrets themselves at their sources. Service keys can be issued with limited lifetimes exactly for such cases.

Additional layers of protection​

Encryption is the foundation, but not the only layer. Access to secrets is restricted at several more levels:

  • Restricted values. A secret with this visibility is not returned via the API and doesn't appear in exports β€” even an authorized user sees only the fact that it exists.
  • Scoped service keys. For CI/CD, keys are issued tied to a specific configuration, with read-only or read-write permissions, and an optional lifetime. Leaking such a key doesn't open access to all team secrets.
  • IP restriction (Trusted IP). Access to a configuration can be limited to a list of allowed addresses and subnets in CIDR format.
  • Full audit. All changes within configurations are logged β€” you can see who changed each secret and when.

What's planned​

Currently Tuna Secrets is a centralized and encrypted storage. The logical next step is to make it a source of truth from which secrets are automatically synced to wherever they're needed.

Plans: syncing secrets from Tuna to Vault, Kubernetes Secrets, GitHub and GitLab CI/CD

Planned integrations for one-way synchronization:

  • HashiCorp Vault β€” pushing secrets to Vault, so Tuna becomes a convenient management interface while applications continue reading them the usual way.
  • Kubernetes Secrets β€” syncing a configuration directly into secrets of the required namespace in the cluster.
  • GitHub Actions β€” publishing to encrypted secrets of a repository or organization for use in pipelines.
  • GitLab CI/CD β€” syncing to CI/CD variables of projects and groups.

The idea is that you edit a secret in one place, and it automatically and securely reaches all your environments β€” without copying values between a dozen panels.

Summary​

Tuna Secrets security rests on several simple and proven principles:

  • Two models for two tasks β€” passwords are encrypted on the client (we can't see them), secrets on the server, for the sake of automation.
  • AES-256-GCM β€” authenticated encryption of values before writing to the database.
  • Envelope encryption β€” the Master Key protects team keys, team keys protect data.
  • The Master Key is separated from data β€” it's not in the database, not in the code, and a leaked DB dump is useless.
  • Access layers on top β€” visibility, service keys, IP restrictions, and audit.

We don't pretend the protection is absolute, and we openly show its boundaries β€” because trust is built on transparency, not marketing promises.

Leave feedback​

If you enjoy using Tuna, or on the contrary you are not happy with something, please leave feedback.

News​

We announce new features and posts on our Telegram channelOpens in a new tab. Subscribe so you don't miss anything.

Help​

We value our users and carefully review every request. If you have any problems with tuna, please contact us in one of the following ways: