> Source: https://docs.cyberelements.io/bastion/4.7/bg/Security/SecurityHardening/

# Security hardening guide

This guide gathers the **hardening** measures that apply to a CyberElements Bastion platform: hardening of the Debian operating system, of the SSH service, of the local firewall, of Apache, of TLS and of the Content Security Policy, along with centralised logging, monitoring and the protection of session recordings.

It does **not** describe how to install the product (that is covered by the [Installation](https://docs.cyberelements.io/bastion/4.7/bg/Installation/Standalone/Introduction/) section) but what should be done **in addition**, once the platform is in place, to reduce its attack surface. The virtual appliances already apply part of these measures: see [Mediation Controller appliances](https://docs.cyberelements.io/bastion/4.7/bg/Installation/MediationController/AppliancesHardening/), [Edge Gateway appliances](https://docs.cyberelements.io/bastion/4.7/bg/Installation/EdgeGateway/AppliancesHardening/) and [PostgreSQL database appliance](https://docs.cyberelements.io/bastion/4.7/bg/Installation/Dependencies/PostgreSQLCluster/Installation/Hardening/).

## 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-009 v2.1** | Recommandations pour la mise en œuvre d'un site Web : maîtriser les standards de sécurité côté navigateur | HTTP headers and Content Security Policy |
| **ANSSI-PA-012 v2.0** | Recommandations de sécurité pour l'architecture d'un système de journalisation | collection, protection and centralisation of logs |
| **ANSSI-PA-035 v1.2** | Recommandations de sécurité relatives à TLS | protocol versions, cipher suites and TLS parameters |

> **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**, from `R1` to `R79`, identical to the one used in the security hardening guide shipped with the product. 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.

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/bastion/4.7/bg/Security/Classification/#reserved-or-to-be-validated) appendix: read it, along with the section of the recommendation, before applying the measure.

## The 79 recommendations

| # | Recommendation | Chapter | Mediation Controller | Edge Gateway |
|---|---|---|---|---|
| [**R1**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SystemHardening/SystemInstallation/#r1) | Minimal Debian installation | System hardening | ✅ | ✅ |
| [**R2**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SystemHardening/SystemInstallation/#r2) | Debian version and security maintenance | System hardening | ✅ | ✅ |
| [**R3**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SystemHardening/SystemInstallation/#r3) | Appropriate disk partitioning | System hardening | ✅ | ✅ |
| [**R4**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SystemHardening/SystemInstallation/#r4) | Removal of unnecessary packages installed by default | System hardening | ✅ | ✅ |
| [**R5**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SystemHardening/SystemInstallation/#r5) | Review of active services and listening ports | System hardening | ✅ | ✅ |
| [**R6**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SystemHardening/SystemInstallation/#r6) | Integrity check of packages and APT repositories | System hardening | ✅ | ✅ |
| [**R7**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SystemHardening/SystemInstallation/#r7) | Controlled automation of Debian security updates | System hardening | ✅ | ✅ |
| [**R8**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SystemHardening/SystemAccounts/#r8) | Management of local accounts and restriction of the root account | System hardening | ✅ | ✅ |
| [**R9**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SystemHardening/SystemAccounts/#r9) | Privileged administration with sudo | System hardening | ✅ | ✅ |
| [**R10**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SystemHardening/SystemAccounts/#r10) | Local authentication policy (libpam-pwquality, pam_faillock) | System hardening | ✅ | ✅ |
| [**R11**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SystemHardening/SystemFilesystem/#r11) | Control of permissions and sensitive files | System hardening | ✅ | ✅ |
| [**R12**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SystemHardening/SystemFilesystem/#r12) | Hardening of configuration files and sensitive directories | System hardening | ✅ | ✅ |
| [**R13**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SystemHardening/SystemKernelAndNetwork/#r13) | sysctl parameters for system and network hardening | System hardening | ✅ | ✅ |
| [**R14**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SystemHardening/SystemKernelAndNetwork/#r14) | Disabling or controlling IPv6 | System hardening | ✅ | ✅ |
| [**R15**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SystemHardening/SystemKernelAndNetwork/#r15) | Advanced boot and kernel hardening (kernel options) | System hardening | ✅ | ✅ |
| [**R16**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SystemHardening/SystemKernelAndNetwork/#r16) | Password on the GRUB boot loader | System hardening | ✅ | ✅ |
| [**R17**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SystemHardening/SystemIntegrity/#r17) | Hardening and review of scheduled tasks | System hardening | ✅ | ✅ |
| [**R18**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SystemHardening/SystemIntegrity/#r18) | Customisation of the system banner | System hardening | ✅ | ✅ |
| [**R19**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SystemHardening/SystemIntegrity/#r19) | Integrity check of system files with debsums | System hardening | ✅ | ✅ |
| [**R20**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SystemHardening/SystemIntegrity/#r20) | Integrity baseline with AIDE | System hardening | ✅ | ✅ |
| [**R21**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SystemHardening/SystemLogsAndTime/#r21) | Configuration of the system logging service | System hardening | ✅ | ✅ |
| [**R22**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SystemHardening/SystemLogsAndTime/#r22) | Protection and rotation of logs | System hardening | ✅ | ✅ |
| [**R23**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SystemHardening/SystemLogsAndTime/#r23) | Protection of command histories and administration traces | System hardening | ✅ | ✅ |
| [**R24**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SystemHardening/SystemLogsAndTime/#r24) | Time synchronisation with NTP | System hardening | ✅ | ✅ |
| [**R25**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Ssh/#r25) | Protocol and cryptographic algorithms | SSH | ✅ | ✅ |
| [**R26**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Ssh/#r26) | Authentication and user access control | SSH | ✅ | ✅ |
| [**R27**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Ssh/#r27) | SSH key authentication and disabling of passwords | SSH | ✅ | ✅ |
| [**R28**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Ssh/#r28) | Restriction of network and forwarding features | SSH | ✅ | ✅ |
| [**R29**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Ssh/#r29) | Network listening and exposure of the SSH service | SSH | ✅ | ✅ |
| [**R30**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Ssh/#r30) | Limitation of sessions and connection timeouts | SSH | ✅ | ✅ |
| [**R31**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Ssh/#r31) | Banner and logging of SSH connections | SSH | ✅ | ✅ |
| [**R32**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Ssh/#r32) | Size and robustness of host and user keys | SSH | ✅ | ✅ |
| [**R33**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Ssh/#r33) | Entropy quality and uniqueness of host keys | SSH | ✅ | ✅ |
| [**R34**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Ssh/#r34) | Advanced features not retained by default | SSH | ✅ | ✅ |
| [**R35**](https://docs.cyberelements.io/bastion/4.7/bg/Security/LocalFirewall/#r35) | Filtering principle and positive security model | Local firewall | ✅ | ✅ |
| [**R36**](https://docs.cyberelements.io/bastion/4.7/bg/Security/LocalFirewall/#r36) | Base rules in Standalone mode (Mediation Controller) | Local firewall | ✅ | ❌ |
| [**R37**](https://docs.cyberelements.io/bastion/4.7/bg/Security/LocalFirewall/#r37) | Simplified profile for the Edge Gateway | Local firewall | ❌ | ✅ |
| [**R38**](https://docs.cyberelements.io/bastion/4.7/bg/Security/LocalFirewall/#r38) | Persistence of rules at startup | Local firewall | ✅ | ✅ |
| [**R39**](https://docs.cyberelements.io/bastion/4.7/bg/Security/LocalFirewall/#r39) | Cluster mode: filtering script managed by the product | Local firewall | ✅ | ❌ |
| [**R40**](https://docs.cyberelements.io/bastion/4.7/bg/Security/LocalFirewall/#r40) | Disabling IPv6 when it is not needed | Local firewall | ✅ | ✅ |
| [**R41**](https://docs.cyberelements.io/bastion/4.7/bg/Security/LocalFirewall/#r41) | Verification, audit and monitoring of rules | Local firewall | ✅ | ✅ |
| [**R42**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Apache/#r42) | Reducing the attack surface and exposed information | Apache | ✅ | ❌ |
| [**R43**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Apache/#r43) | Management of persistent connections | Apache | ✅ | ❌ |
| [**R44**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Apache/#r44) | HTTP security headers | Apache | ✅ | ❌ |
| [**R45**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Apache/#r45) | Restriction of HTTP methods and directory browsing | Apache | ✅ | ❌ |
| [**R46**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Apache/#r46) | Compression of Reverse Proxy virtual hosts and the BREACH vulnerability | Apache | ✅ | ❌ |
| [**R47**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Apache/#r47) | Permissions of configuration files | Apache | ✅ | ❌ |
| [**R48**](https://docs.cyberelements.io/bastion/4.7/bg/Security/GatewayCertificates/#r48) | Protection of p12 files and their associated configuration | Edge Gateway certificates | ❌ | ✅ |
| [**R49**](https://docs.cyberelements.io/bastion/4.7/bg/Security/GatewayCertificates/#r49) | Continuity of protection after a certificate update or renewal | Edge Gateway certificates | ❌ | ✅ |
| [**R50**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Tls/#r50) | General TLS policy | TLS | ✅ | ❌ |
| [**R51**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Tls/#r51) | Configuration of the Mediation Controller Apache portal | TLS | ✅ | ❌ |
| [**R52**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Tls/#r52) | Verification of the effective TLS configuration | TLS | ✅ | ❌ |
| [**R53**](https://docs.cyberelements.io/bastion/4.7/bg/Security/ContentSecurityPolicy/#r53) | Deployment of the CSP on Web VPN hosts | Content Security Policy | ✅ | ❌ |
| [**R54**](https://docs.cyberelements.io/bastion/4.7/bg/Security/ContentSecurityPolicy/#r54) | Known product limitation: unsafe-inline and unsafe-eval | Content Security Policy | ✅ | ❌ |
| [**R55**](https://docs.cyberelements.io/bastion/4.7/bg/Security/ContentSecurityPolicy/#r55) | Consistency with the headers protecting against clickjacking | Content Security Policy | ✅ | ❌ |
| [**R56**](https://docs.cyberelements.io/bastion/4.7/bg/Security/ContentSecurityPolicy/#r56) | Collection of CSP violation reports (optional) | Content Security Policy | ✅ | ❌ |
| [**R57**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Fail2ban/#r57) | Installation and operating principle | fail2ban | ✅ | ✅ |
| [**R58**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Fail2ban/#r58) | SSH jail | fail2ban | ✅ | ✅ |
| [**R59**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Fail2ban/#r59) | Apache jails | fail2ban | ✅ | ❌ |
| [**R60**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Fail2ban/#r60) | Jail specific to CyberElements Bastion authentication | fail2ban | ✅ | ❌ |
| [**R61**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Fail2ban/#r61) | Interaction with the local firewall | fail2ban | ✅ | ✅ |
| [**R62**](https://docs.cyberelements.io/bastion/4.7/bg/Security/Fail2ban/#r62) | Operation and monitoring | fail2ban | ✅ | ✅ |
| [**R63**](https://docs.cyberelements.io/bastion/4.7/bg/Security/CentralizedLogging/#r63) | Principle of centralisation towards the logging infrastructure | Centralised logging | ✅ | ✅ |
| [**R64**](https://docs.cyberelements.io/bastion/4.7/bg/Security/CentralizedLogging/#r64) | Redirection of Apache logs to syslog | Centralised logging | ✅ | ❌ |
| [**R65**](https://docs.cyberelements.io/bastion/4.7/bg/Security/CentralizedLogging/#r65) | Redirection of organisation logs to syslog | Centralised logging | ✅ | ❌ |
| [**R66**](https://docs.cyberelements.io/bastion/4.7/bg/Security/CentralizedLogging/#r66) | Reliable forwarding to the logging server | Centralised logging | ✅ | ✅ |
| [**R67**](https://docs.cyberelements.io/bastion/4.7/bg/Security/CentralizedLogging/#r67) | Good practices on the destination logging server | Centralised logging | ❌ | ❌ |
| [**R68**](https://docs.cyberelements.io/bastion/4.7/bg/Security/MonitoringTools/#r68) | arpwatch: monitoring of local ARP activity | Monitoring tools | ✅ | ✅ |
| [**R69**](https://docs.cyberelements.io/bastion/4.7/bg/Security/MonitoringTools/#r69) | acct: accounting of connections and commands | Monitoring tools | ✅ | ✅ |
| [**R70**](https://docs.cyberelements.io/bastion/4.7/bg/Security/MonitoringTools/#r70) | sysstat: system performance statistics | Monitoring tools | ✅ | ✅ |
| [**R71**](https://docs.cyberelements.io/bastion/4.7/bg/Security/MonitoringTools/#r71) | auditd: audit of the Linux kernel subsystem | Monitoring tools | ✅ | ✅ |
| [**R72**](https://docs.cyberelements.io/bastion/4.7/bg/Security/MonitoringTools/#r72) | Lynis: periodic configuration audit | Monitoring tools | ✅ | ✅ |
| [**R73**](https://docs.cyberelements.io/bastion/4.7/bg/Security/MonitoringTools/#r73) | ClamAV: antivirus (to be validated depending on usage) | Monitoring tools | ✅ | ✅ |
| [**R74**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SessionRecordings/#r74) | Dedicated storage and monitoring of recording space | Session recordings | ✅ | ✅ |
| [**R75**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SessionRecordings/#r75) | Restriction of access to recordings | Session recordings | ✅ | ✅ |
| [**R76**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SessionRecordings/#r76) | Retention and purging of recordings | Session recordings | ✅ | ❌ |
| [**R77**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SessionRecordings/#r77) | Logging of video events | Session recordings | ✅ | ❌ |
| [**R78**](https://docs.cyberelements.io/bastion/4.7/bg/Security/SessionRecordings/#r78) | Password rotation after a recorded session | Session recordings | ✅ | ❌ |
| [**R79**](https://docs.cyberelements.io/bastion/4.7/bg/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 between the components and towards the outside are described with the installation prerequisites: [Mediation Controller](https://docs.cyberelements.io/bastion/4.7/bg/Installation/MediationController/Prerequisites/#network) and [Edge Gateways](https://docs.cyberelements.io/bastion/4.7/bg/Installation/EdgeGateway/Prerequisites/#network), section **Network**.
