Join our Newsletter — 33% off our NHI Course
Home› Glossary› Cyber Security› Command Jacking
Cyber Security

Command Jacking

← Back to Glossary
By NHI Mgmt Group Updated November 18, 2026 Domain: Cyber Security

Command jacking is an attack where a trusted command or command-line argument is altered so a system runs attacker-controlled instructions instead of the intended one. It usually abuses path lookup, insecure quoting, or command substitution in shells and scripts, leading to unauthorised execution.

What Command Jacking Means in Practice

Command jacking is a form of command injection where a trusted command, argument, or command path is altered so the system executes attacker-controlled instructions instead of the intended action. The security issue is not just “bad input”, it is the loss of trust in how shells, scripts, and automation resolve and assemble commands.

This matters because command execution is often highly privileged. If an attacker can influence what gets run, they may pivot from a simple input flaw to arbitrary code execution, data access, or control over adjacent systems. The risk is highest where scripts assume user-supplied values are safe by default.

How Command Jacking Happens

Common failure modes include path lookup abuse, insecure quoting, command substitution, and concatenation of untrusted values into shell commands. A small parsing mistake can change the meaning of an otherwise legitimate command, especially when the application invokes a shell rather than calling a binary directly.

Command jacking also appears when arguments are interpreted as options, filenames, or subcommands without strict delimiting. In these cases, the attacker does not need to replace the whole command, only to alter enough of it that the runtime resolves a different execution path.

  • Path lookup abuse: the wrong executable is found first in the search path.
  • Quoting mistakes: shell metacharacters break out of the intended argument boundary.
  • Substitution abuse: embedded expressions are evaluated instead of treated as literal text.

Why Command Jacking Is Dangerous

Because command jacking turns text handling into code execution, its impact can exceed the original application boundary. An attacker may read or modify files, run additional commands, steal secrets from the environment, or use the compromised process to reach other internal resources.

The issue is especially serious in automation, administrative tooling, and CI/CD-style scripts, where command execution often inherits broad filesystem and network permissions. If the process can reach sensitive material, the command flaw becomes a direct path to broader compromise.

From a defensive perspective, this is one reason secure code review for shell usage needs to be stricter than ordinary input validation. The danger is not only malicious payloads, but also unintended parsing behaviour that silently changes what the system actually executes.

Authoritative references on command execution hardening and adjacent abuse patterns include OWASP API Security Top 10 for authorization and request handling weaknesses, and NIST SP 800-53 Rev 5 Security and Privacy Controls for control families that support secure execution and monitoring. For stronger pipeline and supply-chain integrity, SLSA is also relevant when command handling occurs inside build and release workflows.

Detection and Remediation Patterns

Command jacking is often found through secure review of shell scripts, application code, and automation jobs, followed by runtime testing of suspicious arguments and command boundaries. Reviewers should pay close attention to any place where user-controlled data reaches a shell, a subprocess launcher, or a wrapper script.

Remediation usually means removing shell interpretation where possible, passing arguments as structured parameters, quoting defensively, constraining PATH resolution, and refusing unexpected metacharacters or option-like values. Where the shell is unavoidable, the command boundary should be explicit and narrow.

After suspected exploitation, teams should review process execution logs, recent script changes, and any secrets or credentials available to the affected process. If the command ran with elevated permissions, assume the attacker may have used that access to stage further activity.

For operational hardening guidance, see NIST SP 800-53 Rev 5 Security and Privacy Controls and MITRE ATT&CK Enterprise Matrix, which help teams map post-exploitation behaviour such as command execution and persistence. When command injection affects application interfaces, the OWASP API Security Top 10 is a useful companion for reviewing how requests become execution paths.

Risk and Threat Considerations

Command jacking is risky because it turns ordinary command handling into an execution primitive for attackers. The main concern is not just malformed input, but trusted automation being redirected to run a different command, often with the privileges of the calling process.

Failure mechanism: The attacker abuses shell parsing, path resolution, or argument handling so the intended command is replaced, extended, or interpreted in a dangerous way.

Impact: Successful exploitation can lead to arbitrary command execution, secret exposure, lateral movement, and compromise of systems that rely on scripted administration or automation.

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, OWASP ASVS and CIS Controls v8 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
NIST SP 800-53 Rev 5SI-10 — Information Input ValidationCommand jacking starts with unsafe command inputs or arguments.
AC-6 — Least PrivilegeCommand execution risk is amplified when scripts run with excess privilege.
AU-2 — Event LoggingCommand jacking often requires review of command execution and script activity.
Recommendation — Validate command inputs and reject unexpected characters, separators, and option-like values. Limit command runners to the minimum permissions needed for the task. Log command execution and review anomalies for suspicious arguments or process launches.
OWASP ASVSV15 — Secure Coding and ArchitectureShell invocation and command construction are secure design issues.
Recommendation — Avoid shell interpretation where possible and use structured process invocation instead.
CIS Controls v8CIS-16 — Application Software SecuritySecure application logic should prevent dangerous command execution paths.
Recommendation — Review application code and scripts for unsafe command concatenation and execution.

Practitioner Guidance

What to watch for: Treat any command construction that concatenates strings, invokes a shell unnecessarily, or trusts dynamic paths as a review priority. These are the places where small parsing mistakes become security incidents.

Practitioner takeaway: The safest pattern is to minimise shell use, make argument boundaries explicit, and assume every untrusted value can change command meaning unless the code proves otherwise.

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 18, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org