# Ensure ptrace_scope is Restricted to Enhance Process Security

- Source: https://support.icompaas.com/support/solutions/articles/62000235121-ensure-ptrace-scope-is-restricted-to-enhance-process-security
- Section: [Solutions](https://support.icompaas.com/support/solutions) › [CIS Amazon Linux 2 Benchmark v3.0.0](https://support.icompaas.com/support/solutions/62000112696) › [CIS Amazon Linux 2 Benchmarks](https://support.icompaas.com/support/solutions/folders/62000169265)
- Last updated: 2026-05-29
- Publisher: iCompaas, Inc. (https://www.icompaas.com)

**Profile Applicability:** • Level 1

**Description:**  
The ptrace system call allows one process to observe and control another, which can be exploited to inspect or manipulate processes. The ptrace\_scope kernel parameter controls the restrictions on the ptrace system call. Restricting ptrace\_scope limits this capability to enhance security.

**Rationale:** Setting ptrace\_scope to a restrictive value prevents unauthorized processes from tracing or attaching to other processes, mitigating the risk of privilege escalation or information leakage.

**Impact:  
 Pros:**

-   Reduces the risk of malicious process inspection or manipulation.  
    
-   Enhances overall system security posture.  
    

Cons:

-   May interfere with legitimate debugging or monitoring tools that rely on ptrace.  
    

**Default Value:** On many systems, ptrace\_scope is set to 0 (unrestricted) or 1 (restricted to parent processes), depending on the distribution.

**Pre-requisites:**

-   Root or sudo privileges to read and modify kernel parameters.  
    

**Remediation:**

### **Test Plan:**

**Using Linux command line:**

1.  Check the current value of ptrace\_scope:  
    
    cat /proc/sys/kernel/yama/ptrace\_scope
    
2.  Confirm the value is set to 1 or higher (restricted).
    

3.  Check if the setting persists across reboots:  
    
    grep ptrace\_scope /etc/sysctl.d/\* /etc/sysctl.conf
    

### **Implementation Plan:**

**Using Linux command line:**

1\. Temporarily set ptrace\_scope to 1:  

echo 1 > /proc/sys/kernel/yama/ptrace\_scope

2\. Make the change persistent by adding or updating the following line in /etc/sysctl.d/10-ptrace.conf or /etc/sysctl.conf:  

kernel.yama.ptrace\_scope = 1

3\. Reload sysctl settings:  

sysctl -p /etc/sysctl.d/10-ptrace.conf

### **Backout Plan:**

**Using Linux command line:**

1\. Revert ptrace\_scope to previous value, e.g., 0:  

echo 0 > /proc/sys/kernel/yama/ptrace\_scope

2\. Remove or comment out the ptrace\_scope setting in sysctl configuration files.

3\. Reload sysctl settings.  

**References:**

-   CIS Amazon Linux 2 Benchmark v3.0.0  
    
-   Kernel Yama Documentation  
    
-   Linux man ptrace

## Related compliance guidance

- [SOC 2 compliance: a practical implementation guide for cloud-native SaaS teams](https://support.icompaas.com/compliance/soc-2-trust-services-criteria): Configuration checks like this one are the technical half of a SOC 2 / ISO 27001 programme — the guide shows where they fit, what else an auditor expects, and how to evidence them.
- [ISO/IEC 27001:2022 compliance: a practical implementation guide](https://support.icompaas.com/compliance/iso-27001-2022): ISO 27001 Annex A.8 (technological controls) is where cloud hardening evidence lands; the guide shows how to run the ISMS around it.
