Console Login

Automating Compliance: Why Manual Audits Are a Liability (And How to Fix It with OpenSCAP)

Automating Compliance: Why Manual Audits Are a Liability (And How to Fix It with OpenSCAP)

It is July 2023. The European Commission just adopted the new EU-U.S. Data Privacy Framework on the 10th. Everyone in the boardroom is breathing a sigh of relief, thinking the Schrems II nightmare is over. As a systems architect, I’m telling you: don't get comfortable.

Legal frameworks change. Physics and data sovereignty do not. If your servers are sitting in a massive, opaque public cloud region where you can't guarantee the physical disk location, a piece of paper signed in Brussels won't save you when Datatilsynet (The Norwegian Data Protection Authority) comes knocking for an audit. Worse, manual compliance—checking boxes on a spreadsheet once a year—is a technical debt trap that explodes exactly when you don't have time to fix it.

We need to stop treating compliance as a legal problem and start treating it as an engineering problem. We need Compliance as Code.

The "Trust, but Verify" Architecture

I've managed infrastructure for fintech startups in Oslo where a single unpatched kernel vulnerability meant losing our license. The mistake most teams make is relying on "security through obscurity" or hoping their cloud provider handles the OS layer. They don't. AWS and Azure operate on a shared responsibility model. They secure the concrete; you secure the kernel.

If you are running mission-critical workloads, you need complete control over the virtualization stack. This is why we use KVM at CoolVDS. Unlike OpenVZ or LXC, where kernel exploits can leak across containers, KVM provides hardware-level isolation. But even a KVM instance needs hardening.

The Toolchain: OpenSCAP

Forget proprietary, expensive compliance scanners that upload your data to a third-party cloud. The industry standard is OpenSCAP. It validates your system against the Security Content Automation Protocol (SCAP) standards, including CIS Benchmarks and PCI-DSS.

Let's get our hands dirty. Assuming you are running a fresh Ubuntu 22.04 LTS instance on CoolVDS, here is how we install the necessary tools.

sudo apt-get update
sudo apt-get install libopenscap8 scap-security-guide openscap-utils

Once installed, you don't just "run a scan." You need to select the right profile. For a standard web server handling European traffic, the ANSSI (French National Cybersecurity Agency) or CIS profiles are solid baselines.

To see available profiles:

oscap info /usr/share/xml/scap/ssg/content/ssg-ubuntu2204-ds.xml

Step 1: The Audit (Finding the Holes)

We will run a scan against the CIS Level 2 Server benchmark. This is a rigorous standard. It will break things if you apply it blindly, which is why we audit first.

oscap xccdf eval \
  --profile xccdf_org.ssgproject.content_profile_cis_level2_server \
  --results scan-results.xml \
  --report report.html \
  /usr/share/xml/scap/ssg/content/ssg-ubuntu2204-ds.xml

This command generates an HTML report. When you open it, you will likely see a sea of red fail messages. Do not panic. This is normal for a default Linux installation.

Pro Tip: Never run a remediation script on a production server without testing it in a staging environment first. CIS Level 2 disables kernel modules (like USB storage) that might be critical for legacy backup systems.

Step 2: Automated Remediation with Ansible

Here is where the "DevOps" part kicks in. Don't fix these issues manually. If you edit /etc/ssh/sshd_config by hand, the next update or junior admin will overwrite it. We use Ansible to enforce the state.

OpenSCAP can actually generate an Ansible playbook based on your scan results, but I prefer writing custom playbooks to maintain control. Below is a robust playbook structure targeting common failures regarding SSH hardening and sysctl parameters.

file: hardening.yml

---
- name: Hardening CoolVDS Instance for GDPR Compliance
  hosts: all
  become: yes
  vars:
    ssh_port: 22

  tasks:
    - name: Ensure SSH Protocol is set to 2
      lineinfile:
        path: /etc/ssh/sshd_config
        regexp: '^Protocol'
        line: 'Protocol 2'
        state: present
        validate: '/usr/sbin/sshd -t -f %s'

    - name: Disable Root Login
      lineinfile:
        path: /etc/ssh/sshd_config
        regexp: '^PermitRootLogin'
        line: 'PermitRootLogin no'
        state: present
      notify: Restart SSH

    - name: Set idle timeout interval
      lineinfile:
        path: /etc/ssh/sshd_config
        regexp: '^ClientAliveInterval'
        line: 'ClientAliveInterval 300'
        state: present

    - name: Set keep alive count max
      lineinfile:
        path: /etc/ssh/sshd_config
        regexp: '^ClientAliveCountMax'
        line: 'ClientAliveCountMax 0'
        state: present

    - name: Secure sysctl network parameters (ICMP redirects)
      sysctl:
        name: net.ipv4.conf.all.accept_redirects
        value: '0'
        state: present
        reload: yes

  handlers:
    - name: Restart SSH
      service:
        name: sshd
        state: restarted

Run this against your fleet:

ansible-playbook -i inventory.ini hardening.yml

Step 3: Continuous Monitoring (The Audit Trail)

Compliance is not a destination; it is a state of being. You need to prove to auditors that you are watching the logs. For this, auditd is the kernel-level subsystem of choice.

Default audit rules are often too quiet. We need to track changes to the system time, user/group files, and discretionary access controls. Here is a high-performance configuration that balances visibility with I/O load—crucial when you aren't on NVMe storage (though with CoolVDS, you always are).

file: /etc/audit/rules.d/audit.rules

## First rule - delete all
-D

## Increase the buffers to survive stress events.
## Make this larger for busy systems
-b 8192

## Set failure mode to syslog
-f 1

## Monitor changes to time
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -k time-change
-a always,exit -F arch=b64 -S clock_settime -k time-change
-w /etc/localtime -p wa -k time-change

## Monitor changes to user/group information
-w /etc/group -p wa -k identity
-w /etc/passwd -p wa -k identity
-w /etc/gshadow -p wa -k identity
-w /etc/shadow -p wa -k identity

## Monitor network environment changes
-a always,exit -F arch=b64 -S sethostname -S setdomainname -k system-locale
-w /etc/issue -p wa -k system-locale
-w /etc/issue.net -p wa -k system-locale
-w /etc/hosts -p wa -k system-locale
-w /etc/network -p wa -k system-locale

## Make the configuration immutable
-e 2

Reload the rules immediately:

augenrules --load

To verify that your rules are catching file changes, you can generate a test event and search for it:

touch /etc/hosts
ausearch -k system-locale | tail -n 5

The Infrastructure Factor: Why Latency and Location Matter

You can script security all day, but if your host is physically insecure or routing traffic through high-risk nations, your compliance is void. This is where the "Nordic Advantage" comes into play.

Feature Public Hyperscaler CoolVDS (Norway)
Data Sovereignty Vague (Replication zones) Guaranteed (Oslo/Europe)
Storage I/O Throttled / Shared Dedicated NVMe
DDOS Protection Expensive Add-on Integrated Standard
Virtualization Shared Kernel (often) Full KVM Isolation

Latency is a Security Feature

It sounds counter-intuitive, but low latency aids security. Real-time intrusion detection systems (IDS) need to analyze packets and make blocking decisions in microseconds. If you are serving Norwegian customers but your server is in Frankfurt, you are adding 15-20ms of round-trip time (RTT). Hosting locally in Oslo cuts this to ~2ms via NIX (Norwegian Internet Exchange).

CoolVDS infrastructure connects directly to major Nordic peering points. This doesn't just make your website load faster; it allows your WAF (Web Application Firewall) to react faster to automated botnets.

Automating the Reporting Cycle

Finally, let's automate the paperwork. You don't want to run these scans manually every month. Let's create a cron job that runs the scan and emails the report to the CISO if the score drops below a certain threshold.

file: /usr/local/bin/compliance-check.sh

#!/bin/bash

PROFILE="xccdf_org.ssgproject.content_profile_cis_level2_server"
SCAP_FILE="/usr/share/xml/scap/ssg/content/ssg-ubuntu2204-ds.xml"
REPORT_DIR="/var/www/html/compliance"
DATE=$(date +%F)

mkdir -p $REPORT_DIR

# Run the scan
oscap xccdf eval \
  --profile $PROFILE \
  --results $REPORT_DIR/results-$DATE.xml \
  --report $REPORT_DIR/report-$DATE.html \
  $SCAP_FILE

# Extract Score
SCORE=$(grep -oP 'score system="urn:xccdf:scoring:default"\>\K[0-9.]+' $REPORT_DIR/results-$DATE.xml)

# Alert if score is below 90
if (( $(echo "$SCORE < 90" | bc -l) )); then
  echo "CRITICAL: Compliance score dropped to $SCORE on $(hostname)" | mail -s "Compliance Alert" security@yourdomain.com
fi

Make it executable and add it to crontab:

chmod +x /usr/local/bin/compliance-check.sh
# Run every Monday at 3 AM
0 3 * * 1 /usr/local/bin/compliance-check.sh

Conclusion

Compliance isn't about avoiding fines; it's about operational excellence. A system that is compliant with CIS benchmarks is leaner, faster, and more predictable. It has fewer open ports, fewer running services, and less noise in the logs.

However, software hardening cannot fix hardware latency or legal jurisdiction issues. For that, you need a partner that understands the local landscape. Don't let slow I/O or data sovereignty risks kill your project.

Ready to build a fortress? Deploy a hardened, high-performance instance on CoolVDS today and experience the stability of true KVM virtualization on NVMe.