Skip to content

Security model ​

An IPTV panel has a lot to protect: client passwords that appear in every URL, provider credentials, resellers who must not see each other, and nodes spread over many networks. This page explains how Bitstream handles each.

Who can do what ​

  • Admins can do everything their group allows.
  • Resellers see and change only their own data and the resellers below them. Anything outside their tree answers 404, never 403, so ids cannot be probed. Every reseller endpoint is tested against a sibling reseller.
  • API keys act as the user who made them, limited to the key's scopes. The effective permission is the overlap of both, so a reseller key never does more than that reseller.
  • Group permissions use the same strings as API key scopes, and every route checks exactly one rule taken from the API contract.
  • A reseller can give a sub-reseller only its own group, or a group that grants nothing more: same or fewer permissions and limits, the same 2FA rule.
  • Resellers cannot change a client's package with an edit. They renew instead, so credits are always charged.
  • API keys for resellers are a group permission, off by default. Turning it off stops the group's existing keys too.

Signing in ​

  • Admin and reseller passwords are hashed with argon2id.
  • Access tokens are short JWTs (15 minutes) signed with Ed25519. They live only in memory in the panel, never in browser storage.
  • Refresh tokens are httpOnly, Secure, SameSite=Strict cookies, scoped to /api/v1/auth. Each one works once. If an old one shows up again, every session of that login is revoked, because that means it was stolen.
  • 2FA with TOTP, plus recovery codes. A code cannot be used twice.
  • Forced 2FA. A group can require 2FA (require_2fa), and the security setting require_2fa_admins does the same for admins. Until such a user turns 2FA on, their session reaches only their profile, logout, token refresh and the 2FA enroll and verify calls. Everything else answers 403 2fa_enrollment_required, and the panel sends them to a page that sets up 2FA.
  • A refresh token that is used again within 30 seconds, from the same browser, gets one more token (two tabs refreshing at once). Any other reuse revokes the login.
  • After logout, a password change or a revoked session, the access tokens of that login stop working at once, not after 15 minutes.
  • You change your own password, username and email only under My account, which asks for the current password.
  • Failed logins lock the account and the IP for a while. The panel can be limited to a list of IP ranges.

First setup ​

  • The setup wizard works without a code only on a direct loopback connection, for example through an SSH tunnel. A request that came through a proxy never counts as loopback.
  • From anywhere else it needs the one-time code from setup.code in the control's data folder, sent in the X-BS-Setup-Code header. The wizard checks it on its first screen with POST /setup/check-code. Both calls share a limit of 10 tries per minute.
  • The installer prints the code. Without HTTPS it warns you and suggests an SSH tunnel, because the code and the admin password would cross the network in clear text.

Real client IPs ​

  • X-Forwarded-For is believed only from http.trusted_proxies (loopback by default).
  • CF-Connecting-IP is believed only from a hop in http.cloudflare_proxies, which defaults to Cloudflare's published ranges. A panel behind Cloudflare sees the real client without extra setup, and nobody else can fake the header.
  • IPv6 clients are counted per /64 for login failures, automatic blocks and rate limits.

API keys ​

  • Keys are stored as a SHA-256 hash. The full key is shown once.
  • Creating, editing and rotating a key needs a sign-in token, so a leaked key cannot loosen its own rules.
  • Optional IP allowlist and expiry per key.
  • Optional request signing with HMAC-SHA256, a timestamp and a one-time nonce. A stolen key is useless without the secret, and a captured request cannot be replayed. See API keys and request signing.

Client lines ​

Line passwords are a special case. The Xtream protocol puts them in every playlist URL, and resellers need to read them back to send to clients. So they cannot be hashed:

  • They are encrypted at rest with AES-GCM and compared in constant time.
  • They are redacted from every access log, in paths (/live/u/p/) and in query parameters.
  • Repeated failed logins from one IP block that IP for 15 minutes.

Nodes ​

  • A node joins with a single use token that expires. The token carries the hash of the control's certificate authority, so the node checks it is talking to the real control before it sends anything.
  • The node makes its own private key. Only a certificate request travels.
  • After that, all traffic is mutual TLS. The control checks the node is still active on every connection, so removing a node cuts it off at once.
  • Nodes have no database access and no client passwords. They only know a per-node secret to check play tokens.
  • Play tokens are signed per node with HMAC-SHA256, carry the client IP and a short deadline to open, and stay in the URL path. A token signed for one node does not work on another. A token for one IP family does not work from the other.
  • An HLS or VOD session is bound to its first client IP. Another IP gets 403 session_in_use until the session idles out.
  • Relay tokens in the server tree last 2 to 4 hours, are refreshed through the node config, and carry the child's address.
  • A node can only report events for streams assigned to it, and its log lines are capped. It cannot free or take over another node's sessions.

Streams and ffmpeg ​

  • ffmpeg is never run through a shell. Arguments go straight to the process.
  • Extra ffmpeg flags come from an allowlist, and only admins can set them. Free text ffmpeg options are close to remote code execution, so they are not allowed.
  • -protocol_whitelist is always set by the node. file is in it only for created channels.
  • Local movie, episode and created channel files must be under media_roots (default /srv, /mnt, /media, /data, /opt/bitstream/media, never /). The control refuses other paths when you save, and the node opens files confined to those folders.
  • Direct mode never sends a viewer to a source URL that carries credentials (a user and password, a query, a fragment or a provider account). Those always play through a node.
  • Fetches for EPG, M3U imports and AI providers refuse private and internal addresses unless you set BS_FETCH_ALLOW_PRIVATE=1. Loopback is always refused.
  • EPG files are limited after decompression (4 GiB, 50,000 channels), so a small gzip cannot fill the memory.
  • Source URLs are redacted in logs, stream errors and anything sent to an AI provider.

Secrets at rest ​

  • A 32 byte master key (master.key, mode 0600) encrypts line passwords, third party tokens (Cloudflare, AI providers), certificate keys and backups.
  • Third party tokens are never returned by the API, only a "set" flag or the last few characters.
  • Backups are encrypted in chunks, so a backup cannot be cut or reordered without the restore noticing.
  • Uploading and restoring a backup need a sign-in token. A restore asks for your password again, plus a 2FA or recovery code when 2FA is on (5 tries per 15 minutes).
  • A backup made by another installation can be uploaded, but not restored (409 backup_not_local).

The services themselves ​

  • Each service runs as its own system user (bs-control, bs-node, bs-license) with systemd hardening: read-only system, private /tmp, no new privileges, only the address families it needs, write access only to its own data folder. The units also hide the other services' data and env files. So an ffmpeg exploit on the node cannot read the control's master key or the license admin key.
  • The panel is served with a strict Content Security Policy and cannot be framed.
  • PostgreSQL and Redis listen only on localhost. Redis has a password.
  • Every admin action is written to the audit log, without passwords, tokens or source URLs.

Known gaps ​

  • Source credentials are visible in ffmpeg's command line to local users on a node (/proc/<pid>/cmdline). LLOD mode avoids this.
  • The control is a single instance in this version.
  • Between nodes, relay traffic is plain HTTP unless you set an internal_url with HTTPS.

Bitstream documentation