·5 min read
Vaultwarden on a game-server panel: hashing the admin token at every start
Vaultwarden's /admin page is protected by an ADMIN_TOKEN, and the safe way to set it is an argon2 hash, not the password itself. A Pterodactyl panel gives a server owner a text field for variables. Nobody is going to run an argon2 command by hand and paste the result into a field. So in the Vaultwarden image I made for the panel (commit 3dcef72), the start script takes a plain password variable and does the hashing itself, on every start.
- Project
- Pterodactyl yolks
- Date
- Oct 2026
- Stack
- Docker, Bash, Vaultwarden, Argon2, Pterodactyl
- Commit
- 3dcef72
The wrapper, not a fork
The Dockerfile starts from vaultwarden/server:1.37.4 and changes only what the panel needs. It adds argon2, tini and a few tools through apt, creates a container user with home /home/container, and installs two scripts. The web vault already ships inside the upstream image at /web-vault, so the image just points WEB_VAULT_FOLDER at it. State lives in DATA_FOLDER=/home/container/data, which is the volume Wings mounts, so reinstalling or updating the image does not touch the vault.
One line is easy to miss: HEALTHCHECK NONE. The comment explains it. Upstream's check probes port 80 through /healthcheck.sh, and nothing listens there once the port follows the allocation. Leaving the inherited check in place would mark a healthy server unhealthy.
Hashing the admin password
The interesting part is vaultwarden-start:
if [[ -n "${VW_ADMIN_PASSWORD:-}" ]]; then
salt=$(head -c 24 /dev/urandom | base64 | tr -dc 'A-Za-z0-9' | head -c 22)
# OWASP parameters, the same ones `vaultwarden hash` uses.
ADMIN_TOKEN=$(printf '%s' "$VW_ADMIN_PASSWORD" | argon2 "$salt" -e -id -k 65540 -t 3 -p 4)
export ADMIN_TOKEN
else
unset ADMIN_TOKEN
say "Renode: no admin password set, the /admin page is disabled."
fiThe Dockerfile comment gives the reason for doing this at all: the plain value never reaches Vaultwarden's own config, and the admin page stops warning about a plaintext token. -id selects argon2id, -k 65540 is the memory cost in KiB, -t 3 the iterations, -p 4 the parallelism, and -e prints only the encoded hash string, which is the form Vaultwarden expects. The comment states that these are the same parameters vaultwarden hash uses.
A new random salt on every start means the token changes every start. That is fine, because Vaultwarden verifies the password you type against whichever hash it was given at that boot. The only effect is that the stored hash is never the same twice.
The salt line was the part I distrusted. The script runs under set -euo pipefail, and head -c 22 closes its input early, which can make an upstream process die of SIGPIPE and fail the whole pipeline. Base64 of 24 bytes is 32 characters, and tr -dc removes +, / and =, so I also wanted to be sure the result is never shorter than 22. I ran the exact pipeline 2,000 times under pipefail on Linux: every run exited with status 0 and produced 22 characters. That is not a proof, but it is the kind of failure that would have shown up as a server that sometimes refuses to start.
The branch that unsets
The else branch matters more than it looks. If the variable is empty, the script runs unset ADMIN_TOKEN instead of leaving it alone. An ADMIN_TOKEN could already be present in the environment the script inherits. Without the unset, clearing the password in the panel would leave the old token active and /admin open. With it, an empty panel field always means "admin page off", and the script says so in the console.
Panel settings versus the admin page
Vaultwarden lets you change settings in the /admin page and stores them in config.json, and those saved values take precedence over environment variables. For a panel that is a trap: a user edits SIGNUPS_ALLOWED in the panel, restarts, and nothing changes. The script checks for the file and says so:
if [[ -f "$DATA_FOLDER/config.json" ]]; then
say "Renode: $DATA_FOLDER/config.json exists; settings saved on the /admin page override the panel's variables."
fiAll messages go to stderr through say, and the script ends with exec /vaultwarden, so the server replaces the shell and receives signals directly. The domain handling follows the same plain style: a VW_DOMAIN that already starts with http:// or https:// is used as is, anything else gets https:// in front, and the result is exported as DOMAIN.
What the design does not solve
The plain password still sits in a panel variable, visible to anyone with access to the server's startup settings. Hashing protects the value inside the container's environment and Vaultwarden's config, not the panel field. The argon2 work also repeats at every boot, with memory cost 65540 KiB; I did not time it, and I would not expect it to matter for a service that restarts rarely, but I have no number for it.
The lesson I keep from this image is that a panel variable should be the thing a human can type. Anything that needs a tool to produce, such as a hash, a salt or a derived URL, belongs in the start script, with an explicit message for each branch where the script chose something on the user's behalf.
#docker#bash#vaultwarden#pterodactyl#argon2
Keep reading
Have a project in mind?