> Source: https://docs.cyberelements.io/saas/da/Security/SecurityHardening/

# Security hardening guide

This guide gathers the **hardening** measures that apply to the components you deploy yourself with CyberElements SaaS, the **Edge Gateways** installed on Debian: hardening of the Debian operating system, of the SSH service and of the local firewall, protection of the Edge Gateway certificates, along with fail2ban, centralised logging, monitoring tools and the protection of session recordings.

In CyberElements SaaS, the platform (Mediation Controller, system console, HTML5 Gateway, database) is operated by CyberElements: the recommendations that concern it alone are not part of this guide. The Windows Edge Gateway is not covered either, the measures of this guide being specific to Debian.

It does **not** describe how to install the Edge Gateways (that is covered by the hybrid deployment section, starting with [Edge Gateway formats](https://docs.cyberelements.io/saas/da/HybridDeployment/EdgeGatewayFormats/)) but what should be done **in addition**, once they are in place, to reduce their attack surface.

## Who it is for

| Audience | Role |
|---|---|
| **Partners and integrators** | applying the hardening measures during deployment |
| **Administrators** | maintaining the security posture in operation |

It assumes familiarity with GNU/Linux system administration and access to the privileged accounts of the servers.

## The standards it builds on

The recommendations come from a cross-reading of the publications of the **ANSSI**, the French national cybersecurity agency:

| Reference | Title | What it contributes here |
|---|---|---|
| **ANSSI-BP-028 v2.0** | Recommandations de sécurité relatives à un système GNU/Linux | the main standard for operating system hardening |
| **DAT-NT-007/ANSSI/SDE/NP v1.2** | Recommandations pour un usage sécurisé d'(Open)SSH | hardening of the SSH service, of authentication and of keys |
| **ANSSI-PA-012 v2.0** | Recommandations de sécurité pour l'architecture d'un système de journalisation | collection, protection and centralisation of logs |

> **Information**
>
> **DAT-NT-007** dates from 17 August 2015. Unlike ANSSI-BP-028 (2022), it has not been revised since: the chapter devoted to SSH takes this into account and points out the directives that have become obsolete in current versions of OpenSSH.

## How to read the recommendations

Every measure carries a **stable number**, identical to the one used in the security hardening guide of CyberElements Bastion, which numbers its recommendations from `R1` to `R79`. That number does not change from one version of the documentation to the next: it allows a measure to be named unambiguously in an exchange with support or in an audit report. This guide keeps only the recommendations that apply to the components you deploy: the numbering therefore has gaps, the missing numbers being those of the recommendations that concern the platform alone.

Not all recommendations apply in the same way:

- most are **directly applicable**, subject to the warnings given in their own section;
- some are **reserved for a support or project intervention**;
- others are **to be validated** against the architecture, the administration workstations or the security policy.

> **Before applying a measure in production**
>
> The recommendations reserved for a support or project intervention and those to be validated are gathered in the [Classification of recommendations](https://docs.cyberelements.io/saas/da/Security/Classification/#reserved-or-to-be-validated) appendix: read it, along with the section of the recommendation, before applying the measure.

## The 60 recommendations

| # | Recommendation | Chapter | Edge Gateway |
|---|---|---|---|
| [**R1**](https://docs.cyberelements.io/saas/da/Security/SystemHardening/SystemInstallation/#r1) | Minimal Debian installation | System hardening | ✅ |
| [**R2**](https://docs.cyberelements.io/saas/da/Security/SystemHardening/SystemInstallation/#r2) | Debian version and security maintenance | System hardening | ✅ |
| [**R3**](https://docs.cyberelements.io/saas/da/Security/SystemHardening/SystemInstallation/#r3) | Appropriate disk partitioning | System hardening | ✅ |
| [**R4**](https://docs.cyberelements.io/saas/da/Security/SystemHardening/SystemInstallation/#r4) | Removal of unnecessary packages installed by default | System hardening | ✅ |
| [**R5**](https://docs.cyberelements.io/saas/da/Security/SystemHardening/SystemInstallation/#r5) | Review of active services and listening ports | System hardening | ✅ |
| [**R6**](https://docs.cyberelements.io/saas/da/Security/SystemHardening/SystemInstallation/#r6) | Integrity check of packages and APT repositories | System hardening | ✅ |
| [**R7**](https://docs.cyberelements.io/saas/da/Security/SystemHardening/SystemInstallation/#r7) | Controlled automation of Debian security updates | System hardening | ✅ |
| [**R8**](https://docs.cyberelements.io/saas/da/Security/SystemHardening/SystemAccounts/#r8) | Management of local accounts and restriction of the root account | System hardening | ✅ |
| [**R9**](https://docs.cyberelements.io/saas/da/Security/SystemHardening/SystemAccounts/#r9) | Privileged administration with sudo | System hardening | ✅ |
| [**R10**](https://docs.cyberelements.io/saas/da/Security/SystemHardening/SystemAccounts/#r10) | Local authentication policy (libpam-pwquality, pam_faillock) | System hardening | ✅ |
| [**R11**](https://docs.cyberelements.io/saas/da/Security/SystemHardening/SystemFilesystem/#r11) | Control of permissions and sensitive files | System hardening | ✅ |
| [**R12**](https://docs.cyberelements.io/saas/da/Security/SystemHardening/SystemFilesystem/#r12) | Hardening of configuration files and sensitive directories | System hardening | ✅ |
| [**R13**](https://docs.cyberelements.io/saas/da/Security/SystemHardening/SystemKernelAndNetwork/#r13) | sysctl parameters for system and network hardening | System hardening | ✅ |
| [**R14**](https://docs.cyberelements.io/saas/da/Security/SystemHardening/SystemKernelAndNetwork/#r14) | Disabling or controlling IPv6 | System hardening | ✅ |
| [**R15**](https://docs.cyberelements.io/saas/da/Security/SystemHardening/SystemKernelAndNetwork/#r15) | Advanced boot and kernel hardening (kernel options) | System hardening | ✅ |
| [**R16**](https://docs.cyberelements.io/saas/da/Security/SystemHardening/SystemKernelAndNetwork/#r16) | Password on the GRUB boot loader | System hardening | ✅ |
| [**R17**](https://docs.cyberelements.io/saas/da/Security/SystemHardening/SystemIntegrity/#r17) | Hardening and review of scheduled tasks | System hardening | ✅ |
| [**R18**](https://docs.cyberelements.io/saas/da/Security/SystemHardening/SystemIntegrity/#r18) | Customisation of the system banner | System hardening | ✅ |
| [**R19**](https://docs.cyberelements.io/saas/da/Security/SystemHardening/SystemIntegrity/#r19) | Integrity check of system files with debsums | System hardening | ✅ |
| [**R20**](https://docs.cyberelements.io/saas/da/Security/SystemHardening/SystemIntegrity/#r20) | Integrity baseline with AIDE | System hardening | ✅ |
| [**R21**](https://docs.cyberelements.io/saas/da/Security/SystemHardening/SystemLogsAndTime/#r21) | Configuration of the system logging service | System hardening | ✅ |
| [**R22**](https://docs.cyberelements.io/saas/da/Security/SystemHardening/SystemLogsAndTime/#r22) | Protection and rotation of logs | System hardening | ✅ |
| [**R23**](https://docs.cyberelements.io/saas/da/Security/SystemHardening/SystemLogsAndTime/#r23) | Protection of command histories and administration traces | System hardening | ✅ |
| [**R24**](https://docs.cyberelements.io/saas/da/Security/SystemHardening/SystemLogsAndTime/#r24) | Time synchronisation with NTP | System hardening | ✅ |
| [**R25**](https://docs.cyberelements.io/saas/da/Security/Ssh/#r25) | Protocol and cryptographic algorithms | SSH | ✅ |
| [**R26**](https://docs.cyberelements.io/saas/da/Security/Ssh/#r26) | Authentication and user access control | SSH | ✅ |
| [**R27**](https://docs.cyberelements.io/saas/da/Security/Ssh/#r27) | SSH key authentication and disabling of passwords | SSH | ✅ |
| [**R28**](https://docs.cyberelements.io/saas/da/Security/Ssh/#r28) | Restriction of network and forwarding features | SSH | ✅ |
| [**R29**](https://docs.cyberelements.io/saas/da/Security/Ssh/#r29) | Network listening and exposure of the SSH service | SSH | ✅ |
| [**R30**](https://docs.cyberelements.io/saas/da/Security/Ssh/#r30) | Limitation of sessions and connection timeouts | SSH | ✅ |
| [**R31**](https://docs.cyberelements.io/saas/da/Security/Ssh/#r31) | Banner and logging of SSH connections | SSH | ✅ |
| [**R32**](https://docs.cyberelements.io/saas/da/Security/Ssh/#r32) | Size and robustness of host and user keys | SSH | ✅ |
| [**R33**](https://docs.cyberelements.io/saas/da/Security/Ssh/#r33) | Entropy quality and uniqueness of host keys | SSH | ✅ |
| [**R34**](https://docs.cyberelements.io/saas/da/Security/Ssh/#r34) | Advanced features not retained by default | SSH | ✅ |
| [**R35**](https://docs.cyberelements.io/saas/da/Security/LocalFirewall/#r35) | Filtering principle and positive security model | Local firewall | ✅ |
| [**R37**](https://docs.cyberelements.io/saas/da/Security/LocalFirewall/#r37) | Simplified profile for the Edge Gateway | Local firewall | ✅ |
| [**R38**](https://docs.cyberelements.io/saas/da/Security/LocalFirewall/#r38) | Persistence of rules at startup | Local firewall | ✅ |
| [**R40**](https://docs.cyberelements.io/saas/da/Security/LocalFirewall/#r40) | Disabling IPv6 when it is not needed | Local firewall | ✅ |
| [**R41**](https://docs.cyberelements.io/saas/da/Security/LocalFirewall/#r41) | Verification, audit and monitoring of rules | Local firewall | ✅ |
| [**R48**](https://docs.cyberelements.io/saas/da/Security/GatewayCertificates/#r48) | Protection of p12 files and their associated configuration | Edge Gateway certificates | ✅ |
| [**R49**](https://docs.cyberelements.io/saas/da/Security/GatewayCertificates/#r49) | Continuity of protection after a certificate update or renewal | Edge Gateway certificates | ✅ |
| [**R57**](https://docs.cyberelements.io/saas/da/Security/Fail2ban/#r57) | Installation and operating principle | fail2ban | ✅ |
| [**R58**](https://docs.cyberelements.io/saas/da/Security/Fail2ban/#r58) | SSH jail | fail2ban | ✅ |
| [**R61**](https://docs.cyberelements.io/saas/da/Security/Fail2ban/#r61) | Interaction with the local firewall | fail2ban | ✅ |
| [**R62**](https://docs.cyberelements.io/saas/da/Security/Fail2ban/#r62) | Operation and monitoring | fail2ban | ✅ |
| [**R63**](https://docs.cyberelements.io/saas/da/Security/CentralizedLogging/#r63) | Principle of centralisation towards the logging infrastructure | Centralised logging | ✅ |
| [**R66**](https://docs.cyberelements.io/saas/da/Security/CentralizedLogging/#r66) | Reliable forwarding to the logging server | Centralised logging | ✅ |
| [**R67**](https://docs.cyberelements.io/saas/da/Security/CentralizedLogging/#r67) | Good practices on the destination logging server | Centralised logging | ❌ |
| [**R68**](https://docs.cyberelements.io/saas/da/Security/MonitoringTools/#r68) | arpwatch: monitoring of local ARP activity | Monitoring tools | ✅ |
| [**R69**](https://docs.cyberelements.io/saas/da/Security/MonitoringTools/#r69) | acct: accounting of connections and commands | Monitoring tools | ✅ |
| [**R70**](https://docs.cyberelements.io/saas/da/Security/MonitoringTools/#r70) | sysstat: system performance statistics | Monitoring tools | ✅ |
| [**R71**](https://docs.cyberelements.io/saas/da/Security/MonitoringTools/#r71) | auditd: audit of the Linux kernel subsystem | Monitoring tools | ✅ |
| [**R72**](https://docs.cyberelements.io/saas/da/Security/MonitoringTools/#r72) | Lynis: periodic configuration audit | Monitoring tools | ✅ |
| [**R73**](https://docs.cyberelements.io/saas/da/Security/MonitoringTools/#r73) | ClamAV: antivirus (to be validated depending on usage) | Monitoring tools | ✅ |
| [**R74**](https://docs.cyberelements.io/saas/da/Security/SessionRecordings/#r74) | Dedicated storage and monitoring of recording space | Session recordings | ✅ |
| [**R75**](https://docs.cyberelements.io/saas/da/Security/SessionRecordings/#r75) | Restriction of access to recordings | Session recordings | ✅ |
| [**R76**](https://docs.cyberelements.io/saas/da/Security/SessionRecordings/#r76) | Retention and purging of recordings | Session recordings | ❌ |
| [**R77**](https://docs.cyberelements.io/saas/da/Security/SessionRecordings/#r77) | Logging of video events | Session recordings | ❌ |
| [**R78**](https://docs.cyberelements.io/saas/da/Security/SessionRecordings/#r78) | Password rotation after a recorded session | Session recordings | ❌ |
| [**R79**](https://docs.cyberelements.io/saas/da/Security/SessionRecordings/#r79) | Hardening of the external database | Session recordings | ✅ |

## Before you start

> **Warning!**
>
> Several measures can **cut off administrative access** if they are applied without care: SSH hardening, the local firewall, locking the `root` account, a password on the boot loader. Before any change of that kind:
>
> - keep an **administration session open** throughout the operation;
> - have **emergency console access** to the virtual machine;
> - check the configuration **before** reloading a service, then open a **second session** to validate it before closing the first one.

The network flows required by the Edge Gateways are described with their installation prerequisites: [Prerequisites](https://docs.cyberelements.io/saas/da/HybridDeployment/EdgeGatewayPrerequisites/), section **Network**.
