> Source: https://docs.cyberelements.io/bastion/4.7/lt/Security/SystemHardening/SystemAccounts/

# Accounts, privileges and local authentication

*ANSSI-BP-028 v2.0 reference: R30, R32, R33, R38 to R44 (M/I levels, R for some sudo directives) for accounts and privileges; R31, R68 (M level) for local authentication.*

This section deals with the management of local accounts, with restricting the use of the root account and with setting up controlled privileged administration using sudo. It also covers the **local authentication policy** applied to the operating system accounts.

## R8. Management of local accounts and restriction of the root account

**Applies to**: Mediation Controller ✅ · Edge Gateway ✅

The local accounts present on CyberElements Bastion servers must be limited to the sole needs of administration, maintenance or operation of the solution. The use of named accounts must be preferred so as to guarantee the accountability of the actions carried out; shared or generic accounts must be avoided.

```
1
2
3
```

Accounts that are no longer used should be disabled, after validating that this has no impact on the operation of the solution. Locking the password alone does not by itself guarantee that every access mode to the account is fully disabled; where an account must be disabled, its interactive use must also be prevented.

```
1
2
```

The root account has full privileges on the system; its use must be limited to operations that explicitly require that level of privilege. An administrator should first log in with a named account, then elevate their privileges following a controlled procedure, rather than use the root account directly. That approach strengthens accountability while retaining intervention possibilities in line with the applicable support procedures.

Direct access to the root account over SSH must be disabled; this point is covered in [SSH](https://docs.cyberelements.io/bastion/4.7/lt/Security/Ssh/#r26).

The root account itself must be kept as an emergency ("break glass") access: a strong password, kept in a vault in line with the secret management policy in case the privilege elevation mechanism is lost ([R9](#r9)). Check its state:

```
1
```

> **Warning!**
>
> ANSSI-BP-028 (R33) recommends disabling the root account where privileged administration relies on named accounts and sudo. In the context of CyberElements Bastion, that measure is not retained by default, so as to keep an emergency access possibility should the privilege elevation mechanism or the authentication chain fail. The root account must then be considered an emergency ("break glass") account: its direct access over SSH must be disabled, its use limited to exceptional recovery or support operations, and its secret kept in line with the secret management policy. Fully locking the root account (`passwd -l root`) remains conceivable once the sudo model and an alternative recovery procedure have been validated. Depending on the system configuration, the recovery or rescue mode mechanisms may depend on access to the root account. That measure is therefore classified "To be validated" and must be tested on a mock-up before being applied in production.

ANSSI-BP-028 (R32) recommends locking local user sessions after an idle period. On CyberElements Bastion servers, administered mainly on the command line, that requirement can be supplemented by the expiry of idle interactive shells. For Bash sessions, an expiry delay can be set through the `TMOUT` variable, declared read-only so that a user cannot neutralise it, for instance in a dedicated `/etc/profile.d/99-timeout.sh` file:

```
1
2
3
```

The value, expressed in seconds, must be adapted to the security policy and operational constraints. `TMOUT` causes an interactive Bash shell to close after the idle period; it is not a generic session locking mechanism and its behaviour may differ with other command interpreters. The closing of idle SSH sessions is **not** handled by the `ClientAliveInterval` and `ClientAliveCountMax` directives in [SSH](https://docs.cyberelements.io/bastion/4.7/lt/Security/Ssh/#r30), which only close a connection whose client no longer responds. The various idle delays configured must remain consistent with one another.

> **Classification**
>
> **To be validated**: Full locking of the root account (`passwd -l`). See the [Classification of recommendations](https://docs.cyberelements.io/bastion/4.7/lt/Security/Classification/#reserved-or-to-be-validated) appendix.

## R9. Privileged administration with sudo

**Applies to**: Mediation Controller ✅ · Edge Gateway ✅

Where actions require elevated privileges, a controlled privilege elevation mechanism such as sudo should be used rather than the root account directly. Using sudo strengthens accountability, limits direct use of the root account, logs the commands executed and restricts the rights granted according to the role of the administrators.

```
1
```

Any change must be made with `visudo`, which checks the syntax before application.

```
1
```

On Debian, the native `sudo` group already has a full elevation rule in `/etc/sudoers`; for the model retained here (a global rule for a small team of administrators), it is therefore necessary neither to create a dedicated group nor to add a rule. For the record, the existing rule:

```
1
```

Add each named administration account to the group:

```
1
```

> **Information**
>
> A dedicated group (for example `bastion-admins`) becomes relevant again for delegation differentiated by role (several groups carrying distinct rules, see the information on ANSSI-BP-028 recommendations R40 and R43 below) or if the security policy forbids reusing the default groups of the distribution. In that case, create the group (`groupadd`) and associate a dedicated rule with it in `/etc/sudoers.d/`. If the additional restriction of the sudo binary presented at the end of this recommendation is retained, that choice must also be reflected there.

The rights granted through sudo must be limited to the identified administration needs. The `NOPASSWD` option must not be configured by default; it must be used only for specific technical needs, documented and validated.

> **Information**
>
> ANSSI-BP-028 (R40, R43) further recommends, in the sudoers rules, targeting unprivileged users rather than root as far as possible and strictly specifying the arguments allowed for each command. That model of fine delegation per command suits large teams with differentiated roles; for a small team of trusted administrators, the global rule above remains a deliberate choice. That point is classified To be validated depending on the administration model retained (see [Classification of recommendations](https://docs.cyberelements.io/bastion/4.7/lt/Security/Classification/#reserved-or-to-be-validated)).

The following directives strengthen traceability and the compartmentalisation of sessions, aligning with ANSSI-BP-028 (R39). They must be placed in a dedicated file under `/etc/sudoers.d/`, created and edited with `visudo`, which checks their syntax before application.

The files under `/etc/sudoers.d/` are read in lexicographical order and, for a given option, the last value read prevails: the `99-` prefix guarantees that these directives apply last. File names containing a dot or ending with "~" are ignored by sudo.

```
1
2
3
4
5
6
7
8
9
```

> **Warning!**
>
> The `noexec` and `requiretty` directives are not retained in the baseline applied by default. `noexec` can prevent common administrative commands, notably `apt`, editors or shell scripts, from launching their sub-programs; `requiretty` can block automations run without a terminal. They can be assessed on a mock-up for targeted sudo rules, giving preference to the `NOEXEC` tag command by command and to explicit documentation of the need or of the deviation (see [Classification of recommendations](https://docs.cyberelements.io/bastion/4.7/lt/Security/Classification/#reserved-or-to-be-validated)).

Where the sudo version and the operational context allow it, input and output logging can also be enabled:

```
1
2
3
4
```

> **Warning!**
>
> These input/output logging options must be validated before application: they increase the volume of logs generated and may contain sensitive information typed or displayed during administration sessions. The sudo log file must be protected with suitable permissions and, where possible, brought into the log centralisation policy.

```
1
2
```

> **Information**
>
> Beyond the configuration files, the `/usr/bin/sudo` binary itself can be restricted to the authorised administrators group rather than remaining executable by every account on the system (the default behaviour of the distribution):
>
> ```
> 1
> 2
> ```

> **Warning!**
>
> Classified to be validated (optional): this restriction must be checked after each update of the sudo package, which may restore the default permissions of the Debian package. It must also be reflected on any maintenance account (`systancia`) that needs to use sudo, by adding it to the `sudo` group rather than by widening the permissions of the binary (see [Classification of recommendations](https://docs.cyberelements.io/bastion/4.7/lt/Security/Classification/#reserved-or-to-be-validated)).

> **Information**
>
> In the case of the OVAs supplied by Systancia, a maintenance account such as `systancia` may be present so as to allow support operations. That account must be considered an identified maintenance account, whose use must be framed by the applicable support procedures, limited to the necessary interventions and logged. Its access must not be disabled without a validated alternative support procedure.

> **Warning!**
>
> A syntax error in a sudo configuration file can block privilege elevation. Before any change, keep an administration session open with sufficient privileges. After the change, check the syntax and test privilege elevation before closing that session:
>
> ```
> 1
> 2
> 3
> 4
> ```

The `sudo whoami` command must return `root` where privilege elevation is authorised. The configuration files dedicated to sudo must belong to root and must not be modifiable by unprivileged users.

## R10. Local authentication policy (libpam-pwquality, pam_faillock)

**Applies to**: Mediation Controller ✅ · Edge Gateway ✅

This recommendation concerns the local accounts of the operating system. Where the authentication of users or administrators is delegated to an external directory (LDAP, Active Directory), the main password, lockout and renewal policy must be carried by that directory.

> **Warning!**
>
> Changes to the PAM configuration must be made with care: a configuration error can prevent all local or remote authentication. Before any change, keep an administration session open with sufficient privileges so as to be able to correct the configuration in case of error.

The `libpam-pwquality` module makes it possible to define minimum requirements on the quality of local passwords:

```
1
```

Configuration in `/etc/pam.d/common-password` (modification of the first active line):

```
1
```

- `retry=3`: number of entry attempts when changing the password
- `minlen=12`: minimum length
- `difok=3`: minimum number of characters differing from the old password
- `ucredit` / `lcredit` / `dcredit` / `ocredit` = -1: mandatory presence of uppercase letters, lowercase letters, digits and special characters
- `maxrepeat=3`: limits the successive repetitions of a same character
- `gecoscheck`: prevents the use of elements taken from the account information

These settings must remain compatible with the maintenance accounts and the applicable support procedures.

Temporary lockout after authentication failures, through `pam_faillock`, in `/etc/security/faillock.conf`:

```
1
2
3
4
```

These settings log authentication failures, temporarily lock an account after 3 failures and unlock it automatically after 300 seconds, over a sliding window of 900 seconds.

> **Warning!**
>
> Locking the root account through `pam_faillock` (the `even_deny_root` option) must be assessed with caution and must not be enabled without prior validation, so as not to block support or recovery operations. In environments supplied as OVAs, the maintenance accounts (notably `systancia`) must be taken into account before any change to the lockout policy.

Integration into the PAM stack, `/etc/pam.d/common-auth`:

```
1
2
3
4
5
6
7
8
```

> **Warning!**
>
> The order of the PAM modules, the jump controls and the modules already present may vary between Debian versions and depending on the packages installed. Keep a privileged session open and test a new local connection, an SSH connection and sudo elevation before closing the session used for the change.

Checking and operation:

```
1
2
3
```

After any change to the PAM configuration, it is recommended to test the opening of a new session, privilege elevation through sudo where used, the behaviour after several failures, the unlocking of an account and access to the maintenance account in line with the applicable support procedures.
