whitecell
Log in

Guide

The whitecell command on a server.

A reference for the person at a server’s terminal. Each section is one subcommand: what it does, its options, what it prints and how it exits. The names and options are the code’s own.

Where it is

The installer links /usr/local/sbin/whitecell to /opt/whitecell/bin/whitecell, a two-line script that runs the installed release with /usr/bin/python3. It remakes the link on every install and update. Run the command as root.

The sudo on Debian and Ubuntu finds it. The default sudo settings on RHEL and Fedora leave /usr/local/sbin off the path, so there it is sudo /usr/local/sbin/whitecell. If another file already sits at that path, the installer leaves it alone and says so, and the command is /opt/whitecell/bin/whitecell.

whitecell --version              # the version
whitecell <command> --help       # a command's options

The commands that change or inspect the server refuse on a machine that is not Linux, or without root, with exit 3: “this command changes or inspects the host; run it as root on the Linux host”.

whitecell status

The release the server runs, its inventory, then one row per service.

sudo whitecell status
sudo whitecell status --json     # the rows as JSON, as the heartbeat carries them
release: <release name>
inventory: <n> items at <time> (<n> not explained by a package, the manifest or Whitecell; answers given in the console are not counted here)
service          mode     syscalls tetragon                   egress     unit      rule-hits/24h would-deny/24h denied/24h
  • mode. The recorded mode, audit or enforce.
  • syscalls. filter when the service’s settings filter system calls, none otherwise.
  • tetragon. The rule pack’s state.
  • egress. The verdict of the service’s egress table as loaded.
  • unit. The systemd unit’s state.
  • The three counts. Rule hits, would-be denials and real denials in the last 24 hours.

Under the table come lines that need a person: a service left to its distribution’s AppArmor profile; each service’s writable places, declared and learned; any failed page check; decoys that nginx does not serve yet, with the hand step; rules Tetragon has not loaded, and why; and a line when nothing rotates Whitecell’s logs.

Exit 0, or 3 without root on Linux.

whitecell review

A report from the server’s own event stream, /var/log/whitecell/events.jsonl, which only root and the adm group can read.

sudo whitecell review --since 7d
OptionDefaultWhat it does
--sinceeverythingOnly events newer than Nd, Nh or Nm.
--jsonoffThe same report as one JSON document.
--events/var/log/whitecell/events.jsonlThe event file to read.
--manifest/etc/whitecell/manifest.yamlHost names the egress proposal may use, those the manifest already allows.

The report has five parts, each headed as it prints:

  • Rule hits (monitor mode: detections, nothing was denied). By rule, then service, then what the process did, with counts.
  • Egress observed. Per service, the flows the manifest does not allow yet, as a proposed egress.allow block by /24 or /48 network. A /24 can be wider than the service needs, so read it before copying it.
  • Skin (what the outside did). Decoy hits by class, path and address, closed-port scanners, direct-to-origin attempts and CrowdSec alerts.
  • Units. Failures, process exits and starts.
  • Sessions and host connections. Logins as user and address, and the programs and sessions that connected out.

Exit 0.

whitecell test

Sends one harmless test through the whole response on a server that is paired and reporting. It writes /etc/cron.d/test-whitecell, a cron file of comments only, and waits for the system to quarantine it and for the receipt. Getting started walks through what arrives in the console.

sudo whitecell test              # waits up to 120 s
sudo whitecell test --wait 300   # waits up to 300 s

When the answer arrives it prints:

Found and answered in <n> s: the investigation moved the test file to the quarantine (quarantine_file, action <id>, at <time>).
Receipt: the control plane took the result of action <id> and signed its receipt; it is under Actions and receipts in your console.
Verdict: the triage's and the investigation's are on the case in your console, on this server's page.

With no answer in time it removes the file if it is still the test’s, prints why the answer may not have come, and exits 1. Ctrl-C cleans up the same way. If a test was answered in the last quarter of an hour, it first notes that a test while that case is open joins it and gets no new look.

It refuses with exit 2, writing nothing, and prints whitecell test: refused: followed by one of these:

  • whitecell test needs root: run it with sudo
  • this server is not paired with a cell: install Whitecell with a pairing code from the console first
  • the cell has not acknowledged this server in the last 5 minutes: check that whitecelld runs (systemctl status whitecelld); a test would wait for nothing
  • /etc/whitecell/actions.disabled is here: this server carries out no action, so nothing could answer the test
  • a test is already running here (planted at <time>); wait for it to end
  • /etc/cron.d/test-whitecell exists and is not a test's file: it is left as it is, for a person to look at
  • dd is not on this server (/usr/bin/dd): the test writes its file with it

whitecell receipts verify

Checks an exported receipt log offline: every signature and every link of the chain. It needs no control plane, no token and no network, and runs on any machine with Python 3 and the cryptography package (python3-cryptography).

Get the log from Actions and receipts with “Export receipts (JSONL)”. Get the public key from Settings, Receipt signing key, which shows the command with the key filled in.

whitecell receipts verify receipts.jsonl --public-key '<the public key from Settings>'
ArgumentWhat it takes
the exportThe exported file, or - for standard input.
--public-keyRequired. The control plane’s Ed25519 public key: base64, or a file holding base64, a PEM key, or the JSON the control plane serves for its key.
--hmac-keyA file holding the control plane’s old HMAC key, to check rows signed before Ed25519.
receipts: <n> rows, seq 1 to <n>
anchor: seq 1 starts the chain (prev null)
ed25519: <n> rows, <n> valid (key <key id>)
OK: every signature and every link holds

A failure ends with FAILED:, the count of bad rows, breaks in the chain and rows not checked, then each problem. Exit 0 when every row was checked and holds, 1 when one did not or was not checked, and 2 when the key or the file cannot be read.

On a machine without Whitecell, the same check is one file: /opt/whitecell/src/whitecell/receipts_verify.py on any server runs on its own, as python3 receipts_verify.py verify <export> --public-key <key>.

whitecell promote, demote and demote-rule

The system promotes services itself (The first week). These are the same switches by hand. They act on the server directly, without asking the control plane.

sudo whitecell promote php-fpm               # enforce, then watch 2 minutes
sudo whitecell promote php-fpm --watch 5m    # Ns or Nm; 0 for no watch
sudo whitecell demote php-fpm --reason "site broke after promotion"
sudo whitecell demote-rule php-fpm           # web-shell rule back to observing

promote switches the service to enforce and restarts it. A public web service’s page is checked after the restart. It prints php-fpm -> enforce: ok - <detail>, watches for the window, and checks that the unit is active and has not failed. Healthy, it prints confirmed:. Otherwise it puts the service back in audit and prints DEMOTED php-fpm: with the reason. Exit 0 when confirmed, 1 when the switch failed or the service was demoted.

demote switches the service back to audit, restarts it, and drops its learned writable places. --reason defaults to operator. Exit 0 or 1.

demote-rule switches the service’s web-shell rule from killing back to observing, at once, and restarts nothing. --rule takes web-shell, the only such rule, and --reason defaults to operator. Exit 0 or 1, or 2 when refused.

Uninstall

Takes Whitecell off the server and nothing else. Run it through the installer script, which runs the installed code’s whitecell uninstall and downloads nothing:

sudo bash whitecell.sh --uninstall --dry-run   # the plan, nothing changed
sudo bash whitecell.sh --uninstall             # asks you to type UNINSTALL

It prints its plan and asks for UNINSTALL on a line. Each step then prints done, skipped or failed:

  1. Stops and removes Whitecell’s units: the daemon, the actor, the firewall unit and each service’s egress unit.
  2. Deletes its nftables tables, inet skin and each inet skin_egress_*. No other table is touched and the ruleset is never flushed.
  3. Deletes its Tetragon policies and options, and restarts Tetragon. Tetragon itself stays installed.
  4. Removes its drop-in from every service. A running service keeps the hardening until it restarts, and the output names each one.
  5. Removes the decoy configuration from nginx or Apache, tests the configuration and reloads the server.
  6. Removes its CrowdSec whitelists, its AppArmor profiles and its logrotate file.
  7. Removes /opt/whitecell, /etc/whitecell, /var/log/whitecell, /var/lib/whitecell except the quarantine, the install log, its downloads and builds in /root, and the /usr/local/sbin/whitecell link.
OptionWhat it does
--dry-runPrint the plan and change nothing.
--keep-tetragonRemove Whitecell’s policies, but leave its Tetragon options and do not restart Tetragon.
--restart-servicesRestart each running service once its drop-in is gone, instead of at its next restart.
--yesDo not ask for UNINSTALL.
Without inet skin the server has no inbound firewall. The closing lines name the host firewall that is installed and off, with the command that turns it on, such as systemctl enable --now firewalld or ufw enable. Then retire the server in the console: the uninstall does not tell the control plane.

The quarantine directory is kept when it holds anything, and the output names it. Delete it once nothing in it is needed. Running the command again finishes what a run that stopped part way left. It refuses, changing nothing, on a machine where the control plane or the agent is installed.

Exit 0 when every step is done or skipped, 1 when one failed or the answer was not UNINSTALL, 2 when refused, and 3 when not run as root on Linux. sudo whitecell uninstall takes the same options.

whitecell.sh

The installer script from the console’s Add a server page. Its own usage lines:

sudo bash whitecell.sh [pairing code]          # add this server to your console (asks for the code when it is left out)
sudo bash whitecell.sh --update                # on a server already added: update Whitecell, asking nothing
bash whitecell.sh --dry-run [--update] [code]  # run the checks and print the steps; change nothing
sudo bash whitecell.sh --uninstall [--dry-run] [--keep-tetragon] [--restart-services] [--yes]

Running it again on a server that has reported is an update, with or without --update. An update restarts only the daemon and the actor, never a workload. A two-minute watchdog puts the previous release back unless the new one reports in time.

--update stops at once with exit 2 on a server that is not paired, or paired and never reported. Without it, a server paired but never reported finishes its install and needs no code. Only one run goes at a time, and every command’s output goes to /var/log/whitecell-install.log. A check that fails stops the script with one line and exit 2.

whitecell inventory and init

The installer runs both. By hand they draft or redraft a manifest.

sudo whitecell inventory --out inventory.json
sudo whitecell init --inventory inventory.json --out manifest.yaml

inventory prints what the server runs, as JSON, with no model. It lists the running services with their real programs and packages, the listeners and connections, timers and cron entries, SSH ports and login sources, the web servers’ sites, and Whitecell’s own state. --out writes it to a file. It runs on Linux only, and elsewhere exits 3.

init drafts a v1 manifest from the inventory with fixed rules and no model, and writes a report of every guess beside it. Read both before compiling.

OptionDefaultWhat it does
--inventorycollect on this serverAn inventory file from whitecell inventory.
--answersask on a terminalA YAML file of answers. On a terminal without it, init asks for the host name, the units that face the internet, whether the site is behind Cloudflare, the decoy domain, the operator source networks and the management access, among others.
--outmanifest.yamlWhere the manifest goes.
--reportthe manifest’s name with .report.mdWhere the report goes.

Exit 0, 1 when the draft does not validate, which is a bug, and 3 with no inventory on a machine that is not Linux.

whitecell compile

Compiles a manifest into policy files, and writes files only. Both modes are compiled for every service, so a promotion on the server is a swap, not a recompile. Outbound host names resolve through DNS at compile time, so it needs the network.

whitecell compile /etc/whitecell/manifest.yaml --out /root/whitecell-build
OptionDefaultWhat it does
--outbuildThe directory to write.
--no-validateoffSkip the validators.
--learned-dir/etc/whitecell/learned when it existsThe learned egress overlays to merge; '' for none.
--sensorkprobeHow the rule pack hooks the kernel’s security functions: kprobe or lsm. Keep kprobe; lsm needs BPF in the kernel’s LSM list and carries a Tetragon bug.
--platformthe manifest’s, else this machine’sarch, debian, fedora, rhel or suse. Without a manifest value or /etc/os-release, debian.

It prints one line naming the host, the number of services, the sensor and the platform, then each learned overlay it merged, each file it wrote, and each validator as [ok] or with what failed. A failed validator does not change the exit status; apply validates again and refuses. Compile on the server itself: apply refuses a build that lacks the server’s learned overlays.

Exit 0, or 2 when the manifest is bad or cannot be read.

whitecell apply

Validates a build and installs it: the host set, meaning the firewall table, the decoys and the rule pack, and every service in its recorded mode. That mode is audit unless the service was promoted. A service whose files are unchanged is neither reinstalled nor restarted.

sudo whitecell apply /root/whitecell-build
OptionWhat it does
--serviceOnly these services; repeat it for more than one.
--no-restartRestart no service. A changed drop-in takes effect at the service’s next restart; a changed egress table loads at once.
--forceApply a stale build, a build for another platform family, or one without this server’s learned overlays.

It refuses with exit 2, before anything changes, a path that is not a build, a build whose manifest this release cannot load, a build for another platform family, and a stale build: one whose manifest differs from the installed one while the installed one is newer. It prints both hashes. It also refuses a build without this server’s learned overlays, and any file that fails validation, printed as INVALID. Exit 1 when a service failed, a web server’s configuration test failed, or the firewall table did not load. Exit 0 otherwise.

whitecell join and pair

The installer pairs for you. By hand, the secret goes in a file or on standard input, never on the command line, because Tetragon exports process arguments.

whitecell join --cell https://cp.example.com:8484 --ca cert.pem --code-file -
whitecell pair --cp-url https://203.0.113.10:8484 --host web-01 \
  --ca cert.pem --token-file -

join pairs with the control plane from the pairing code alone and writes the server’s credentials to /var/lib/whitecell/cp.json, readable by root only. --host sends a name too, for a control plane that needs one. pair does the same with a one-time token from a control plane you host yourself. Both take https:// only, or plain http:// to loopback, and --creds changes where the credentials go. Neither replaces existing credentials: move cp.json away first.

Exit 0 when paired, 1 when the control plane cannot be reached or refuses the code, and 2 for a bad argument, an unreadable or empty code, or a server already paired.

The running parts

systemd runs these; you do not.

  • whitecell daemon is whitecelld. It folds every signal the server produces into /var/log/whitecell/events.jsonl and sends it to the control plane. journalctl -u whitecelld -f is the live view. Its options set its files and the user agent of synthetic traffic, and --quiet drops the line it prints per event.
  • whitecell actor is whitecell-actor. It carries out actions from the fixed catalogue and nothing else. --dry-run plans and records and executes nothing.
  • fileop, pagecheck and rule-reload are internal. The actor runs them in short-lived units of their own.

To stop every action on this server, create the file the actor checks before each action. While it exists the actor refuses everything, and whitecell test refuses to run.

sudo touch /etc/whitecell/actions.disabled

On the control plane

These run on a control plane you host yourself, on its own machine, never on a protected server. The control plane document in the repository covers each one.

CommandWhat it does
cpserve, init, token, host, kill, reflex, notify, prune, export. whitecell cp kill on stops every action on every server.
hosts, events, metricsList the servers, read events, and print the numbers per day and server.
act, actionsRequest an action; list, show, approve, decline or revoke actions.
exceptionsList, add, approve, decline or renew exceptions.
agentrun, case, digest and brief: the agent, the record it would see, the daily digest and the weekly brief.
benchScore a model on recorded scenarios. Nothing executes.

Exit codes

Command0123
testansweredno answer in time, or interruptedrefused, nothing written
receipts verifyevery row checked and holdsa bad row, a break, or a row not checkedkey or file unreadable
uninstallevery step done or skippeda step failed, or no UNINSTALLrefusednot root on Linux
applyinstalleda service, a web server test or the firewall table failedrefused before any changenot root on Linux
promoteconfirmedfailed, or demoted by the watchnot root on Linux
demotedonefailednot root on Linux
demote-ruledonefailedrefusednot root on Linux
statusprintednot root on Linux
compilewrittenbad manifest
initwrittenthe draft does not validateno inventory, not Linux
join, pairpairedunreachable, or code refusedbad argument, or already paired