System logging and time synchronisation¶
ANSSI-BP-028 v2.0 reference: R71, R72 (M/I/R levels) for system logging; no dedicated recommendation for time synchronisation, a cross-cutting good practice (consistency of logs, certificates, authentication).
This section covers local system logging, the protection of logs and command histories, then time synchronisation. Log centralisation and the integration with fail2ban are covered in the dedicated chapters: Centralised logging and fail2ban.
R21. Configuration of the system logging service¶
Applies to: Edge Gateway
CyberElements servers must have an active and properly configured logging service. The
rsyslog service can be used for the collection and management of system logs.
1 | |
The main configuration is generally located in /etc/rsyslog.conf and /etc/rsyslog.d/. Where the
architecture does not provide for the use of IPv6, IPv4 should be forced in /etc/default/rsyslog:
1 | |
1 | |
It should be checked that the system logs are indeed generated, and that their permissions prevent any change or deletion by an unauthorised user:
1 2 | |
The logs must be kept in line with the security and operational policy, with a rotation
configured so as to avoid the /var and /var/log partitions filling up (/etc/logrotate.conf,
/etc/logrotate.d/). Centralising logs towards a remote server or a monitoring solution, where the
architecture allows it, is covered in Centralised logging.
It is recommended to monitor the state of the rsyslog service, the presence of recent logs, the
space available on /var and /var/log, rotation errors and the critical errors reported by the
system. Any change to the logging configuration must be documented.
R22. Protection and rotation of logs¶
Applies to: Edge Gateway
System and application logs may contain sensitive information: authentication traces, system errors, IP addresses, user names, administration events or information useful in analysing an incident. They must be protected against unauthorised access, illegitimate changes and accidental or malicious deletion.
1 | |
The logs must only be modifiable by the authorised accounts and services; read access must be limited to administrators, to monitoring accounts or to explicitly authorised accounts. Membership of the groups that allow certain logs to be consulted must be reviewed regularly:
1 2 | |
The rotation configuration can be tested without being applied, using debug mode:
1 | |
The partitions holding the logs must be watched so as to avoid them filling up:
1 2 | |
Where log centralisation is in place, the local logs do not necessarily have to be kept indefinitely, but a minimum local retention must be defined according to operational, support and investigation needs. It is recommended to monitor the space available, rotation errors, the absence of recent log generation and abnormal deletions or changes of log files. Any change to the retention or rotation policy must be documented.
R23. Protection of command histories and administration traces¶
Applies to: Edge Gateway
Command histories may contain sensitive information: file paths, user names, configuration parameters, IP addresses or, in some cases, secrets typed by mistake on the command line. The histories of the accounts with interactive access should be protected, notably the administration, maintenance and support accounts.
History files concerned:
1 2 3 4 5 6 | |
1 2 3 | |
Typing secrets directly on the command line should be avoided (passwords, access tokens, private keys, API secrets, connection strings containing credentials). Where possible, secrets must be passed through the mechanisms intended for that: an interactive prompt, a protected file, a controlled temporary variable, a secret vault or a validated support procedure.
For accounts using bash, the history configuration can be reinforced in the profile file of the
account (~/.bashrc):
1 2 3 4 | |
Warning!
Command histories must not be considered a reliable or sufficient audit mechanism: they can be modified by the user concerned and do not replace system logging, sudo logs or application logs. The maintenance accounts used as part of support must be given particular attention; the traces of an operation must be kept in line with the applicable support procedures, without exposing secrets or sensitive information.
R24. Time synchronisation with NTP¶
Applies to: Edge Gateway
Time synchronisation is essential to the correct operation and to the security of a CyberElements Bastion infrastructure. A time difference between components can affect the consistency of logs, the analysis of security events, authentication mechanisms, certificate validation, exchanges with external directories or services as well as support and investigation operations.
The Edge Gateway servers must have reliable, consistent and monitored time synchronisation.
As part of a CyberElements installation, the NTP service may be installed or configured by the packages of the solution. Before any change, its presence and state must therefore be checked:
1 2 | |
Information
The time synchronisation service used is based on NTPsec. The main configuration is located in
/etc/ntpsec/ntp.conf, and the start-up options of the service in /etc/default/ntpsec.
The existing configuration must be backed up before any change:
1 2 | |
Configuring the time sources¶
The NTP servers used must be controlled and consistent with the network architecture. Where a server sits in a DMZ, NTP access must be limited to the explicitly authorised time sources.
Example configuration in /etc/ntpsec/ntp.conf with two internal NTP servers:
1 2 | |
The iburst option speeds up the initial acquisition of synchronisation once the NTP source becomes
reachable.
The configured sources can be checked with:
1 | |
Warning!
The public NTP sources present in the initial configuration must not be kept if the network policy requires the exclusive use of internal time servers. The configured sources must be documented and match the explicitly authorised flows.
Using IPv4 only¶
Where the CyberElements architecture does not use IPv6, the NTP service should be forced to
use IPv4. In /etc/default/ntpsec, configure:
1 | |
The -4 option forces the service to use IPv4. The -g option allows the service to correct a
large initial clock offset at start-up.
After the change:
1 2 | |
Checking synchronisation¶
After configuring or restarting the service, check the NTP sources and their state:
1 | |
The source currently selected for synchronisation can be identified in the first column of the
ntpq output.
Detailed information on the state of the daemon can also be consulted with:
1 | |
The service can be checked with:
1 2 | |
It is also possible to check that the service uses the expected NTP port:
1 | |
The logs of the service must be checked in case of an anomaly:
1 | |
or, for recent events:
1 | |
Network flows¶
NTP flows must be authorised in line with the flow matrix of the deployment. The protocol mainly uses UDP/123, towards the authorised time sources only.
No NTP access towards an unplanned destination must be authorised.
Monitoring¶
Time synchronisation must be monitored so as to detect notably:
- the loss of the selected NTP source;
- the absence of reachable NTP sources;
- an abnormal clock drift;
- the
ntpsecservice stopping; - repeated errors present in the logs of the service.
Any change to the time sources, to the NTP configuration or to the associated filtering rules must be documented.
Information
The NTP configuration must be consistent across all CyberElements components. A common time source or a controlled synchronisation chain notably makes it easier to correlate logs between the Edge Gateway and the security or monitoring devices.