# Ensure Root User PATH Environment Variable Integrity

- Source: https://support.icompaas.com/support/solutions/articles/62000235391-ensure-root-user-path-environment-variable-integrity
- 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 PATH environment variable for the root user defines directories that the shell searches for executable files. If the PATH contains insecure directories (such as . or writable directories), it can lead to execution of malicious programs with root privileges.

Rationale:  
 Ensuring the root user's PATH environment variable is secure prevents attackers from exploiting insecure path entries to gain unauthorized root access or execute malicious commands.

**Impact:  
** **Pros:**

-   Prevents execution of unauthorized or malicious programs by root.  
    
-   Enhances system security and reduces privilege escalation risks.  
    

**Cons:**

-   Misconfiguration could restrict legitimate command execution if required paths are missing.  
    

Default Value:  
 By default, the root user's PATH may include insecure directories if not properly configured.

Pre-requisites:

-   Root or sudo privileges to audit and modify environment configuration files.  
    

Remediation:

### Test Plan:

Using Linux command line:

1.  Check the root user's PATH value:
    
     echo $PATH (as root)
    
      
    
2.  Verify that the PATH does not include:
    
    -   Current directory (.)  
        
    -   Directories writable by others or not owned by root  
        
3.  Check configuration files such as /root/.bash\_profile, /root/.bashrc, /etc/profile, and /etc/environment for PATH settings.
    

Implementation Plan:

Using Linux command line:

1.  Edit root user's shell initialization files (/root/.bash\_profile, /root/.bashrc) to set a secure PATH. For example:
    
    export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    
2.  Remove any insecure directories from PATH.
    
3.  Verify ownership and permissions of directories in the PATH.
    
4.  Reload the environment or log out and back in.  
      
    

Backout Plan:

Using Linux command line:

1.  Restore previous PATH settings from backups if needed.
    
2.  Communicate changes to system administrators.  
      
    

References:

-   CIS Amazon Linux 2 Benchmark v3.0.0  
    
-   [NIST SP 800-53 Revision 5 - CM-7  
      
    ](https://csrc.nist.gov/publications/detail/sp/800-53/rev-5/final#cm-7)

## 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.
