Host hardening
Every edge package - Scanner, Apex, Syslog Collector and Integrator - carries a hardening pass for the Ubuntu Server host it is installed on. It closes the findings a vulnerability scan raises against a stock install: SSH defaults, kernel and network settings, legacy services, no audit trail, no host firewall, loose file permissions, password policy, login banners and unattended security updates.
It is part of the package rather than a separate download so that a host you build from the CyberOptix CTEM Platform repository ends up in the same state as every other, and stays there: a timer re-applies it daily and any drift is corrected.
Before you start
- The package has been installed. The hardening ships with it and needs nothing else.
- At least one account on the host holds an SSH key. The pass disables SSH password login, and it refuses to do so while no account has a key, so that it never leaves the console as the only way in. Linking the system provisions the operators' accounts and keys, which satisfies this.
- A reboot window at some point. Two changes take effect at the next boot:
/tmpas a memory-backed filesystem, and auditing from early boot. Nothing reboots the host for you.
Run it
Installing or upgrading a package enables the daily timer but does not apply the hardening during the install itself. Link the system first, then run the pass once by hand so the first application happens while you are watching:
sudo optix-harden
It prints a summary at the end: the system it detected, the effective SSH settings, what is listening, the firewall state, the audit state and what still needs a reboot.
To preview without changing anything:
sudo optix-harden --check --diff
To see when it runs next and how the last run went:
systemctl list-timers optix-hardening.timer
journalctl -u optix-hardening.service -n 50
The unit, the timer and the hardening files are owned by the package, so
dpkg -V cyberoptix.<package> reports any change to them. There are no crontabs or
cron.d drop-ins to edit, the pass keeps its own timer enabled, and the audit rules
record changes to the unit directories and the cron paths with the account that made
them.
What it changes
| Area | Change |
|---|---|
| SSH | Key-only login, no root login, no agent or X11 forwarding, verbose logging, modern ciphers and key exchange only, idle disconnect after 15 minutes, a legal banner. |
| Kernel and network | Address space randomisation, restricted debugger attach, hidden kernel pointers, no ICMP redirects or source routing, SYN cookies, reverse path filtering. |
| Kernel modules | Unused filesystems and network protocols can no longer be loaded. |
| Mounts | /dev/shm is nodev, nosuid, noexec. /tmp is memory-backed with nodev, nosuid. |
| Accounts | Password ageing and quality rules, lockout after five failures, sudo logged to its own file, root's password locked, empty passwords locked. |
| Banners | An authorised-use notice before login. The message of the day no longer reveals the release. |
| Audit | auditd records time, identity, login, permission, mount, deletion, sudo, kernel module and configuration changes, and every privileged command. |
| Services | Ctrl-Alt-Del disabled, AppArmor and time sync on, the journal persistent and capped, core dumps off, no remote syslog reception by the host's own rsyslog. |
| Updates | Security updates install unattended with no automatic reboot. The edge packages themselves, Docker and redis are excluded so an update never restarts a running task; those follow the maintenance flow instead. |
| Permissions | System account files, cron directories and the files under /etc/optix that hold credentials are restricted. |
| Firewall | Depends on the system, see below. |
| Removed packages | telnet, rsh, talk, NIS, ftp, tftp, xinetd, avahi, cups, rpcbind, NFS, bind9, DHCP server, vsftpd, apache, nginx, samba, squid, snmpd, dovecot, ldap-utils. None is used by an edge system. |
The accounts the Scanner and Apex create for your operators log in with their SSH key only. sudo keeps the standard rule and asks for a password, so each operator sets one under Appliance Password on their profile page; CyberOptix CTEM Platform stores only its hash and the appliance applies that hash on its next check-in. Until an operator sets one, the account carries a random password that nobody holds, rather than no password, so it is a real credential and the password ageing rules can never expire a key-based login. No account on the appliance is granted passwordless sudo.
What differs by system
The Scanner and Apex do offensive work, and some of the measures above would get in its way: an exploited target calls back to the host on whatever port the payload chose, operators tunnel through the host so every connection to a target leaves from its address, and the tool containers share the host's kernel and network. The pass detects which system is installed and adjusts.
| Scanner | Apex | Syslog Collector | Integrator | |
|---|---|---|---|---|
| Host firewall | Off | Off | On: SSH and the Collector port only | On: SSH only |
SSH tunnelling (-L, -D) | Allowed | Allowed | Blocked | Blocked |
| Reverse path filtering | Loose | Loose | Strict | Strict |
| IPv6 router advertisements | Accepted | Accepted | Refused | Refused |
| SCTP | Loadable | Loadable | Blocked | Blocked |
/tmp memory-backed | Yes | No | Yes | Yes |
Nothing on a Scanner or Apex host listens for the network except SSH: the tool containers bind to loopback and the services run unprivileged and open no ports. The firewall being off on those two therefore removes nothing that was protecting them, and the summary lists what is listening so a stray listener is visible.
That is the one supported combination. Both use the offensive profile, so nothing
conflicts, and Apex's /tmp setting applies to the shared host, which keeps
/tmp on disk for both.
Every other mix is not supported, even though it may appear to work. The syslog Collector and the Integrator get the strict profile. Installed on a host that already runs a Scanner or Apex, the offensive profile wins: the tools keep working, but the Collector or Integrator runs without the firewall and the other protections it would have on its own host, and the pass says so in its summary. The reverse is worse: a Collector host turned into a Scanner by adding the Scanner package has its firewall and SSH tunnelling rules undone by the next run. Give the Collector and the Integrator their own hosts, and expect no support for a host that mixes them with anything else.
Turning parts off
Each area is a switch. Pass it to the command and the daily run keeps whatever you set only until its next run, so put a permanent change in a variables file rather than on the command line:
sudo optix-harden -e edge_hardening_auditd=false
The switches are packages, ssh, sysctl, kernel_modules, mounts, auth,
banner, auditd, firewall, services, updates and permissions, each prefixed
with edge_hardening_. The firewall policy on a strict-profile host can also be opened
with edge_hardening_firewall_policy=open, and a Scanner whose callback ports are fixed
can enforce the firewall and open just those with edge_hardening_firewall_policy=enforce
plus a rule list; /usr/share/optix/hardening/README.md on the host documents every
variable.
Files
| Path | Purpose |
|---|---|
/usr/share/optix/hardening/ | The hardening pass itself, replaced on every package upgrade |
/usr/local/bin/optix-harden | Runs it by hand |
/usr/lib/systemd/system/optix-hardening.timer | The daily schedule |
/etc/ssh/sshd_config.d/00-cyberoptix-hardening.conf | The SSH settings it applies |
/etc/sysctl.d/60-cyberoptix-hardening.conf | The kernel and network settings |
/etc/audit/rules.d/50-cyberoptix.rules | The audit rules |
/var/log/sudo.log | Every sudo invocation |
Next
- Scanners and Apex - the two systems that run with the offensive profile
- Log agents and Collectors and Integrator - the two that run with the strict profile
- Troubleshooting - a host that stopped reporting after a run