MEDIUM RHCOS (Node) M2: Kernel Hardening (Sysctl) P3

Verified Compare Branch Scanned: 2026-01-14
FAIL on vanilla RHCOS 9.8. Remediation tested and works.

Overview

This remediation applies kernel security hardening via sysctl parameters. These settings improve memory protection and restrict potentially dangerous kernel features.

Note: This group is currently On Hold pending further investigation. PR #528 was closed.

Settings

Setting Value Description
kernel.randomize_va_space 2 Full ASLR - randomizes memory layout
kernel.unprivileged_bpf_disabled 1 Prevent BPF-based privilege escalation
kernel.yama.ptrace_scope 1 Restrict ptrace to parent-child processes
net.core.bpf_jit_harden 2 Harden BPF JIT against spraying attacks

Implementation

The remediation applies a MachineConfig with sysctl settings:

apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
  name: 75-sysctl-medium
  labels:
    machineconfiguration.openshift.io/role: master
spec:
  config:
    ignition:
      version: 3.2.0
    storage:
      files:
        - path: /etc/sysctl.d/75-security-hardening.conf
          mode: 0644
          overwrite: true
          contents:
            inline: |
              # Memory protection
              kernel.randomize_va_space = 2

              # BPF security
              kernel.unprivileged_bpf_disabled = 1
              net.core.bpf_jit_harden = 2

              # Process tracing restriction
              kernel.yama.ptrace_scope = 1

Compliance Checks Remediated

This group addresses 4 compliance checks:

Check Profile Description Docs
rhcos4-e8-worker-sysctl-kernel-randomize-va-space E8 Enable ASLR 📖
rhcos4-e8-worker-sysctl-kernel-unprivileged-bpf-disabled E8 Disable unprivileged BPF 📖
rhcos4-e8-worker-sysctl-kernel-yama-ptrace-scope E8 Restrict ptrace 📖
rhcos4-e8-worker-sysctl-net-core-bpf-jit-harden E8 Harden BPF JIT 📖

Source Remediation Files

  • medium/rhcos4-e8-worker-sysctl-kernel-randomize-va-space.yaml
  • medium/rhcos4-e8-worker-sysctl-kernel-unprivileged-bpf-disabled.yaml
  • medium/rhcos4-e8-worker-sysctl-kernel-yama-ptrace-scope.yaml
  • medium/rhcos4-e8-worker-sysctl-net-core-bpf-jit-harden.yaml

Verification

After applying, verify sysctl settings:

oc debug node/<node-name> -- chroot /host sysctl kernel.randomize_va_space kernel.unprivileged_bpf_disabled
# Expected:
# kernel.randomize_va_space = 2
# kernel.unprivileged_bpf_disabled = 1

Security Impact

  • ASLR (kernel.randomize_va_space=2): Makes memory-based exploits significantly harder
  • BPF restrictions: Prevents unprivileged users from using eBPF for privilege escalation
  • Ptrace scope: Limits debugging capabilities to parent-child process relationships

Upstream Proposal

The following changes could eliminate the need for MachineConfig remediation. Items are categorized by recommended scope:

net.core.bpf_jit_harden=2 All OCP Low
openshift/os /usr/lib/sysctl.d/50-security-hardening.conf View Proposed Change
Prevents BPF JIT spraying attacks. KSPP recommended. Zero workload impact.
Scope: Negligible performance impact. Protects against JIT spraying on all clusters. KSPP recommended.
kernel.yama.ptrace_scope=1 All OCP Med
Fedora/RHEL (elfutils RPM) Override /usr/lib/sysctl.d/10-default-yama-scope.conf View Proposed Change
Kernel default IS 1 but elfutils RPM overrides to 0. RHCOS is a container host, not a dev workstation. Fedora 44 Change Proposal changed ptrace_scope from 1 to 2.
Scope: Kernel default is already 1. Only relaxed by elfutils RPM meant for developer workstations, not container hosts.

PR History

net.core.bpf_jit_harden=2 Closed redirected
Maintainer (@dustymabe) prefers accepting RHEL defaults. Suggested proposing bpf_jit_harden further upstream at the RHEL/Fedora level. Fedora 44 Change Proposal changed bpf_jit_harden from 0 to 2 by default — may flow to RHEL 10. Hold and verify.
kernel.yama.ptrace_scope=1 Closed redirected
Maintainer (@dustymabe) prefers accepting RHEL defaults. Fedora 44 Change Proposal changed ptrace_scope from 1 to 2 and bpf_jit_harden from 0 to 2 by default. These may resolve at the RHEL/Fedora level without needing RHCOS-specific overrides.
Legend
Remediation Status
✅ PASS (vanilla) Passes on unhardened RHCOS; no remediation needed
🟢 Verified Remediation tested on live cluster, confirmed PASS
🔵 In Progress Remediation actively being developed or tested
🟡 Pending Not yet started; needs remediation work
🟠 Partial Some checks pass or remediation not fully validated
⚪ On Hold Work paused (blocked or deprioritized)
Upstream Verdict
🔼 Candidate Suitable for upstreaming to ComplianceAsCode
🟣 PR Open Upstream PR filed
🎯 RAN Only Only applies to RAN deployments
⚙️ Platform Requires OCP platform-level configuration
✅ Pass Already passing upstream
📍 Site Site/deployment-specific configuration
— N/A Not applicable for upstreaming
Platform
RHCOS Node-level checks (MachineConfig)
OCP Platform-level checks (API/CR)
Mixed Both RHCOS and OCP checks
Severity
HIGH
MEDIUM
LOW
MANUAL

Keyboard Shortcuts

Navigation
j / Next row
k / Previous row
Enter Open selected / Expand details
Esc Clear selection / Close modal
Actions
/ Focus search
d Toggle dark mode
? Show this help
g h Go to home
Filters
1 Show all
2 Pending only
3 In Progress only
4 Complete only