Skip to content

Generate a random [api] secret on Debian install - #1025

Open
SounLabs wants to merge 2 commits into
chirpstack:masterfrom
SounLabs:fix/api-secret-postinst
Open

SounLabs wants to merge 2 commits into
chirpstack:masterfrom
SounLabs:fix/api-secret-postinst

Conversation

@SounLabs

Copy link
Copy Markdown

As discussed over email re: the default [api] secret.

The Debian package ships chirpstack.toml with the placeholder
secret = "you-must-replace-this". Since that value signs login/API
(JWT) tokens, an instance left on the placeholder signs tokens with a
publicly-known key.

This extends debian/postinst to replace the placeholder (or an empty
secret) with openssl rand -base64 32 on first install, mirroring the
existing OpenWrt uci-defaults/90_set_random_api_key behaviour. Only the
placeholder/empty value is rewritten, so an operator's own secret is never
overwritten, and it is safe on upgrade (chirpstack.toml is a dpkg conffile).

Happy to also cover the Docker/systemd path or add an app-level startup
warning when the secret is empty/placeholder, if you'd like — just let me know.

SounLabs and others added 2 commits September 17, 2026 22:43
The shipped configuration uses a fixed placeholder API secret
("you-must-replace-this"). Because this secret signs login and API
(JWT) tokens, an instance left on the placeholder signs its tokens
with a publicly-known key. Replace the placeholder (or an empty
secret) with `openssl rand -base64 32` in postinst on first install,
mirroring the existing OpenWrt uci-defaults behaviour.

Only the placeholder / empty value is rewritten, so an operator's own
secret is never overwritten and it is safe on upgrade (chirpstack.toml
is a dpkg conffile).
The api.secret value signs login and API tokens (HS256 JWT). When it is
left empty or set to the example placeholder ("you-must-replace-this"),
the signing key is known and tokens can be forged, bypassing
authentication. Log a warning once during API setup so operators running
an unconfigured or example-derived config are alerted.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant