Hyppää sisältöön

Scheduled tasks, banner and integrity

ANSSI-BP-028 v2.0 reference: no dedicated recommendation for scheduled tasks or for the system banner (supplementary good practices); R76, R77 (M/I/R/E levels) for file integrity.

This section covers the review of scheduled tasks, the system banner and the integrity check of files.

R17. Hardening and review of scheduled tasks

Applies to: Mediation Controller · Edge Gateway

Scheduled tasks may be used by the operating system, by CyberElements Bastion, by monitoring tools or by operational procedures specific to the deployment. On a CyberElements Bastion server, they must be limited to the needs required for the operation of the solution, for its administration, for monitoring or for security maintenance.

Warning!

CyberElements Bastion may create or use its own scheduled tasks. Those tasks must not be deleted, disabled or modified without prior validation by Systancia or without an explicitly applicable support procedure. The aim of this recommendation is to allow a configuration review, not to delete existing tasks automatically.

A poorly controlled scheduled task can present a significant risk, notably if it runs a script that an unprivileged user can modify or if it allows commands to be run with elevated privileges. The following locations should be checked regularly:

1
2
3
4
5
6
/etc/crontab
/etc/cron.d/
/etc/cron.hourly/
/etc/cron.daily/
/etc/cron.weekly/
/etc/cron.monthly/
1
2
crontab -l -u <user_name>
systemctl list-timers --all

It is recommended to check that:

  • the scheduled tasks are identified and documented;
  • the tasks tied to CyberElements Bastion are kept and comply with the documentation or with the support procedures;
  • the scripts run still exist, are legitimate and cannot be modified by unprivileged users;
  • the tasks run with elevated privileges are strictly necessary;
  • obsolete, unknown or undocumented tasks are analysed before any action;
  • important outputs or errors are logged or monitored.
1
2
3
ls -ld /etc/cron.d /etc/cron.hourly /etc/cron.daily /etc/cron.weekly /etc/cron.monthly
ls -l /etc/crontab
ls -l <script_path>

A script run by root must not be modifiable by an unprivileged user. Any scheduled task added for maintenance, monitoring or audit purposes must be documented: aim, execution frequency, account used, files or commands run.

R18. Customisation of the system banner

Applies to: Mediation Controller · Edge Gateway

The banners displayed on local or remote connections must not disclose sensitive technical information about the server: operating system version, components installed or architecture of the solution. An overly detailed banner can provide information useful to an attacker during the reconnaissance phase.

The following files can be used:

1
2
/etc/issue
/etc/issue.net

/etc/issue is generally used for local connections, /etc/issue.net for remote connections (notably SSH, where the Banner directive is configured). Example of a generic banner. In /etc/issue, the backslash (\) starts an escape sequence that is interpreted on display (\n, \l…): each \ of the banner is doubled there. /etc/issue.net does not interpret them: the banner is written there as it stands.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
      ____      _               _____ _                           _
     / ___|   _| |__   ___ _ __| ____| | ___ _ __ ___   ___ _ __ | |_ ___
    | |  | | | | '_ \ / _ \ '__|  _| | |/ _ \ '_ ` _ \ / _ \ '_ \| __/ __|
    | |__| |_| | |_) |  __/ |  | |___| |  __/ | | | | |  __/ | | | |_\__ \
     \____\__, |_.__/ \___|_|  |_____|_|\___|_| |_| |_|\___|_| |_|\__|___/
          |___/
#################################################################
# WARNING:                                                      #
# You must have specific authorization to access this machine.  #
# Unauthorized access to this machine is prohibited and will be #
# considered as intrusion.                                      #
# Unauthorized users will be logged, monitored, and could be    #
# prosecuted.                                                   #
#################################################################
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
      ____      _               _____ _                           _
     / ___|   _| |__   ___ _ __| ____| | ___ _ __ ___   ___ _ __ | |_ ___
    | |  | | | | '_ \\ / _ \\ '__|  _| | |/ _ \\ '_ ` _ \\ / _ \\ '_ \\| __/ __|
    | |__| |_| | |_) |  __/ |  | |___| |  __/ | | | | |  __/ | | | |_\\__ \\
     \\____\\__, |_.__/ \\___|_|  |_____|_|\\___|_| |_| |_|\\___|_| |_|\\__|___/
          |___/
#################################################################
# WARNING:                                                      #
# You must have specific authorization to access this machine.  #
# Unauthorized access to this machine is prohibited and will be #
# considered as intrusion.                                      #
# Unauthorized users will be logged, monitored, and could be    #
# prosecuted.                                                   #
#################################################################

The banner must not contain:

  • the name or the precise version of the operating system;
  • the version of CyberElements Bastion;
  • the precise role of the server;
  • network addressing information;
  • sensitive internal names or information about the organisation of the infrastructure.
1
ls -l /etc/issue /etc/issue.net

The SSH banner is configured in /etc/ssh/sshd_config:

1
Banner /etc/issue.net

Warning!

After changing the SSH configuration, test the syntax before reloading the service, and keep an administration session open so as to be able to correct the configuration in case of error.

1
2
sshd -t
systemctl reload ssh

R19. Integrity check of system files with debsums

Applies to: Mediation Controller · Edge Gateway

The debsums tool checks the integrity of the files installed by Debian packages, by comparing their checksums with the expected values supplied by the packages. It makes it possible to detect some unexpected changes, notably after a maintenance operation, an update, a restore or as part of a configuration audit.

1
2
3
apt install debsums
debsums -s
debsums -as

The -s option displays only the files whose integrity does not match the expected values; -as also includes the configuration files managed by the Debian packages. The results must be analysed before any corrective action: some changes may have been made legitimately as part of the configuration of the system, of the installation of CyberElements Bastion or of validated operational procedures.

Warning!

debsums only checks the files installed by Debian packages that have checksums. It does not make it possible to check every file of the system, nor the files created dynamically, the logs, the application files not covered or the configuration files specific to the deployment.

1
debsums -s > /var/log/debsums-check.log

A check should be run after the initial installation, after a major update, after a maintenance operation or a backup restore, as part of a regular audit, or where an unauthorised change is suspected. For a more complete integrity watch (notably on the configuration files and application directories not covered by the Debian packages), a dedicated tool such as AIDE (R20) must be considered.

R20. Integrity baseline with AIDE

Applies to: Mediation Controller · Edge Gateway

AIDE (Advanced Intrusion Detection Environment) makes it possible to create a baseline of the state of certain files and directories, then to detect the changes made since that baseline. It is used alongside debsums so as to watch files not covered by the checksums of the Debian packages, notably some configuration files, application directories or files specific to the operation of the server.

1
apt install aide

Information

AIDE uses a main configuration located in /etc/aide/aide.conf and can be supplemented by dedicated files in /etc/aide/aide.conf.d/. So as to make maintenance easier and to avoid modifying the configuration supplied by the package directly, a file specific to CyberElements Bastion should be created.

Example configuration for CyberElements Bastion:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
cat > /etc/aide/aide.conf.d/90_cyberelements_bastion << 'EOF'
# ------------------------------------------------------------
# CyberElements Bastion - additional AIDE rules
# ------------------------------------------------------------
# System security configuration
/etc/ssh 0 Full
/etc/sudoers$ 0 Full
/etc/sudoers.d 0 Full
/etc/pam.d 0 Full
/etc/security 0 Full
/etc/apt 0 Full
/etc/systemd/system 0 Full
# System startup
/boot 0 Full
# Application directory - to be completed as needed
/usr/local/ipdiva 0 Full
EOF

The Full rule group checks the main attributes of the files and directories watched, notably the type, the permissions, the owner, the group, the size, the dates, the inode and the checksums available. The application paths must be adapted to the role of the server and to the stability of the directories concerned.

Validating the configuration:

1
aide --config-check

Before creating the baseline, it is also possible to check the rules actually applied to a scope without writing an AIDE database:

1
2
aide --dry-init --limit /etc
aide --dry-init --limit /usr/local/ipdiva

Initialising the baseline. The baseline must be created only when the server is in a state known to be healthy, after CyberElements Bastion has been installed, the hardening measures applied and the correct operation of the solution validated.

1
aideinit

Information

aideinit generates the new baseline and offers to activate it. The database must only be validated after checking that there is no anomaly and confirming that the configuration watched matches the expected state of the server.

Integrity check:

1
aide --check

The deviations reported must be analysed before any corrective action. A change may be legitimate (update, configuration change, maintenance operation, evolution of the solution) or reveal an unauthorised change.

Updating the database after a legitimate change:

1
aide --update

After the reported changes have been analysed and validated, the new database can replace the active baseline following a controlled procedure. A copy of the previous database should be kept temporarily so as to make a rollback or an investigation easier.

1
2
cp -a /var/lib/aide/aide.db /var/lib/aide/aide.db.bak
mv /var/lib/aide/aide.db.new /var/lib/aide/aide.db

Warning!

Dynamic directories must not be excluded globally without analysis. In particular, excluding the whole of /var, /var/log, /run or /tmp by default is not advised. Where a directory specific to CyberElements Bastion generates many legitimate changes, prefer a targeted exclusion of the single path concerned.

Example of a targeted exclusion, to be adapted only after a dynamic directory has been identified:

1
!/usr/local/ipdiva/<dynamic_directory>/.*

The AIDE reports must be kept and, where possible, brought into monitoring or log centralisation so as to allow integrity deviations to be tracked over time.

Information

In the case of an OVA or of a prepared image, the AIDE baseline must only be initialised definitively after deployment in the target environment, network configuration, application of the necessary security settings and validation that CyberElements Bastion works correctly.