Grafana: secret_key committed in clear, and port 3000 bypasses Caddy #13

Open
opened 2026-11-16 10:39:01 -05:00 by polen · 0 comments
Owner

Problem

  1. services.grafana.settings.security.secret_key is hardcoded in devices/server/configuration.nix and present in git history (commit 1880856). This key encrypts datasource credentials in the Grafana database.
  2. Grafana binds 0.0.0.0:3000 and port 3000 is open in the firewall, so it is reachable in plain HTTP without going through Caddy.

Fix

  • Move the key to sops and reference it with $__file{/run/secrets/...} (secret owned by grafana).
  • Rotate the key. Datasources are provisioned and hold no credentials, so the rotation cost is low.
  • Set http_addr = "127.0.0.1" and remove 3000 from allowedTCPPorts.
## Problem 1. `services.grafana.settings.security.secret_key` is hardcoded in `devices/server/configuration.nix` and present in git history (commit `1880856`). This key encrypts datasource credentials in the Grafana database. 2. Grafana binds `0.0.0.0:3000` and port 3000 is open in the firewall, so it is reachable in plain HTTP without going through Caddy. ## Fix - Move the key to sops and reference it with `$__file{/run/secrets/...}` (secret owned by `grafana`). - Rotate the key. Datasources are provisioned and hold no credentials, so the rotation cost is low. - Set `http_addr = "127.0.0.1"` and remove 3000 from `allowedTCPPorts`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
polen/nixos#13
No description provided.