Safeguard
Security Guides•

Where should a fintech app encrypt data: app, database, or disk?

Application, database, filesystem and hardware encryption protect against different threats. Choose by threat model, and keep keys apart from the data.

Safeguard Security Team
4 min read

Encrypt at the layer that matches the threat you are defending against. Disk or hardware encryption protects against stolen equipment. Database encryption helps with stolen files and backups. Application level encryption protects specific fields even from someone who gets into the database. Keep the keys apart from the data in every case.

The four layers

The OWASP Cryptographic Storage cheat sheet lists where encryption can be performed: at the application level, at the database level, at the filesystem level and at the hardware level. It says which layers are appropriate depends on the threat model, and gives a clear example: hardware level encryption is effective against physical theft of the server but provides no protection if an attacker compromises the server remotely.

LayerProtects well againstDoes not help much against
Hardware or diskStolen drives or serversRemote access to a running system
FilesystemOffline access to files and snapshotsAn attacker with the running system's access
DatabaseStolen database files and backupsA user or injection flaw that can query data in the clear
Application, field levelA database dump, and some insidersA fully compromised application that holds the keys

The last row carries a caveat from the same guidance: it may not be possible to fully protect keys from an attacker who has fully compromised the application, but steps can make theft harder.

Start with the threat model

Ask who you are protecting data against. A payments startup might list:

  1. A lost laptop or decommissioned disk.
  2. A leaked database backup in object storage.
  3. SQL injection that reads tables.
  4. A malicious or careless insider.
  5. A compromised application server.

Match each to a layer. Items 1 and 2 are covered by lower layers. Items 3 and 4 benefit from field level encryption with keys outside the database. Item 5 is the hardest and is addressed by limiting what the application can decrypt and by monitoring.

Reduce what you store

The guidance says the strongest protection for sensitive information is not storing it. It singles out card details as especially attractive to attackers and subject to strict PCI DSS storage rules. If a payment provider can hold the data, consider letting it.

Key placement matters as much as the layer

OWASP's key management section lists secure storage options: a hardware security module, a virtual HSM, key vaults from cloud providers, or an external secrets management service. Benefits it names include central management, easy rotation, secure key generation, simpler compliance with standards such as FIPS 140 or PCI DSS, and making keys harder to export.

It also says encryption keys should be stored separately from encrypted data. For example, if data is in a database, keys should not be in that database, so an attacker with SQL injection cannot get both. If keys must live in files or environment variables, the basic rules are: do not hard code keys, do not commit them, protect config files with restrictive permissions, and avoid environment variables where they can be exposed by diagnostic functions.

Algorithms and modes

Use AES with at least a 128 bit key, ideally 256, and an authenticated mode such as GCM or CCM through a maintained library, according to the guidance. It says custom algorithms are not an option. Generate keys with a cryptographically secure random function, not from words or keyboard mashing.

A decision path

  1. List the data you hold and delete what you do not need.
  2. Turn on disk and database encryption, which are usually configuration changes on managed platforms.
  3. For the most sensitive fields, add application level encryption with envelope keys held in a key service.
  4. Separate keys from data and give the application the least decrypt permission it needs.
  5. Document the threat model and what each layer covers, so reviewers see the reasoning.

Where Safeguard fits

Safeguard does not store keys or encrypt your data. Its dependency scanning and reachability analysis cover the cryptographic libraries in your code, and its policy gates help review changes to them. A free scan is available at gold.safeguard.sh/scan.

Quick check

Is disk encryption enough for a payments database?

It protects against stolen hardware and not against remote compromise of a running system. Add other layers according to your threat model.

Can I keep keys in the same database as the data?

Avoid it. If an attacker reaches the database, for instance through injection, they should not get the keys as well.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.