Security fixes are provided for the latest release only; there is no long-term support branch.
| Version | Supported |
|---|---|
| latest | yes |
| < latest | no |
Please report security vulnerabilities using GitHub Security Advisories for this repository rather than opening a public issue. This allows a fix to be prepared and released before the details become public.
If GitHub Security Advisories are not available to you, open an issue with minimal detail asking for a private contact channel, and a maintainer will follow up.
Please include:
- A description of the vulnerability and its potential impact
- Steps to reproduce (Pi model, OS/distribution, PiMonitor version)
- Any relevant logs or configuration (with secrets/API keys redacted)
We aim to acknowledge reports within a few days and to release a fix as soon as reasonably possible depending on severity.
These notes summarize the security-relevant design decisions in PiMonitor so reporters and reviewers have context:
- The main
pimonitorservice runs unprivileged, as a dedicated system user with no special capabilities. It only reads world-readable files under/proc,/sys/class/thermal,/sys/devices/system/cpu/*/cpufreq,/sys/class/hwmon,/etc/os-release,/var/lib/dpkg/status, and the existing apt cache under/var/lib/apt/lists/(via the read-onlyapt-cache dumpavailcommand) and, when Pi-hole is installed, the world-readable/etc/pihole/versions, plus the optional, fixed-argumentvcgencmd measure_temp/measure_temp pmic/get_throttledcalls. It never invokes anything that requires root. Its only extra privilege is membership in thevideogroup (SupplementaryGroups=videoinpimonitor.service), which Raspberry Pi OS requires for opening the firmware devicevcgencmduses (/dev/vcio_gencmdon current releases,/dev/vchiqon older ones). The group grants access to GPU, framebuffer, camera (V4L2) and firmware-mailbox devices (the mailbox also accepts write-type property calls), but not to root. - openHAB status makes the service an HTTP client of its own machine, and only of that. When
openhab.enabledis notfalse, the service reads the existence and owner of/usr/share/openhab,/etc/openhaband/var/lib/openhab, thecmdline,statandstatusfiles of other users' processes under/proc(withhidepid=mounted they are not visible, and the openHAB values then degrade to absent) and/proc/net/tcpand/proc/net/tcp6, and sendsGETrequests toopenhab.base_url. That URL must behttpwith a loopback host; the connection is checked against a loopback address again when it is made, no proxy is used, redirects are not followed, each request has a 5 s timeout and at most 8 MiB of a response is read. See decision 0013. - The openHAB API token (
openhab.api_tokenin the config file, mode640 root:pimonitor, orPIMONITOR_OPENHAB_TOKEN, loadable from the same restrictedEnvironmentFile=) is sent only as anAuthorization: Bearerheader tobase_url, only when set, and only over a connection whose server side runs as the owner of/var/lib/openhab: the connection's own entry in/proc/net/tcpor/proc/net/tcp6is looked up before any byte is sent, so a local user who binds openHAB's port while openHAB is down does not receive it. When the directory is missing, the lookup fails or the platform is not Linux, the token is not sent. It never appears in a log line, inGET /api/v1/openhab, inGET /api/v1/configor in any other response. With anopenhab.api_tokenset,GET /api/v1/openhabserves Thing UIDs, labels and status descriptions that openHAB itself serves only to authenticated users (GET /metricsserves their counts per status); the same Thing UIDs and labels (up to 10, each string cut to 256 bytes) also appear inopenhab_things_offlineevents ofGET /api/v1/alertsand in webhook payloads, which leave the Pi for the configured endpoints; setapi_keyif the LAN should not read them. After an upgrade with anopenhab.api_tokenset and alerts on, every webhook whosemin_leveladmitswarnreceives the UIDs and labels of up to 10 offline Things inopenhab_things_offlineevents; set boththresholds.openhab_things_offline_warnandthresholds.openhab_things_offline_critto0to stop them. - Webhook URLs are often the webhook's credential (Slack, Discord, ntfy tokens in the path or query). The full
URLs live only in the configuration file (mode
640 root:pimonitor). The service log names a webhook by its index inalerts.webhooksand the URL's scheme and host; the notifier never logs userinfo, path, query or fragment itself, error texts included. Not covered: a service that puts its secret in the host name, and an endpoint that echoes the request line back in a malformed response, whichnet/httpquotes in the error text. - Only apt cache refresh runs as root, via a separate, narrowly-scoped
systemd timer/service (
pimonitor-apt-update.timer) that runs exactly one command (apt-get update) on a schedule. This unit performs no other action and is not reachable from the web-facing service. - The HTTP dashboard and REST API are intended for trusted local networks
by default (no authentication, plain HTTP). If you expose the API to other
systems (e.g. for home automation integrations), set the optional
api_keyconfiguration value to require a bearer token on/api/v1/...requests (and onGET /metrics, ifprometheus_enabledis set), and do not expose the service directly to the public internet without TLS and additional access control, either via a reverse proxy or by setting the optionaltls_cert/tls_keyconfiguration values to have the service terminate TLS itself. The bundled dashboard keeps working withapi_keyset: it prompts for the key once per browser and persists it inlocalStorage(an accepted trade-off — anyone with access to the browser profile can read it, and without TLS the key is visible on the wire either way). - Supply the API key through the config file or the environment, not the
command line.
/etc/pimonitor/config.yamlis kept at mode640 root:pimonitorbyinstall.sh; alternatively setPIMONITOR_API_KEY, which systemd can load from anEnvironmentFile=with equally restricted permissions. The-api-keyflag is a development convenience only: a process's command line is world-readable via/proc/<pid>/cmdline, so a key passed that way is exposed to every local user on the machine. - Shell-outs (
apt-cache dumpavail, optionalvcgencmd measure_temp) are invoked with fixed argument lists (no user input is interpolated into shell commands), to avoid command injection. - Shell-outs are also invoked with an explicit, minimal environment rather
than inheriting the service's own — neither
apt-cachenorvcgencmdneeds anything beyondPATH(and, forapt-cache, a couple of apt-specific variables), soPIMONITOR_API_KEYandPIMONITOR_OPENHAB_TOKENare never copied into a child process's/proc/<pid>/environ. config.Loadcallsos.Unsetenv("PIMONITOR_API_KEY")andos.Unsetenv("PIMONITOR_OPENHAB_TOKEN")immediately after reading each variable, so nothing later in thepimonitorprocess itself (a future code path, a library,os.Environ()) can read the key or token back out of the environment. This does not scrub the key or token from/proc/<pid>/environ. We verified this rather than assuming it: on Linux, that file is generated by the kernel once, from the rawargv/envpblock captured at the process'sexecve(), and is never regenerated from latersetenv/unsetenvcalls —os.Unsetenvonly updates the Go runtime's in-process copy of the environment. A local user who can already read/proc/<pid>/environfor thepimonitorprocess (in practice, root or thepimonitorservice user) can recover the key or token from it for the life of the process regardless of this call. The meaningful protections remain the ones above: keepapi_key/PIMONITOR_API_KEY(andopenhab.api_token/PIMONITOR_OPENHAB_TOKEN) out of the command line and in files with restricted permissions (mode640 root:pimonitor, asinstall.shsets up), and rely on the explicit subprocess environment (not this unset) to keep the key and token out ofapt-cache's andvcgencmd's own environments.- Requests to any endpoint behind
apiRoute(every/api/v1/...route, plusGET /metricswhenprometheus_enabledis set) share a concurrency limit (withMaxInFlight,internal/httpapi/middleware.go), so a request flood — from another device on the LAN, a misconfigured integration, or a buggy retry loop — is bounded rather than able to multiply CPU/memory work without limit on constrained hardware such as a Pi Zero. This does not require authentication and is not a substitute forapi_key; it is a resource- exhaustion mitigation, not an access control. Seedocs/API.md.
If you believe any of these assumptions are violated by the current implementation, please report it as described above.