Disallow magic SysRq key
An XCCDF Rule
Description
To set the runtime status of thekernel.sysrq
kernel parameter, run the following command: $ sudo sysctl -w kernel.sysrq=0To make sure that the setting is persistent, add the following line to a file in the directory
/etc/sysctl.d
: kernel.sysrq = 0
Rationale
The Magic SysRq key allows sending certain commands directly to the running kernel. It can dump various system and process information, potentially revealing sensitive information. It can also reboot or shutdown the machine, disturbing its availability.
- ID
- xccdf_org.ssgproject.content_rule_sysctl_kernel_sysrq
- Severity
- Medium
- References
- Updated
Remediation Templates
An Ansible Snippet
- name: Gather the package facts
package_facts:
manager: auto
tags:
- disable_strategy
- low_complexity
A Shell Script
# Remediation is applicable only in certain platforms
if rpm --quiet -q kernel; then
# Comment out any occurrences of kernel.sysrq from /etc/sysctl.d/*.conf files
for f in /etc/sysctl.d/*.conf /run/sysctl.d/*.conf /usr/local/lib/sysctl.d/*.conf /usr/lib/sysctl.d/*.conf; do