Operating Systems Azure

Rocky Linux 9 Hardened SSG ANSSI-BP-028 High on Azure User Guide

| Product: Rocky Linux 9 Hardened SSG ANSSI-BP-028 High on Azure

Overview

This guide covers the deployment and verification of Rocky Linux 9 Hardened SSG ANSSI-BP-028 High on Microsoft Azure using cloudimg's pre configured virtual machine image from the Azure Marketplace.

Rocky Linux is a community enterprise operating system produced by the Rocky Enterprise Software Foundation, built to be binary compatible with Red Hat Enterprise Linux 9. This edition applies the SCAP Security Guide profile ANSSI-BP-028 (high) (xccdf_org.ssgproject.content_profile_anssi_bp28_high) at build time with oscap, using the policy content Rocky Linux itself packages (scap-security-guide). The machine is then rebooted and evaluated again, with no remediation, so the score reflects what the machine actually boots into.

This is a hardened image that ships its own evaluation. It is not a certification, an accreditation, or a compliance guarantee. ANSSI-BP-028 is a configuration guide published by ANSSI, the French national cybersecurity agency; anssi_bp28_high is the ComplianceAsCode project's implementation of its high level. cloudimg is not affiliated with or endorsed by ANSSI, and this guide names the profile without reproducing the guide's text. Compliance is a determination about a whole environment, which no machine image can confer. What this image gives you is a measurement you can reproduce.

Measured on the shipped image:

  • XCCDF score: 97.3 against the 388 rules the profile selects, measured after a reboot with no remediation
  • 388 rule results: 330 pass, 34 fail, 23 not applicable, 1 not checked (it needs an online feed)
  • Every one of the 34 failures is explained in Step 4: 9 waivers, each named with its reason, and 25 kernel build configuration checks that cannot pass on a packaged Rocky Linux kernel
  • There is no upstream pass score for this profile. 90.0 is cloudimg's own threshold for shipping this image, and the build fails below it or on any unexplained failure
  • For comparison, the untouched Rocky Linux 9 cloud image scores 58.2 against the same profile

The evaluation ships on the image: the profile, the measured score, the ARF results, the HTML report and the manifest

What's included:

  • Rocky Linux 9 (9.9 at the time of writing) from the Rocky Enterprise Software Foundation's own Azure LVM cloud image, imported only after its SHA-256 checksum and GPG signature were verified
  • Separate LVM filesystems for /home, /tmp, /srv, /var, /var/tmp, /var/log and /var/log/audit, mounted with the options the profile asks for, so its partition rules are measured on real separate filesystems. No swap on the OS disk
  • scap-security-guide, openscap-scanner, audit, aide and dnf-automatic, all from Rocky Linux's own free repositories, with no subscription and no licence key
  • The build time ARF results, HTML report and score at /var/lib/cloudimg/hardened/, and a manifest at /usr/share/cloudimg/hardened/manifest.json recording the datastream, its SHA-256, the profile id, the content and scanner versions, the waivers, the kernel build configuration conflicts, the disk layout and the score
  • A second re evaluation of your VM about three minutes after first boot and weekly after that, audit only, never remediating
  • Every available update applied at build time, with unattended security updates armed through dnf-automatic
  • SELinux enforcing, auditd running with the profile's rules, and an AIDE database
  • Azure Linux Agent (waagent) and cloud-init, proven to still work under the hardening on a freshly provisioned VM
  • Gen2 Hyper-V virtual machine support
  • cloudimg's support team on hand 24 hours a day by email (support@cloudimg.co.uk), with a guaranteed response within 24 hours

Platform: Microsoft Azure (Gen2 Hyper-V) Default user: azureuser

What the profile changes for you

Read this before you deploy. A high level hardening profile changes how the machine behaves, on purpose:

  • Only members of the group sudogrp can run sudo. The account you create in the Azure portal is put in that group automatically. See Step 7 to add another administrator.
  • sudo defaults to noexec for every rule except your administrator account's own grant and root's, so rules you add later cannot start other programs unless you tag them EXEC:.
  • /home, /tmp and /var/tmp are mounted noexec. Run a script there with bash script.sh, not ./script.sh. /tmp and /var/tmp are also private per user.
  • Idle shells log out after 10 minutes (TMOUT=600).
  • Three failed password attempts lock an account for 15 minutes, root included. New passwords need at least 15 characters from all four character classes.
  • Kernel hardening arguments (slub_debug=FZP, page_poison=1, iommu=force, the Spectre and MDS mitigations, mds=full,nosmt and l1tf=full,force) cost some CPU performance, and on a VM size that presents two threads per core they turn off the second thread. Size accordingly.

Step 1: Deploy the Virtual Machine

Option A: Azure Portal

  1. Navigate to the Azure Marketplace and search for "Rocky Linux 9 Hardened SSG ANSSI-BP-028 High cloudimg"
  2. Select the image and click Create
  3. Configure the basics:
  4. Subscription and Resource group: your own
  5. Virtual machine name: your choice
  6. Region: any region you deploy into
  7. Size: Standard_B2s or larger
  8. Authentication type: SSH public key (recommended) or password
  9. Username: azureuser, or a name of your choice
  10. Under Inbound port rules, allow SSH (22) only
  11. On the Disks tab you may choose a larger OS disk than the 32 GiB minimum, then grow a volume as in Step 3
  12. Review and create

Option B: Azure CLI

az group create --name my-rocky-anssi-rg --location eastus

# Accept the Marketplace terms once per subscription (required before the first CLI deploy)
az vm image terms accept --urn cloudimg1647283583153:rocky-9-hardened-anssi-high:default:latest

az vm create \
  --resource-group my-rocky-anssi-rg \
  --name my-rocky-anssi-vm \
  --image cloudimg1647283583153:rocky-9-hardened-anssi-high:default:latest \
  --size Standard_B2s \
  --admin-username azureuser \
  --generate-ssh-keys \
  --public-ip-sku Standard

Connect once the VM is running:

ssh azureuser@<public-ip>

Step 2: Confirm the Image Is What It Claims

Everything below runs as your administrator account on your own VM. Nothing here needs the internet.

Read the manifest first. It is the machine readable record of what was evaluated:

cat /usr/share/cloudimg/hardened/manifest.json

You should see the datastream /usr/share/xml/scap/ssg/content/ssg-rl9-ds.xml and its SHA-256, the profile id xccdf_org.ssgproject.content_profile_anssi_bp28_high, the content package scap-security-guide-0.1.82-2.el9_8.rocky.1.1.noarch, oscap 1.3.14, the nine waivers, the 25 upstream conflicts, the seven separate volumes, the score 97.3 and the time of the evaluation.

Confirm the policy content on your VM is byte for byte the content that was evaluated:

sha256sum /usr/share/xml/scap/ssg/content/ssg-rl9-ds.xml
python3 -c "import json;print(json.load(open('/usr/share/cloudimg/hardened/manifest.json'))['sha256'])"

The two hashes must match:

769e4de0ee8ee67334745f97088043591d97694f3f494d07d9d0fa44fed02a51  /usr/share/xml/scap/ssg/content/ssg-rl9-ds.xml
769e4de0ee8ee67334745f97088043591d97694f3f494d07d9d0fa44fed02a51

Then confirm the content is a valid SCAP datastream and carries the profile:

sudo oscap ds sds-validate /usr/share/xml/scap/ssg/content/ssg-rl9-ds.xml && echo "datastream is valid"
oscap info --profiles /usr/share/xml/scap/ssg/content/ssg-rl9-ds.xml | grep anssi_bp28
datastream is valid
xccdf_org.ssgproject.content_profile_anssi_bp28_enhanced:ANSSI-BP-028 (enhanced)
xccdf_org.ssgproject.content_profile_anssi_bp28_high:ANSSI-BP-028 (high)
xccdf_org.ssgproject.content_profile_anssi_bp28_intermediary:ANSSI-BP-028 (intermediary)
xccdf_org.ssgproject.content_profile_anssi_bp28_minimal:ANSSI-BP-028 (minimal)

Step 3: The Disk Layout

The profile selects partition rules for /home, /srv, /var, /var/tmp, /var/log and /var/log/audit, and mount option rules for each. On this image every one of them is a separate logical volume in the volume group rocky, so those rules pass on real filesystems rather than being waived. /tmp is a separate volume too.

for m in / /home /tmp /srv /var /var/tmp /var/log /var/log/audit /boot /boot/efi; do
  printf '%-15s %-32s %s\n' "$m" "$(findmnt -no SOURCE "$m")" "$(findmnt -no OPTIONS "$m" | grep -oE '(nodev|nosuid|noexec)' | paste -sd, -)"
done
sudo lvs rocky
/               /dev/mapper/rocky-lvroot
/home           /dev/mapper/rocky-home           nosuid,nodev,noexec
/tmp            /dev/mapper/rocky-tmp            nosuid,nodev,noexec
/srv            /dev/mapper/rocky-srv            nosuid,nodev
/var            /dev/mapper/rocky-var            nosuid,nodev
/var/tmp        /dev/mapper/rocky-var_tmp        nosuid,nodev,noexec
/var/log        /dev/mapper/rocky-var_log        nosuid,nodev,noexec
/var/log/audit  /dev/mapper/rocky-var_log_audit  nosuid,nodev,noexec
/boot           /dev/sda3                        nosuid,nodev,noexec
/boot/efi       /dev/sda2                        nosuid,nodev,noexec

/var is deliberately not noexec: Azure VM extensions and cloud-init scripts run from it (see the waivers in Step 4). The device names of /boot and /boot/efi depend on how Azure attaches the disks.

Separate LVM filesystems with their mount options, and no swap on the OS disk

The volumes are sized for a 32 GiB OS disk: / 8.8 GiB, /var 6 GiB, /var/log 4 GiB, /var/log/audit 3 GiB, /home, /tmp and /var/tmp 2 GiB each, /srv 1 GiB, with about 2 GiB left free in the volume group. cloud-init does not grow a logical volume for you. If you deployed with a larger OS disk, or enlarge it later, grow the partition and the physical volume first and then the volume that needs the space (here /var by 10 GiB; -r grows the XFS filesystem too):

PV=$(sudo pvs --noheadings -o pv_name | tr -d ' ')
DISK=/dev/$(lsblk -dno PKNAME "$PV")
PART=$(cat /sys/class/block/$(basename "$PV")/partition)
sudo growpart "$DISK" "$PART" || echo "the partition already fills the disk"
sudo pvresize "$PV"
sudo vgs rocky
sudo lvextend -r -L +10G rocky/var
df -h /var

Step 4: The Exclusions, In Full

Two lists ship on the image in /usr/share/cloudimg/hardened/. They mean different things: a waiver is a choice cloudimg made, an upstream conflict is not a choice at all.

cat /usr/share/cloudimg/hardened/waivers.txt
echo "--- upstream conflicts: $(grep -c . /usr/share/cloudimg/hardened/upstream-conflicts.txt) ---"
cat /usr/share/cloudimg/hardened/upstream-conflicts.txt

waivers.txt: nine rules left unapplied on purpose

Each of these was skipped when the profile was applied, and each shows as failing in the shipped report, so nothing is hidden:

Rule Why it is waived
grub2_password A boot loader password baked into an image would be the same on every VM. Set your own with sudo grub2-setpassword.
sysctl_kernel_modules_disabled After boot the Azure agent loads nf_tables and the resource disk needs ext4; data disks and containers load modules too. Disabling module loading breaks them.
mount_option_var_noexec Azure VM extensions (Run Command, monitoring, backup) and cloud-init custom data scripts run from /var.
sudo_add_requiretty requiretty breaks non interactive sudo over SSH, which scripted administration and configuration management rely on.
sudoers_explicit_command_args Your administrator account's full grant is the only way to administer this image: root cannot log in.
sudoers_no_root_target The same grant must be able to act as root.
rsyslog_remote_loghost Site specific: it needs your own log collector. The profile's own fix writes a placeholder host called logcollector.
rsyslog_remote_tls Site specific: TLS forwarding to your own collector.
rsyslog_remote_tls_cacert Site specific: your own CA certificate for that connection.

SELinux enforcing, the effective SSH settings and the complete waiver list

If your environment has a log collector, configure rsyslog for it and re run the evaluation: those three rules then pass.

upstream-conflicts.txt: 25 kernel build configuration checks

The profile includes 25 kernel_config_* rules that read how the kernel itself was compiled (/boot/config-<version>), for example whether kexec, hibernation or 32 bit emulation were built in. Rocky Linux builds its kernel for a general purpose enterprise distribution, so these cannot pass on a packaged Rocky Linux kernel, and no setting on the running VM changes them. You can see the configuration they read:

grep -E '^CONFIG_(KEXEC|HIBERNATION|IA32_EMULATION|PROC_KCORE)=' /boot/config-$(uname -r)
CONFIG_KEXEC=y
CONFIG_HIBERNATION=y
CONFIG_IA32_EMULATION=y
CONFIG_PROC_KCORE=y

A rule is written into upstream-conflicts.txt only if it is in the fixed candidate list below and was measured failing on this image. Any other failing rule stops the build instead.

cat /usr/share/cloudimg/hardened/upstream-conflict-candidates.txt | wc -l

Step 5: Re-run the Evaluation Yourself

You do not have to take the score on trust. The shipped evidence:

sudo ls -la /var/lib/cloudimg/hardened/
sudo cat /var/lib/cloudimg/hardened/score.txt

arf.xml is the full ARF results file and report.html the rendered report. The directory is readable only by root, so copy the report to your home directory first, then fetch it from your workstation:

sudo cp /var/lib/cloudimg/hardened/report.html ~/anssi-report.html
sudo chown "$(id -un)": ~/anssi-report.html
ls -la ~/anssi-report.html
echo "then, from your workstation: scp azureuser@<public-ip>:anssi-report.html ."

To reproduce the measurement from scratch, run the same evaluation the build ran. It takes three to four minutes on a Standard_B2s:

sudo oscap xccdf eval \
  --profile xccdf_org.ssgproject.content_profile_anssi_bp28_high \
  --results-arf /tmp/anssi-arf.xml \
  --report /tmp/anssi-report.html \
  /usr/share/xml/scap/ssg/content/ssg-rl9-ds.xml > /dev/null ; echo "oscap exit code: $? (0 = every rule passed, 2 = one or more failed)"
sudo grep -oE '<score[^>]*>[^<]*</score>' /tmp/anssi-arf.xml

On the image as shipped this exits 2, because the nine waived rules and the 25 kernel build configuration checks fail, and the score is 97.3. Exit code 1 is a genuine tool error.

What the score does and does not mean

  • It is a measurement produced by the ComplianceAsCode implementation of ANSSI-BP-028 at its high level, applied to this machine.
  • It is not a certification, an accreditation or an assessment by ANSSI or any other body.
  • Many ANSSI-BP-028 recommendations concern how an organisation runs its systems, not how one image is configured. A hardened base image is a starting point for that work, not a substitute for it.
  • 90.0 is cloudimg's own shipping threshold for this image. There is no published pass mark for this profile.

Step 6: Ongoing Verification and Drift Detection

A systemd timer re evaluates your VM about three minutes after first boot and weekly after that. It is audit only and never remediates, so it can never change your running system.

systemctl list-timers hardened-verify.timer --no-pager
sudo ls -la /var/lib/cloudimg/hardened/ | grep verify- || echo "the first scheduled verify has not run yet, it fires about 3 minutes after boot"

Compare verify-score.txt with score.txt to see whether your VM has drifted from the image as shipped. To start a run now without waiting (it runs in the background for three to four minutes):

sudo systemctl start --no-block hardened-verify.service
sudo journalctl -u hardened-verify.service --no-pager | tail -5

hardened-verify.service is a Type=oneshot unit, so inactive (dead) is its normal state once the audit has finished.

Step 7: Administering This Image

sudo

Only members of sudogrp can execute sudo, and sudo runs commands with noexec unless the matching rule is tagged EXEC:. cloud-init gives the account you created both:

stat -c '%a %U:%G %n' /usr/bin/sudo
grep -E '^Defaults[[:space:]]+(noexec|use_pty)' /etc/sudoers
sudo grep -h 'ALL=(ALL)' /etc/sudoers.d/90-cloud-init-users
4110 root:sudogrp /usr/bin/sudo
Defaults noexec
Defaults use_pty
azureuser ALL=(ALL) NOPASSWD:EXEC: ALL

To give another account administrator rights, add it to sudogrp and give it a grant tagged EXEC:, for example:

echo "for a new administrator called alice, run:"
echo "sudo usermod -aG sudogrp alice"
echo "echo 'alice ALL=(ALL) EXEC: ALL' | sudo tee /etc/sudoers.d/50-alice && sudo chmod 0440 /etc/sudoers.d/50-alice && sudo visudo -c"

An account that is not in sudogrp cannot run sudo at all, even with a sudoers rule. This includes accounts created by the Azure portal's Reset password blade, which you then add to the group the same way.

Sessions, logins and temporary files

  • Idle shells close after 10 minutes. Start long jobs with nohup, tmux or a systemd unit.
  • /home, /tmp and /var/tmp are noexec. Run scripts with an interpreter (bash script.sh, python3 script.py) or install them under /usr/local.
  • /tmp and /var/tmp are polyinstantiated: each user sees a private copy.
  • Password logins lock for 15 minutes after three failures, including root. If you deployed with a password, choose it carefully.

Kernel arguments

The profile's kernel hardening arguments are live:

tr ' ' '\n' < /proc/cmdline | grep -E '^(iommu|l1tf|mce|mds|page_alloc.shuffle|pti|rng_core.default_quality|slab_nomerge|spec_store_bypass_disable|spectre_v2|page_poison|slub_debug)='
cat /sys/devices/system/cpu/smt/control
iommu=force
l1tf=full,force
mce=0
mds=full,nosmt
page_alloc.shuffle=1
pti=on
rng_core.default_quality=500
slab_nomerge=yes
spec_store_bypass_disable=seccomp
spectre_v2=on
page_poison=1
slub_debug=FZP
notsupported

notsupported means the VM size presents one thread per core, so nosmt changes nothing; on a size with two threads per core it reads off or forceoff. The arguments are also in GRUB_CMDLINE_LINUX in /etc/default/grub, so they carry over to new kernels.

Step 8: Verify the Rest of the Hardening

SELinux is enforcing now and after a reboot:

getenforce
grep -E '^SELINUX(TYPE)?=' /etc/selinux/config
getsebool deny_execmem

The SSH posture. Root login is refused; password login follows the choice you made when you deployed:

sudo sshd -T | grep -E '^(permitrootlogin|passwordauthentication|pubkeyauthentication|clientaliveinterval) '

clientaliveinterval is 180, which is what Azure's VM image certification asks for.

The only TCP port listening off the machine is SSH. firewalld is not installed; your Azure network security group is the boundary:

ss -ltnH | awk '{print $4}' | grep -vE '^(127\.|\[::1\])' | sort -u
0.0.0.0:22
[::]:22

auditd is running with the profile's rules loaded, and AIDE has its database:

systemctl is-active auditd
sudo auditctl -l | wc -l
sudo ls -la /var/lib/aide/aide.db.gz

The Azure agent, cloud-init, auditd and AIDE healthy under the hardening, with port 22 the only off machine listener

AIDE: checking for file changes

The AIDE database describes the image as captured. To see what has changed on your VM since then (this takes a few minutes):

sudo aide --check 2>&1 | head -40 || true

Expect differences under /etc, /var and /root after first boot: cloud-init writes your SSH key, logs rotate and the machine makes its own host keys. Once the VM is configured the way you want it, re baseline it:

echo "run this once the VM is configured:"
echo "sudo aide --init && sudo mv -f /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz"

Step 9: Patching

Unattended security updates are armed. upgrade_type = security is what the profile sets, and Rocky Linux publishes the security advisories that mode needs:

systemctl is-enabled dnf-automatic.timer
grep -E '^(upgrade_type|apply_updates|download_updates)' /etc/dnf/automatic.conf
enabled
upgrade_type = security
download_updates = yes
apply_updates = yes

To patch everything now:

sudo dnf -y upgrade

If a kernel update lands, reboot, then re run the evaluation from Step 5 so your evidence matches the running kernel. A scap-security-guide update changes the datastream's SHA-256; the scheduled verify then stops and says so, because its results would no longer be comparable with the shipped baseline.

Troubleshooting

sudo: unable to execute or Permission denied running sudo. The account is not in sudogrp. Add it from your administrator account with sudo usermod -aG sudogrp <user> and log in again.

A command under sudo fails with Permission denied when it starts another program. The sudoers rule it matched is not tagged EXEC:. Your provisioned administrator's rule is; rules you add need it too.

./script.sh: Permission denied in your home directory or /tmp. Those filesystems are noexec. Run bash script.sh.

The shell logged me out. TMOUT=600 closes idle shells after 10 minutes.

oscap exits 2. Expected: the waived rules and the kernel build configuration checks fail. Exit 1 is a genuine tool error.

The score I measure differs from score.txt. Expected once you have changed the machine. Use the shipped arf.xml as the baseline and compare.

A volume is full. Grow it as in Step 3; about 2 GiB is free in the volume group on a 32 GiB disk, and more once you enlarge the OS disk.

Support

cloudimg's support team is on hand 24 hours a day by email (support@cloudimg.co.uk), with a guaranteed response within 24 hours: https://www.cloudimg.co.uk/support. Include the output of cat /usr/share/cloudimg/hardened/manifest.json with any query about the hardening, since it identifies exactly which policy content your VM was built and measured against.

Licence

Rocky Linux is assembled from thousands of independently packaged components under their own terms (GPL, LGPL, MIT, BSD, Apache-2.0, MPL and more); each package's terms are readable with rpm -qi <package> and under /usr/share/licenses/. The Rocky Enterprise Software Foundation's own elements are BSD-3-Clause. No paid subscription, licence key or support contract is required.

The SCAP Security Guide content is BSD-3-Clause (the ComplianceAsCode project). The oscap scanner is LGPL-2.1. AIDE and audit are GPL-2.0-or-later. The full notice ships at /usr/share/doc/cloudimg/HARDENED-IMAGE-LICENCE-NOTICE.txt.

"Rocky Linux" is a trademark of the Rocky Enterprise Software Foundation, used here only to identify the operating system this image contains. ANSSI-BP-028 is published by ANSSI; this image names the guide and the SSG profile only. cloudimg claims no affiliation with or endorsement by the Rocky Enterprise Software Foundation, ANSSI, Red Hat or the ComplianceAsCode project.