Secrets on servers: why plaintext is a risk
Updated: 26 October 2026
On many servers, database passwords, API keys and tokens sit in plaintext: in a .env next to the application, in a deploy script or directly in docker-compose.yml. That is convenient – and exactly where a small mistake turns into serious damage.
Where secrets usually live on servers
- .env files in the project folder, often in the same directory the web server serves or the backup includes.
- Deploy scripts with lines like
docker run -e DB_PASSWORD=secret …. The value then ends up in the command line, the shell history, the process list anddocker inspect. - docker-compose.yml with fixed values under
environment:. The file quickly lands in the Git repository and with everyone who clones it. - Configuration files such as
config.php,application.ymlorsettings.jsonwith credentials that simply travel along when copied to a new server.
How plaintext secrets get out
An attacker rarely has to "crack the server". More often a single weakness that makes files readable is enough – and the secrets are lying right next to it.
A vulnerability in the application
A vulnerability in the application or one of its libraries often allows reading arbitrary files or running code. Whoever can run code inside the application's process reads its environment variables and every file the process may read. A .env in the working directory is the first thing to grab.
Path traversal
With a path traversal flaw, the application builds a file path from user input without properly rejecting ../. Instead of an image or a document, it then serves ../../.env or ../config/database.yml. Such flaws have been on the lists of the most common web vulnerabilities for years.
A misconfigured web server
If the .env sits below the web root and the web server does not explicitly deny access, it can be fetched at https://example.com/.env. Automated scanners request exactly this address on a great many servers, along with /.git/config and typical backup files such as config.php.bak.
Backups, images and logs
Plaintext secrets travel into every server backup, into virtual machine snapshots and into container images when the file is copied in during the build. Error messages and debug output occasionally write environment variables to the log, and logs are often forwarded to other services. Every copy is one more place where the value can be read – often with much weaker protection than the server itself.
People and tools
A value that was once sent in a chat, copied to the clipboard or typed into a one-liner remains in the chat history, the clipboard history or the shell history. Whoever leaves the team still knows it.
What a solution has to deliver
- No plaintext on disk. The server only holds an encrypted file. The value exists in plaintext only in the memory of the process that needs it.
- No plaintext at the provider. The service that manages the secrets must not be able to read them either. A leak there must not reveal a single value.
- Access per person and per server. Every person and every machine has its own key, which can be revoked individually.
- No values in command lines. Neither in the deploy script nor in the console.
How Secrets solves this
Zero-knowledge and end-to-end encryption
Secrets encrypts every value in your browser or in the command-line tool secrets-tool before it leaves your computer. A project is one file, secrets.enc: the content encrypted once, plus for each authorized person their own copy of the data key, encrypted with their public key. The server only stores this file. It knows neither your vault password nor your private key nor any plaintext value. Details are under How it works and Security.
Values only at runtime
Once secrets-tool is set up on the server, it fetches the encrypted file and decrypts it straight into the environment variables of the deploy process:
secrets-tool remote pull shop-backend eval "$(secrets-tool export | sed 's/^/export /')" ./start-app.sh
In PowerShell this is enough:
secrets-tool remote pull shop-backend Invoke-Expression (secrets-tool load)
Only secrets.enc is on disk. Whoever copies it without the key gets nothing. More under Use in deployments.
Docker hosts without the CLI: hostenv
If the server only runs Docker, secrets-tool hostenv writes the env files onto the host from your own computer – with mode 600, without any value appearing in the console or in a command line:
secrets-tool hostenv --target /opt/app/api.env --map DB_PW=SPRING_DATASOURCE_PASSWORD --map JWT_SECRET --ssh root@server
The deploy one-liner then only contains --env-file /opt/app/api.env and a check with secrets-tool hostenv --guard that the file matches the current state. Instead of docker run -e DB_PASSWORD=…, no value is left in the script. Guide: Bring env files to the host.
Device approval instead of a password in a script
On your own computer, secrets-tool unlock --device removes the password prompt for good. The approval can be revoked at any time in the web app under My access – for example when a laptop is lost. Servers and pipelines each get their own API token, which is revoked just as individually (Connect the CLI directly).
Find mistakes before they go live
secrets-tool check scans a repository for plaintext values, private keys, tokens, passwords in configuration files and deploy scripts with -e NAME=value. As a pre-commit hook (secrets-tool check --hook) it stops a commit before a secret lands in the history. See Check a repository.
Checklist for your server
- Is there a
.envor configuration file with plaintext passwords anywhere? Move the values into a project and replace the file withremote pullplusload/export, or withhostenv. - Are values in deploy scripts or in
docker-compose.yml?secrets-tool checkshows the places with file and line. - Have values ever been in plaintext on a server, in a backup or in the Git history? Then treat them as known: rotate them, don't just move them.
- Does every server and every pipeline have its own token? Only then can a single access be revoked.
Get started with the secrets-tool download and the five-step guide. How supply chain attacks exploit exactly these plaintext values is described in Supply chain attacks on npm and Composer.