// Engineering Log
Secrets and Zero Trust: Part 1 — Threat Model and Principles
Published on 2026-11-16 · Author: Mikhail Gorbachev
// Fast route
This article belongs to the topic Deploy and reliability.
Secret — any data that by itself grants access: a password, API token, private SSH key, encryption key, master password of a password manager. The main problem with secrets is not that they are hard to store, but that they get copied to many places: the same token ends up in code, in a CI variable, in a build log and in chat. The zero trust approach answers this with a simple rule: the location where a request originates gives it no rights. Every access is re-evaluated, granted for a time and with least privilege.
This article — without installation or commands — explains what counts as a secret, where secrets leak, which threats to protect against, what NIST SP 800-207 and OWASP say about access, and which layers make up a practical scheme.
What counts as a secret
A secret is anything that allows you to pass authentication as someone else or read protected data:
- account, database, control panel or router passwords;
- API tokens and keys for clouds, payment systems, DNS providers, bots;
- private SSH keys and private parts of TLS certificate keys;
- disk encryption keys, backup and archive keys;
- CI runner registration tokens and service account tokens;
- the password manager master password and its session key;
- two-factor recovery codes.
The last two items are often forgotten. A password manager session key for the session allows reading and modifying the vault just like after unlocking. Recovery codes bypass the second factor, so they should not sit next to the password.
Not a secret — username, server address, public key. Their leak makes an attack easier but does not grant access. This distinction is important: public data can be kept in a repository and documentation, secrets cannot. For public repositories decide separately: server addresses and account names facilitate reconnaissance.
Where secrets live and how they leak
A secret does not leak from the vault but from the places where it was copied. Typical places:
- Code and Git history. Removing a secret in the next commit fixes nothing: the old version of the file remains in history and in all clones. The order of actions for such a leak is described in the article “Secure development: Part 2 — Secrets in code”.
.envfiles. Convenient in development but stored on disk as plain text, they end up in project archives, backups and container images if not explicitly excluded.- CI/CD variables. A project variable is available to pipeline jobs, and therefore to anyone who can change the job configuration; protected branches narrow this. GitLab documentation explicitly warns that masking a variable does not guarantee protection from an attacker: a modified value (for example, with shell-escaped characters) will not be masked, and to prevent
envandprintenvfrom printing the secret it recommends external secret stores and File variables. - Logs. Debug output, an error trace with connection parameters, a web server log with a token in the request URL. Logs are often retained longer and are accessible to more people than the secret store.
- Correspondence. A password sent in a messenger or email remains in both parties’ history, on their devices and in the service’s backups.
- Backups. A server copy contains configs with passwords,
.env, keys. If the copy is not encrypted, its theft equals the theft of all these secrets. - Disks and media. A decommissioned disk, a single-board computer SD card, a laptop left in a taxi. Anything stored there in plain text can be read without the system password.
From this follows the first practical rule: the fewer places a secret exists in plain text, the fewer leakage routes. Every extra copy is another place from which the secret can be stolen.
Threat model
A threat model answers two questions: who and by what method can obtain a secret, and which of these methods you close. Below are five typical scenarios for a small infrastructure; the list is not exhaustive, add your own.
Theft of media. An attacker obtains a disk, memory card, laptop or a copy of a VM image. They can read files but do not control a running system. Protection: secrets on disk are stored only encrypted, and the decryption key is not on the same disk.
Compromised runner or dependency. A malicious package from a registry, a compromised CI action, or a hacked build server runs code in the same environment where secrets are available. Such code sees environment variables and job files. Protection: give a job only the secrets it needs and only for the job duration; pin dependency versions; do not run untrusted code where it has access to production secrets.
Log leakage. A build log, application debug output or centralized logging system becomes accessible to outsiders. Protection: do not print secrets at all; masking is insurance, not a security measure.
Merge request from a fork. An outsider proposes a change that runs their code in CI. If such a job receives repository secrets, they will get them. GitHub Actions does not pass secrets to workflows run from forks (except GITHUB_TOKEN) and recommends avoiding the pull_request_target event where code from the request runs with access to secrets. In Gitea a job token for requests from forks is always read-only, and running jobs from forks of other users may require approval (rules depend on Gitea version).
Former employee or contractor. Someone left but remembers passwords they saw, keeps a copy of .env or exported the vault. Disabling their account does not revoke shared passwords they knew. Protection: personal accounts instead of shared ones, access via groups and collections that can be removed with one action, and rotation of all shared secrets they could access.
Separately: what this model does not protect against — root on the machine where the secret is used, and a process of the same user while the vault is open. If an attacker controls a workstation during operation, they see what you see.
Zero trust according to NIST SP 800-207
The NIST SP 800-207 “Zero Trust Architecture” (August 2020) defines zero trust as a set of ideas aimed at minimizing uncertainty when making precise access decisions with least privilege for each request, assuming the network is compromised.
The document is about networks and services. Below its seven tenets are mapped to working with secrets: the mapping is made by the author of this article and is not in the document.
- All data sources and computational services are resources. For secrets: password manager, CI runner, admin workstation, router — each is a resource with its own access rules, not a “trusted part of the infrastructure.”
- All communication is protected regardless of network location. Being on an internal network does not grant trust. For secrets: a password manager inside the internal network still operates only over HTTPS, and secrets are not transmitted in plain text even inside a VPN.
- Access to each resource is granted per session with the minimal necessary privileges. For secrets: the vault is opened per session and closed afterwards, a CI job receives a token for the job duration rather than a permanent key.
- Access is determined by dynamic policy considering client, application, device state, behavioral and environmental attributes. For secrets: production secrets are available only from protected branches and environments, vault login requires a second factor, and unlocking on a workstation uses a hardware key.
- The organization monitors the integrity and state of all assets; none are trusted by default. For secrets: runners and workstations where the vault is opened are updated and checked like servers, and runner state is considered when issuing secrets; a runner that builds untrusted code does not receive production secrets.
- Authentication and authorization are dynamic and strictly enforced before granting access. For secrets: every vault login and every token issuance goes through a full check; “log in once — then everything is allowed” is not permitted.
- The organization collects as much data as possible about asset, network and communication state and uses it to improve protection. For secrets: logging of vault accesses and usages, alerts on failed attempts, regular review of who has access to what.
A short guideline for everyday work (author’s wording, not NIST) — five rules: session-scoped access, least privilege, dynamic policy, monitoring, continuous verification.
What OWASP advises
The OWASP Secrets Management Cheat Sheet describes the same ideas at a practical level:
- Centralization. Secret management is gathered in one system and standardized; OWASP recommends keeping an inventory: why each secret exists and where it is stored.
- Least privilege. Access is granted at the level of individual objects, not “to the entire vault”; production and development secrets are better kept in separate systems.
- Dynamic secrets. When possible, secrets are created for a short time for a specific task. OWASP notes separately that restarting an application does not revoke already stolen data.
- Rotation. Secrets are changed regularly, preferably automatically; OWASP suggests changing human account passwords if compromise is suspected.
- Audit. An append-only or tamper-evident log: it is useful to see who requested a secret, when it was used, failed authentication attempts and changes.
- Secrets are not stored in plain text. They are not provided to Docker via
ENVandARG, not committed to a repository, and are scanned for before commit.
NIST and OWASP recommendations converge on the main point: access for a time, with least privilege and logged; OWASP additionally recommends centralizing and standardizing secret management.
Which layers make up the scheme
The cycle examines a scheme for a small infrastructure. At its center is the password manager Vaultwarden, which in this cycle serves as the secrets store: an unofficial server implementation compatible with Bitwarden clients that you deploy yourself behind a reverse proxy with HTTPS (“Password managers: Part 3 — Bitwarden and Vaultwarden”). Vault entries are encrypted on the client, so the server stores entry contents in encrypted form; account metadata (email addresses, organization membership, KDF parameters) are stored in the clear. On servers and in scripts Bitwarden CLI (bw) works with the vault: the secret is retrieved at the moment of use, not stored in the script or .env; bw itself keeps a local copy of the encrypted vault and the session key for the duration of its operation. A FIDO2 hardware key works as a second factor in the web vault (FIDO2 login is not supported in bw itself: there are TOTP, e-mail and YubiKey OTP options or API key login). For unlocking by touch the cycle uses its own wrapper rather than Bitwarden’s feature: the master password is stored on disk encrypted by a key secret. The same key stores the private part of SSH keys of type ed25519-sk: without the connected device signing is not possible. The final layer is CI/CD: job secrets are issued by branch and environment, and where the platform supports it, short-lived OIDC tokens are used instead of permanent keys.
| Layer | What threat it mitigates | What it doesn’t mitigate |
|---|---|---|
| Vaultwarden | scattered secrets in files and correspondence; disclosure of entry contents if the server database is stolen, while the master password is strong (the database can be brute-forced offline); employee departure — access is removed via organizations and collections | weak master password; a compromised user machine with the vault open; dynamic secrets: as of 12.10.2026 Vaultwarden does not support Bitwarden Secrets Manager (bws) |
| Bitwarden CLI | secrets in plain text in scripts and .env | a process of the same user or root while the session is open: the session key grants access to the vault |
| FIDO2 hardware key | storing the master password on disk in plain text; theft of media if the master password cannot be decrypted without the key | a person who has both the machine and the key, if touch does not require a PIN; loss of the only key without a spare |
| SSH keys on FIDO2 | theft of the private key file: the file contains only an identifier, the private part never leaves the device | actions of an attacker on the client while the key is connected and the user touches it on request |
| CI/CD | permanent keys in project settings (use OIDC instead); giving production secrets to unprotected branches and forks | printing a secret to the log in a modified form; a compromised runner that executes a job with secrets |
No single layer covers everything. The point of the scheme is that an attacker must overcome several defenses, not just one; they are not all independent: some rely on a single workstation.
Honest limitations
Zero trust does not make a system invulnerable. It is good to know the limits of the approach in advance.
- The endpoint remains a weak spot. While the vault is open, secrets are available to your user’s processes and to root. Closing sessions after work, hardware keys and short-lived tokens reduce the window but do not eliminate it.
- Self-hosting is your responsibility. Updates, backups, HTTPS, protection against password guessing and the Vaultwarden admin panel are on you. A Linux server needs the usual basic protection: firewall, Fail2ban, auditing (the cycle “Linux server protection”, starting with the article “Linux server protection: Part 1 — UFW firewall”).
- There are few dynamic secrets in this scheme. Most secrets in the password manager are static; rotation protects them rather than short lifetime. Short-lived tokens are available where the platform issues them: OIDC tokens for jobs in GitLab and GitHub. According to Gitea documentation as of 12.10.2026 the
id-tokenscope is not supported, meaning Gitea Actions does not issue an OIDC job token. - Masking in CI is not protection. Both GitLab and GitHub warn that modified values will not be masked. The only protection is that the secret does not get into a job that does not need it.
- Convenience versus strictness. Every additional check slows work. If rules are too inconvenient, people will bypass them: keep a password in a note, disable the second factor, give a token all permissions. Build the scheme so that the secure path is also the shortest.
- Recovery after loss. A hardware key cannot be copied. Without a spare key pre-registered in all services and without recovery codes, losing the device means losing access.
Checklist
- Create an inventory of secrets: what they are, what they are for, where they are stored, who has access. Without an inventory you cannot rotate or revoke.
- Move secrets from
.env, configs, notes and correspondence into a single vault; leave only variable names in repositories. - Check Git history and CI logs for old secrets; first rotate the found secret with the provider, then clean history.
- Replace shared accounts with personal accounts, and grant access to shared secrets via groups and collections.
- Enable a second factor for vault login; a FIDO2 hardware key is better, and register a spare immediately.
- Separate production and development secrets; give production secrets only to protected branches and CI environments.
- Forbid passing secrets to jobs from forks and do not run untrusted code on runners with access to production secrets.
- Where the platform supports OIDC, replace permanent keys in CI with short-lived tokens.
- Set rotation periods and procedures for employee departure: which shared secrets are changed and who does it.
- Enable logging of vault accesses and alerts for failed logins; encrypt vault backups and verify recovery.
// Similar task
If you are dealing with something similar
This article belongs to one of the main working topics. You can keep reading on the topic, go to the homepage to understand what I do, or open the service pages directly.
Article topic
Deploy and reliability
Docker, CI/CD, releases, monitoring, observability, and incident handling.
Typical tasks behind this topic
- Set up deployment without manual chaos
- Add monitoring, alerts, and baseline observability
- Investigate incidents and stabilize production
// Next step
If you need help with this topic, not just another article, it is better to go straight to the service page. The homepage and topic collection stay available as secondary routes.
Open services// Reviews
Related reviews
I came with an expensive request to configure a VPS server, but during the consultation Mikhail suggested a much simpler, more affordable solution. In the end I saved time and money. Mikhail — a true expert who works for the client's result, not for the fee. I recommend him!
I came with an expensive request to configure a VPS server, but during the consultation Mikhail suggested a much simpler and more cost-effective solution. In the end I saved budget and time. Mikhail — a true expert who …
VPS setup, server setup
2026-05-12 · ★ 5/5
Excellent work! Set up the server very quickly, installed the control panel, and configured the IP. Definitely recommend!
Excellent work! Very quickly set up the server, installed the panel, configured the IP I can definitely recommend it!
Everything was excellent; helped promptly and professionally. Thank you — I recommend them to the community.
Everything's great, helped promptly and professionally, thank you, I recommend it to the community
VPS setup, server setup
2026-04-16 · ★ 5/5
There were several issues concerning both the technical side and overall understanding. Mikhail responded quickly, resolved the technical problems, and helped me understand them — many thanks. I'm satisfied with the result.
There were several issues concerning both the technical side and overall understanding. Mikhail responded quickly to the request, helped sort things out and resolved the technical problems and helped clarify …
VPS setup, server setup
2026-02-18 · ★ 5/5
Everything was done quickly and efficiently. I recommend.
Everything was done quickly and efficiently. I recommend.
VPS setup, server setup
2026-01-17 · ★ 5/5
Everything went well; the contractor responded quickly to questions and helped resolve the issue. Thanks!
Everything went well, the contractor responded quickly to questions and helped resolve the issue. Thank you!
VPS setup, server setup
2025-12-16 · ★ 5/5
// Contact
Need help?
Get in touch with me and I'll help solve the problem
I reply within one business day (03:00-13:00 GMT)
Or leave a request here:
// Related