1.5.2 Ensure ptrace_scope is restricted

Information

The ptrace() system call provides a means by which one process (the 'tracer') may observe and control the execution of another process (the 'tracee'), and examine and change the tracee's memory and registers.

Rationale:

If one application is compromised, it would be possible for an attacker to attach to other running processes (e.g. Bash, Firefox, SSH sessions, GPG agent, etc) to extract additional credentials and continue to expand the scope of their attack.

Enabling restricted mode will limit the ability of a compromised process to PTRACE_ATTACH on other processes running under the same user. With restricted mode, ptrace will continue to work with root user.

Solution

Set the following parameter in /etc/sysctl.conf or a file in /etc/sysctl.d/ ending in .conf:

kernel.yama.ptrace_scope = 1

Example:

# printf '
kernel.yama.ptrace_scope = 1
' >> /etc/sysctl.d/60-kernel_sysctl.conf

Run the following command to set the active kernel parameter:

# sysctl -w kernel.yama.ptrace_scope=1

Note: If these settings appear in a conically later file, or later in the same file, these settings will be overwritten

Default Value:

kernel.yama.ptrace_scope=1

See Also

https://workbench.cisecurity.org/benchmarks/13007

Item Details

Category: CONFIGURATION MANAGEMENT

References: 800-53|CM-6, 800-53|CM-7, CSCv7|9.2

Plugin: Unix

Control ID: 6d4cc232b212a8413bb7267b8d9c54a3745239e16aa72aabfb54a9e130d651d3