Skip to content
CWPControl Web PanelDocumentation
  1. Home
  2. Docs
  3. CWP DataCenter Panel
  4. Security of the API connection

Security of the API connection

Updated

CWP DataCenter Panel manages servers only through the CWP API v2. It never gets the root password, SSH access or a login to the CWP admin panel of a server. This page explains how the connection between the panel and each server is protected.

LayerProtection
TransportHTTPS only, port 2304 of the server
Server identitythe TLS key of the server is pinned
Credentialsan API token with limited scopes, valid only from the panel’s IP
Networkport 2304 is open only for the panel’s IP
Storage in the paneltokens are encrypted (AES-256-GCM)
Revocationone command on the server

Encrypted connection

Every request from the panel goes to https://<server>:2304/v2 over TLS. The panel does not follow redirects and does not fall back to plain HTTP.

The panel talks only to the real server

CWP usually serves a self-signed certificate on port 2304, so a normal certificate check would fail. Instead, the panel pins the server’s TLS public key:

  • datacenter_addserver reads the key directly on the server and puts its fingerprint into the CWPDC1. line. The panel therefore does not have to trust the first connection.
  • From then on, every request checks that the server presents exactly that key. If the key is different (for example a man-in-the-middle attack), the panel stops all requests to that server, does not send the token, and raises a critical alert.
  • When you replace the server’s certificate on purpose, run datacenter_addserver again and paste the new line.

Other options when adding a server manually: CA (normal verification, for servers with a certificate from a public CA) and None (no check, only for tests: the token could be stolen on the way).

The API token

datacenter_addserver creates an API token on the server for the panel. On the CWP side:

  • Bound to the panel’s IP. CWP rejects the token from any other address, so a stolen token is useless elsewhere.
  • Limited scopes. The token can do only what the panel needs: accounts, packages, domains, DNS, e-mail, databases, SSL, FTP, cron, backups, firewall, services, reading server data and jobs, and maintenance (updates). The panel tells you when a token lacks a scope instead of failing silently.
  • Stored as a hash. CWP keeps only the SHA-256 hash of the token and shows the token once, when it is created.
  • Optional expiry. datacenter_addserver <panel IP> --days 365 creates a token that expires after one year.
  • Rate limited by CWP, so a runaway client cannot overload the server.

Firewall

The script opens port 2304 in CSF only for the panel’s IP (a single csf.allow rule marked “CWP datacenter”). Port 2304 stays closed for the rest of the internet. Without CSF, the script prints the firewalld or iptables rule to add.

Tokens inside the panel

  • Tokens are stored encrypted in the panel’s database (AES-256-GCM).
  • The encryption key is in config.php, outside the database. A leaked database alone does not reveal the tokens.
  • Even with the database and config.php, a token works only from the panel’s IP.

Note: Keep config.php and the database backups safe. If you suspect a leak, revoke the tokens on the servers (see below) and add the servers again.

Adding a server with an enrollment code

With Add server → Or let the server add itself, the server sends its details to the panel by itself:

  • The code works once and expires after one hour. The panel stores only a hash of it.
  • The server sends its data to the panel over HTTPS with full certificate verification. Use a valid certificate on the panel (AutoSSL); --insecure-enroll exists only for tests.
  • After 20 wrong codes from one IP, that IP is blocked for 15 minutes.
  • Every attempt, successful or not, goes to the Audit log. With Telegram set up, you also get a message when a server joins.

Removing access

To cut off the panel from a server, run on that server as root:

/scripts/datacenter_addserver <panel IP> --remove

This revokes the token and removes the CSF rule. Tokens can also be listed and revoked one by one with /scripts/cwp_api2 token list and /scripts/cwp_api2 token revoke <id>.

Access to the panel itself

The connection to the servers is only as safe as the panel. The panel adds two-factor login, roles, access limited to server tags, blocking of repeated wrong passwords and an audit log of every change; see Users and security. Its PHP code is encoded with ionCube.

In short

The panel never gets root access. Each server gives it a token with limited rights that works only from the panel’s IP. The connection is encrypted and pinned to the server’s own key, so nobody can step in between. You can cut off the panel at any time with one command on the server.