Join our Newsletter — 33% off our NHI Course
Architecture & Implementation

PATH

← Back to Glossary
By NHI Mgmt Group Updated November 25, 2026 Domain: Architecture & Implementation

PATH is an environment variable that tells a shell where to look for executable programs when you type a command. It is searched in order from left to right, so the first matching binary or script is the one run, which can affect command resolution and introduce risk if untrusted directories appear first.

What PATH Means in Shell Command Resolution

PATH is not a command itself, it is the lookup path your shell uses to find executables in directories listed from left to right. That order matters because the first matching program wins, so PATH controls which binary or script runs when names collide or when a malicious directory is placed early.

A PATH value is usually inherited by shells, scripts, services, and interactive sessions, which makes it a convenience feature and a security boundary at the same time. If the environment is altered unexpectedly, command resolution can drift from the administrator’s intent without changing the command the user typed.

How PATH Affects Command Discovery

When you enter a command without a full filesystem path, the shell searches each PATH entry until it finds an executable file with that name. This means PATH does not change what a program is, but it does change which copy of that program is selected when multiple versions exist.

That behaviour is especially important in systems where local directories, temporary directories, or user-controlled locations appear before trusted system locations. A seemingly harmless command can resolve to a different tool than expected if the search order is manipulated.

Why PATH Order Creates Security Exposure

The security issue is usually not the environment variable itself, but trust in the directories listed within it. If an attacker can write to an earlier directory, they may be able to replace or shadow a legitimate executable and influence what the shell launches.

PATH confusion also creates operational risk in scripts and automation, because a build job or administrative script may work in one context and call the wrong program in another. That makes PATH a common source of brittle behaviour, unexpected privilege boundaries, and hard-to-trace command spoofing.

PATH in System, User, and Automation Contexts

PATH should be understood as a context-sensitive setting, not a universal constant. A safe PATH for an interactive developer shell may be too permissive for a privileged service account, and a minimal PATH for automation may fail if scripts assume user-specific directories are present.

Well-run environments often treat PATH as part of execution hygiene, keeping trusted system directories ahead of writable locations and avoiding unnecessary entries. The same principle applies whether the command is launched manually, by a scheduled task, or by a service wrapper.

Risk and Threat Considerations

PATH can be abused when an untrusted directory appears before a trusted one, allowing command shadowing, unexpected binary execution, or privilege-sensitive misuse of a familiar command name. The risk is highest when scripts, sudo contexts, or automation trust PATH without constraining where executables may come from.

Failure mechanism: The shell resolves a short command name to the first matching executable in PATH, so an attacker who can influence the directory list or place a lookalike binary earlier can redirect execution without changing the command text.

Impact: This can cause arbitrary command execution, credential exposure, integrity loss in administrative workflows, or persistence through poisoned scripts and login environments.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

NIST SP 800-53 Rev 5 and CIS Controls v8 set the technical controls, while ISO/IEC 27001:2022 defines the regulatory obligations.

FrameworkControl / ReferenceRelevance
NIST SP 800-53 Rev 5CM-7 — Least FunctionalityPATH shadowing is reduced by limiting executable search locations.
AC-6 — Least PrivilegePrivileged shells should not resolve commands through attacker-influenced locations.
Recommendation — Restrict PATH entries to trusted directories and remove unnecessary execution paths. Use least-privilege execution contexts and avoid writable PATH entries for privileged processes.
CIS Controls v8CIS-4 — Secure Configuration of Enterprise Assets and SoftwareSafe PATH configuration is part of hardened host and software settings.
CIS-5 — Account ManagementUser and service account environments can carry unsafe PATH settings.
Recommendation — Harden shell and service PATH settings to trusted directories only. Review account environments so PATH values do not inherit unsafe directories.
ISO/IEC 27001:2022A.8.9 — Configuration managementPATH is a configuration item that affects executable resolution and system integrity.
Recommendation — Control and review PATH-related configuration changes in managed environments.

Practitioner Guidance

Why practitioners should care: Treat PATH as an execution-control setting, not just a convenience variable. A clean, predictable search order reduces the chance that automation, admin tasks, or privileged sessions invoke the wrong program.

What to watch for: Review environments where writable directories, temporary paths, or application-local folders appear before trusted system locations, especially in scripts that run with elevated privileges or non-interactive service accounts.

Practitioner takeaway: When command resolution matters, prefer explicit full paths for sensitive operations and keep PATH narrow, stable, and intentional.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on November 25, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org