Skip to content

Security ​

Sensora is built to start on localhost or a private network. Out of the box it has no user accounts, no HTTPS and an open API. This page tells you what to set before anyone else can reach your instance, and what Sensora does and does not protect after that.

Before you expose an instance ​

Do these four things before the instance is reachable from a network you do not control. Then back up the database and deploy/.env as Operations describes.

  1. Set a dashboard password. Set SENSORA_DASHBOARD_PASSWORD in deploy/.env. Without it, and without an API key, anyone who can reach the port can read and change everything.
  2. Set your own ENCRYPTION_KEY and DB_PASSWORD, before the first start. The defaults are public in the repository, and the server starts with them without a warning. See Install for real use. Protect deploy/.env, which holds all three values as plain text.
  3. Put HTTPS in front and close the plain-HTTP port. See Put HTTPS in front. Over plain HTTP, passwords, keys and device secrets cross the network unencrypted.
  4. Do not publish the MQTT broker. It accepts every client without a password. See The MQTT broker.

What is open when nothing is set ​

With no SENSORA_DASHBOARD_PASSWORD, no API_KEYS and no key created in Settings, every path under /api answers without a credential. Anyone who can reach port 8090 can read all readings and customer email addresses, delete devices, change rules, and create the first API key, which locks everyone else out.

The dashboard says so under Settings, then API keys.

The API keys settings screen with the notice that the API is open on this network and the form for the first key

The customer app at /portal is served on the same address as the dashboard. On an open instance, a customer who opens / gets the dashboard. Set the dashboard password before you give the address to customers.

The dashboard password ​

Set SENSORA_DASHBOARD_PASSWORD in deploy/.env and run the start command again. Each browser then asks for the password once.

  • There is one password for everyone, and a signed-in browser can do everything, including creating API keys.
  • The sign-in is a cookie that lasts 30 days and is renewed while you use the dashboard. It is marked Secure only when the browser reached Sensora over HTTPS.
  • The server keeps no list of sign-ins, so you cannot end one browser's session. Changing the password or ENCRYPTION_KEY signs out every browser.
  • Sign-in attempts are limited for each client address: 5 at once, then one every 12 seconds. A correct password is refused too while the limit is reached. There is no lockout and no record of failed attempts.

API keys ​

Scripts and agents send an API key in the header Authorization: Bearer <key>. Create keys under Settings, then API keys. A request needs a key or the dashboard session, not both. See API.

Name on screenScopeAllows
ReadreadRead devices, data, rules and logs, and run read-only queries. Those queries reach almost every table, including claim codes and the tokens in webhook addresses, so give a Read key only to someone you trust with those. See Data explorer.
AgentproposeEverything in Read, plus the MCP endpoint, where it can set a project up and propose rules. It cannot turn a rule on or delete anything. See Agents.
WritewriteEverything in Read, plus create, change and delete devices, templates, integrations, rules and dashboards.
AdminadminEverything in Write, plus manage API keys, everything under Customers, and firmware signing keys.
  • The full key is shown once. Keys do not expire. Revoke a key to stop it.
  • On an open server the first key must be an Admin key. From then on every request needs a key or the dashboard session. If you set no dashboard password, each browser needs a key to open the dashboard.
  • Keys in the API_KEYS variable always have the admin scope.

Paths that are always public ​

These paths answer without the dashboard password and without an API key. Each has its own check.

PathUsed byWhat protects it
GET /healthMonitoringNothing. It says only whether the server and the database answer.
POST /ingest, POST /ingest/announceDevicesThe device ID and the device secret.
GET /ota/check, GET /ota/image/<id>, POST /ota/reportDevices that take remote updatesThe device ID and the device secret.
POST /api/integrations/<token>/webhookServices that send webhooksThe token in the address, and a signature if you set a signing secret.
GET /firmware/...The browser flasherNothing. The files are firmware images that you installed on the server.
GET /llms.txt, GET /api/llms.txt, GET /api/openapi.jsonAgentsNothing. They describe the software and hold no data of your project.
/api/portal/v1/...The customer appThe customer's own sign-in.
GET /api/public/dashboards/<token>Shared dashboard linksThe token in the link. It opens one dashboard, read-only.
/api/sessionThe password screenThe password and the sign-in limit.

The dashboard's own files, which are the page without any data, are public too.

Devices and webhooks ​

  • A device secret is shown once, when you create the device. It allows only that device's own requests and opens nothing under /api.
  • Set a signing secret on a webhook integration if the sender can sign requests. Without one, the token in the address is the only protection.
  • Webhook actions in rules are not signed. The server refuses link-local addresses such as 169.254.169.254, but it does call other private addresses. A person or key that can edit rules can therefore make the server send requests inside your network.

What is stored and how ​

  • Device secrets, API keys and customer sign-in tokens are stored as keyed hashes made with ENCRYPTION_KEY. They cannot be read back.
  • Signing secrets and passwords of integrations are encrypted with a key made from ENCRYPTION_KEY.
  • Readings, device names, claim codes, customer names and email addresses are plain values in PostgreSQL.
  • Sensora does not encrypt the database volume or your backups. Use disk encryption on the host if you need it.

If you lose or change ENCRYPTION_KEY, device secrets, API keys and integration secrets stop working. There is no tool to change the key on a running instance.

Put HTTPS in front ​

Sensora cannot serve HTTPS and does not request certificates. Put a reverse proxy on the same host in front of it. The two examples below were tested with version 0.1.27. A tunnel such as Tailscale Serve or Cloudflare Tunnel is another option: point it at http://127.0.0.1:8090.

  1. Bind the Sensora port to the host itself and set the public address. In deploy/.env:

    ini
    WEB_PORT=127.0.0.1:8090
    PUBLIC_URL=https://sensora.example.com
  2. Run the start command again.

    bash
    docker compose -f deploy/docker-compose.yml up -d
  3. Configure the proxy with one of the two examples.

WARNING

Without step 1, port 8090 stays reachable over plain HTTP next to your HTTPS address. A host firewall such as ufw does not block it by default, because Docker publishes ports with firewall rules of its own.

Caddy ​

Caddy gets a certificate for the domain by itself. The domain must point to the host, and ports 80 and 443 must be reachable. This is the whole Caddyfile:

text
sensora.example.com {
    reverse_proxy 127.0.0.1:8090
}

nginx ​

With nginx you bring the certificate yourself, for example from Certbot.

nginx
server {
    listen 443 ssl;
    server_name sensora.example.com;

    ssl_certificate     /etc/letsencrypt/live/sensora.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/sensora.example.com/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1:8090;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_buffering off;
        proxy_read_timeout 1h;
        client_max_body_size 10m;
    }
}

Whatever proxy you use, it must:

  1. Pass the original Host header.
  2. Send X-Forwarded-Proto: https. Sensora marks the session cookie Secure only when it sees this header. Caddy sends it by default.
  3. Not buffer responses, because the live views use a long-running stream at /api/stream.
  4. Allow request bodies of 10 MB, so that firmware uploads pass.

Rate limits behind a proxy ​

Some rate limits are counted per client address: dashboard sign-in, device and webhook requests that fail their check, shared dashboard links, customer sign-in and claim code attempts. Limits and roadmap lists the numbers.

Sensora takes the client's address from the X-Real-IP header, which the bundled web server always sets to the address that connected to it. It does not read X-Forwarded-For from your proxy.

WARNING

Behind a reverse proxy or a tunnel, Sensora therefore sees every visitor with the same address, the address of the proxy. All visitors share one allowance for each of these limits. For example, all your customers together can request 5 sign-in links at once and then one per minute, and a person who keeps sending wrong dashboard passwords blocks sign-in for everyone. Version 0.1.27 has no setting to change this. If you need limits per visitor, add them in your proxy.

The MQTT broker ​

The stack includes a NanoMQ broker with the image's default settings.

  • It accepts anonymous clients and has no TLS.
  • Sensora knows an MQTT device only by the device ID in the topic. MQTT messages carry no device secret.
  • Anyone who can connect to the broker can therefore publish readings as any device and read every topic.

By default only the Sensora server can reach the broker, because none of its ports is published. Publish port 1883 only on a network you trust, and never publish the broker's other ports. For anything else, run a broker with user names, access rules and TLS, and connect Sensora to it. See MQTT.

What is not there ​

  • No user accounts, roles or teams, and no record of who changed what in the dashboard.
  • No two-factor sign-in and no single sign-on.
  • No built-in HTTPS, firewall or IP allow list.

To report a security problem in Sensora itself, see Support.

Sensora is open source under the Apache 2.0 license.