Μετάβαση στο περιεχόμενο

Installation and security maintenance

ANSSI-BP-028 v2.0 reference: R28, R58 to R63, R80 (M/I levels).

This section covers the initial foundation of the system: minimal installation, version compatibility, partitioning, reduction of installed packages and services, control of APT repositories and automation of updates.

R1. Minimal Debian installation

Applies to: Edge Gateway

CyberElements servers must be installed on a Debian system corresponding to a strictly minimal installation, on a 64-bit architecture. The aim is to reduce the attack surface by limiting the installed components to those strictly required for the solution to work, to be administered and to be kept secure over time.

During installation, only the Debian base system must be installed. The predefined "SSH server" task may be selected so as to allow secure remote administration. No graphical environment and no service unnecessary to the solution must be installed, in particular: desktop environment, printing services, office services, multimedia services, unneeded network discovery services, application services not used by CyberElements, tools intended for workstation use. In the software selection screen of the Debian installer, the "standard system utilities" task is checked by default: uncheck it, so that only "SSH server" remains checked.

1
2
3
4
lscpu
uname -a
cat /etc/debian_version
cat /etc/os-release

After installation, the active services and listening ports should be checked so as to confirm that only the expected services are present:

1
2
systemctl --type=service --state=running
ss -tulpn

R2. Debian version and security maintenance

Applies to: Edge Gateway

Servers must be installed on a Debian version compatible with the version of the solution deployed. Each version of CyberElements is tied to a supported Debian version; compatibility information is given in the applicable compatibility matrix.

Systancia recommends carrying out version upgrades by following the corresponding installation or update documentation. The operating system must be kept up to date so as to fix the vulnerabilities affecting the Debian components used by the solution: system services, libraries, OpenSSL, OpenSSH and so on.

Updates must be validated in a test or pre-production environment before being applied in production wherever possible. Before any significant operation, a backup, a snapshot or another suitable restore point should be taken.

1
2
3
4
5
6
cat /etc/debian_version
cat /etc/os-release
grep -R "^[^#]" /etc/apt/sources.list /etc/apt/sources.list.d/
apt update
apt list --upgradable
apt upgrade

Flows towards the configured public repositories must be authorised, controlled and documented in the applicable flow matrix. Any change to the repositories must be carried out in line with the applicable maintenance and support procedures.

R3. Appropriate disk partitioning

Applies to: Edge Gateway

Appropriate partitioning isolates the different components of the file system and limits the risks tied to a partition filling up, to the execution of unauthorised files or to the abusive use of temporary directories. The recommended reference partitioning is as follows:

Mount point Options Minimum size
/boot nosuid,nodev,noexec (noauto optional) 1 GB
/opt nosuid,nodev (ro optional) 1 GB
/tmp nosuid,nodev,noexec 4 GB
/srv nosuid,nodev (noexec,ro optional) 1 GB
/home nosuid,nodev,noexec 8 GB
/proc hidepid=2 —
/usr nodev 6 GB
/var nosuid,nodev 5 GB
/var/log nosuid,nodev,noexec 5 GB
/var/tmp nosuid,nodev,noexec 2 GB
swap no option depending on RAM
/ no option rest of the disk

Warning!

Restrictive mount options (noexec, nosuid, nodev, ro) must be applied with care and validated before application, so as not to disrupt the installation, the updates or the operation of CyberElements. After any change to /etc/fstab, test the configuration before rebooting.

Information

The noexec option on /var (ANSSI-BP-028 R28) is not retained: the post-installation scripts of Debian packages (/var/lib/dpkg) require execution rights under /var, a limitation the ANSSI itself points out in its reference partitioning.

1
2
3
4
findmnt -o TARGET,SOURCE,FSTYPE,OPTIONS
cat /etc/fstab
mount -a
findmnt -o TARGET,SOURCE,FSTYPE,OPTIONS

Information

Where deployment starts from a Systancia OVA, the initial partitioning may be predefined. Check that the sizes of /var, /var/log, /tmp and /home are suited to the expected log volume and to the retention requirements.

Information

On recent systems, /tmp is mounted in memory (tmpfs) by default rather than on a disk partition. As soon as a /tmp entry appears explicitly in /etc/fstab, as recommended in this table, that default behaviour is neutralised and /tmp remains a dedicated disk partition with the options above. No further action is therefore needed; conversely, if the choice is made not to dedicate a partition to /tmp, the in-memory mount can be kept and hardened by adding the noexec option through a systemd override (systemctl edit tmp.mount).

Warning!

The hidepid=2 option on /proc is classified "to be validated": compatibility with monitoring and with services reading /proc must be checked, a gid= exception remaining possible (see Classification of recommendations).

R4. Removal of unnecessary packages installed by default

Applies to: Edge Gateway

The system must contain no software that is not indispensable to the operation, administration or security maintenance of CyberElements.

1
2
dpkg -l
apt-mark showauto

Warning!

This recommendation must be applied after installing CyberElements and after validating that the solution works correctly.

Systancia recommends checking that the following packages are not installed, unless a need is explicitly identified:

  • aspell, ispell, libaspell15, m4
  • bsd-mailx, exim4
  • ftp, telnet, traceroute, netcat-traditional, rpcbind
  • gcc and its versioned variants gcc-X, but not the gcc-X-base packages, whose removal can make the system unstable. The default version follows the one supplied by the distribution, to be checked with apt-cache policy gcc
  • laptop-detect, pinentry-gtk2, procmail, vim-tiny

That list can be completed by checking the following families, where they are not needed:

  • printing: cups, cups-browsed
  • network discovery: avahi-daemon
  • Bluetooth: bluetooth, bluez
  • unneeded file sharing: nfs-common
  • old or unencrypted protocols: rsh-client, rsh-server, talk, talkd, tftp, tftpd
  • legacy super-servers: xinetd, inetutils-inetd, openbsd-inetd
  • compilation or debugging tools: make, binutils, build-essential, gdb, strace, ltrace
1
2
3
4
apt remove --purge --simulate <package_name>
apt remove --purge <package_name>
apt autoremove --simulate
apt autoremove

SSH must be preferred for remote administration, replacing unencrypted or obsolete protocols (FTP, RSH, RCP, TELNET). For file transfer, SCP or SFTP must be preferred (openssh-client package). Hardening the SSH service itself is covered in SSH.

R5. Review of active services and listening ports

Applies to: Edge Gateway

The active services and listening ports should be checked regularly so as to make sure that only the services required for operation, administration, monitoring or security maintenance are active.

1
2
3
systemctl --type=service --state=running
systemctl list-unit-files --type=service --state=enabled
ss -tulnp

R6. Integrity check of packages and APT repositories

Applies to: Edge Gateway

Servers must use controlled APT repositories, limited to the sources required for the operation and security maintenance of the solution. Misconfigured repositories can lead to the installation of incompatible, obsolete or unvalidated packages.

Two software sources are used in a standard installation:

  • the official Debian repositories, notably the debian-updates and debian-security suites;
  • the local Systancia repository located under /opt/systancia/repository, used for the packages specific to CyberElements.

Information

Packages coming from the Systancia repository must be updated in line with Systancia product and support procedures. They must not be replaced by packages from third-party repositories or unvalidated test repositories. The policy for automating Debian updates is covered in R7.

Information

Recent distributions declare their sources by default in the deb822 format, as /etc/apt/sources.list.d/*.sources files rather than in the historical /etc/apt/sources.list file. The commands below cover both formats; finding only .sources files on a recent installation is normal.

1
2
3
ls -l /etc/apt/sources.list /etc/apt/sources.list.d/ 2>/dev/null
grep -R "^[[:space:]]*[^#[:space:]]" /etc/apt/sources.list /etc/apt/sources.list.d/ 2>/dev/null
apt update
1
apt-config dump | grep -E '^APT::Install-(Recommends|Suggests)'

Information

APT::Install-Recommends disables the automatic installation of recommended packages. APT::Install-Suggests makes the non-installation of suggested packages explicit. These settings apply to subsequent APT installations, unless explicitly overridden on the command line.

Checking the integrity of the files already installed is handled separately with debsums in R19; this recommendation deals mainly with the provenance of packages, control of the repositories and limitation of the dependencies installed.

R7. Controlled automation of Debian security updates

Applies to: Edge Gateway

Where the operational policy allows it, Debian security updates can be automated using the unattended-upgrades package. That automation must be controlled so as to guarantee compatibility with operational, monitoring, backup and support procedures.

1
apt install unattended-upgrades apt-listchanges

Automatic updates can be enabled with the following command:

1
dpkg-reconfigure unattended-upgrades

Information

Depending on the Debian version and the installation method, the file /etc/apt/apt.conf.d/20auto-upgrades may not be present by default. Its absence alone does not therefore indicate that unattended-upgrades is badly installed or inactive.

The APT configuration actually taken into account can be checked with:

1
apt-config dump | grep -i -A5 periodic

Where automation is enabled, the following settings must notably be present:

1
2
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";

If needed, a dedicated configuration file can be created in /etc/apt/apt.conf.d/20auto-upgrades with the following content:

1
2
3
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
APT::Periodic::AutocleanInterval "7";

The detailed policy applied by unattended-upgrades is configured notably in /etc/apt/apt.conf.d/50unattended-upgrades. Automation should be limited to Debian security updates and to the repositories validated for the supported version.

Warning!

Automatic reboots must be assessed with caution. In production, it is generally recommended not to enable automatic reboot without a validated operational procedure:

1
Unattended-Upgrade::Automatic-Reboot "false";

The state of the periodic APT mechanisms and of the automatic update service should also be checked:

1
2
3
4
5
systemctl status apt-daily.timer
systemctl status apt-daily-upgrade.timer
systemctl status unattended-upgrades
journalctl -u unattended-upgrades
test -f /var/run/reboot-required && cat /var/run/reboot-required

Before enabling automatic updates in production, check that:

  • the repositories match the supported version;
  • the flows towards the authorised repositories are open and documented;
  • the update logs are monitored;
  • and the required reboots are handled through a defined procedure.

Automatic operating system updates do not replace the update procedures for CyberElements Bastion, which must follow the product documentation.