Skip to content
CWPControl Web PanelDocumentation
  1. Home
  2. Docs
  3. Admin Guide
  4. Security
  5. CWP Cage (account isolation)

CWP Cage (account isolation)

Updated

CWP Cage account isolation

CWP Cage runs each account’s PHP (and everything it starts) inside its own private Linux mount namespace. Inside the cage the account sees only its own /home, a private empty /tmp, and the few system files it legitimately needs — nothing of any other account. This is the big jump over suPHP: even a site with a web-shell and zero PHP hardening cannot list /home, read another account’s files, or read /etc/shadow, because those paths simply do not exist for that process.

Note: CWP Cage is a CWPpro feature, available in CWP 2.0 and later. It works with both the PHP-FPM and the cwpsapi (lsphp) handlers.

Requirements

  • A CWPpro licence, CWP 2.0 or later.
  • The account’s sites must run PHP through PHP-FPM or lsphp (cwpsapi). These handlers keep a persistent per-account PHP pool, and that pool is what is moved into the cage.
  • Accounts on suPHP or php-cgi start a short-lived PHP process for every request, so there is no pool to cage. To cage such an account, first switch its sites to PHP-FPM or lsphp in WebServers Settings.

How it fits the other layers

Cage is one of four independent isolation layers; each holds even if the ones above it are bypassed or absent:

LayerWhat it does
1. Handler (cwpsapi / suPHP)PHP runs as the account’s own UID, never as root.
2. CWP CagePrivate mount namespace — other accounts’ files are not present at all.
3. cgroupsCPU, memory and process-count limits, so one site cannot starve the server.
4. CWP Secure KernelMandatory access control: PHP is not even allowed to execute a shell.

Where to find it

In the CWP admin panel open Security → CWP Cage. A live resource view (CPU / memory / processes per cage) is under Security → CWP Cage LIVE. From the command line everything is driven by /scripts/cwp_cage.

Cage an account

From the panel (GUI)

  1. Open Security → CWP Cage. The table lists every account with its cage state, live CPU, memory, process count and faults.
  2. Click Cage on an account to move it into its own cage, or Release to put it back on the shared PHP masters.
  3. Use Cage all / Release all to do the whole server in one background pass (a few seconds per account).
  4. Under Packages, tick the hosting packages whose new accounts should be caged automatically right after creation.

Tip: Enabling a cage is safe: CWP self-tests each cage first and refuses to activate one that does not work, so an account is only ever marked caged when it is actually usable (a broken cage would make PHP return HTTP 503).

From the command line (CLI)

# Cage / release one account
/scripts/cwp_cage enable  <account>
/scripts/cwp_cage disable <account>

# Cage every account on the server (one reload at the end)
/scripts/cwp_cage enable-all

# Status and live per-account CPU / memory usage
/scripts/cwp_cage status [account]
/scripts/cwp_cage usage  [account]

# After the panel rewrote pool configs (PHP Selector, rebuild):
# re-apply the cage for every caged account
/scripts/cwp_cage sync

# Self-heal: uncage any account whose cage no longer works (keeps sites up)
/scripts/cwp_cage heal [account]

Note: The socket path of each PHP pool does not change when an account is caged, so the vhosts stay exactly as they are — no vhost regeneration is needed.

What the account sees inside the cage

  • /home: only its own home directory.
  • /tmp, /var/tmp, /dev/shm and the PHP session directory are private to the account; other accounts’ files never appear there.
  • The panel configuration and /root are hidden.
  • The account’s cron jobs run in the same caged view as its PHP.
  • Databases keep working: CWP keeps the MySQL socket reachable even when the MySQL data directory lives under /home.

Before you enable it

  • Memory: each caged account runs its own PHP master for every PHP version it actually uses, about 20 MB each. PHP versions the account does not use get no master at all; if a site is switched to another version, the cage follows automatically. On servers with hundreds of accounts, plan for this extra memory.
  • No access outside the account: scripts that read files of other accounts, or system paths outside the account, stop working once the account is caged. This is intended; check your own trusted applications that share files between accounts, and keep those accounts uncaged if needed.

Recommended rollout:

  1. Cage one or two typical accounts.
  2. Check their sites: pages, uploads, cron jobs, contact forms and e-mail sending.
  3. Then use Cage all, or tick the hosting packages under Packages so new accounts are caged automatically.

What is protected (and what is not)

Cage protects the server and the neighbouring accounts from a compromised site. It does not protect a site from its own bad code: the account owns its data and can always read and change its own files. Outbound network access (for example a curl call) is governed by the firewall and the Secure Kernel, not by the cage.

Common problems

SymptomCause / fix
An account shows no system userLeftover / half-deleted account with no Linux user — it cannot be caged. Recreate or remove it.
An account shows no PHP-FPM poolThe account has no active pool to cage yet; it is served another way. No action needed unless you switch it to PHP-FPM / cwpsapi.
Site returns HTTP 503 after a config changeRun /scripts/cwp_cage sync to re-apply the cage after pool configs were rewritten, or cwp_cage heal to auto-uncage a broken cage.