A restricted shell is a command-line environment that limits what a user can do, usually by blocking actions such as changing directories, starting new shells, or exporting environment variables. It is commonly used in build and CI/CD contexts to reduce what an attacker can do if access is abused.
Expanded Definition
A restricted shell is a constrained command-line environment designed to limit what a user can execute, where they can navigate, and which session behaviors they can change. In NHI and CI/CD contexts, it is typically used to reduce blast radius when a service account, deployment operator, or automation identity reaches an interactive endpoint.
Restricted shells are not the same as full privilege separation, and they do not replace NIST Cybersecurity Framework 2.0 access governance or Zero Trust controls. Their value is narrow but practical: they limit command surface, block shell escapes, and constrain session manipulation. Definitions vary across vendors and platforms, because some products describe a hardened shell, while others enforce restrictions through command wrappers, forced commands, or session policies.
The most common misapplication is treating a restricted shell as a complete security boundary, which occurs when organisations assume command limits alone can contain an identity that still has broad file, network, or tool access.
Examples and Use Cases
Implementing restricted shells rigorously often introduces workflow friction, requiring organisations to weigh operator convenience against reduced lateral movement and tighter auditability.
- A CI/CD runner is given a shell that only permits build and deployment commands, preventing ad hoc file edits or interactive debugging during production jobs.
- An emergency support account is placed in a restricted shell so it can inspect logs and restart services, but cannot spawn a new shell or change directories into sensitive paths.
- A privileged automation identity uses a forced command wrapper that invokes one approved script, aligning execution with the principle described in the Ultimate Guide to NHIs rather than granting open-ended interactive access.
- A third-party maintainer receives time-bound access to a bastion host, but the shell blocks environment variable exports and command chaining to reduce the chance of secret extraction.
- Security teams pair a restricted shell with audit logging so they can prove which commands were attempted, especially when the session belongs to a service account used in sensitive release pipelines.
In practice, restricted shells are strongest when combined with identity scoping, command allowlists, and session monitoring rather than used as a standalone control.
Why It Matters in NHI Security
Restricted shells matter because many NHI compromises begin with a credential that was never intended to be used interactively. If an API key, deployment account, or service identity lands in a terminal session, the shell becomes the last practical barrier before secrets exposure, environment tampering, or pipeline manipulation. That is why shell constraints are relevant to governance, not just operations. NHIMG research shows that 96% of organisations store secrets outside secrets managers in vulnerable locations such as code, config files, and CI/CD tools, which increases the odds that an attacker can pivot from one compromised identity to another.
The same NHIMG guide also notes that 97% of NHIs carry excessive privileges, a condition that makes unrestricted shells especially dangerous when access is abused. This is where restricted shells support Zero Trust by limiting what a session can do even after authentication succeeds, complementing controls in NIST Cybersecurity Framework 2.0. Organisations typically encounter the real need for restricted shells only after a service account is misused during an incident, at which point session containment becomes operationally unavoidable to address.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Non-Human Identity Top 10 and CSA MAESTRO address the attack and risk surface, while NIST CSF 2.0, NIST Zero Trust (SP 800-207) and NIST SP 800-63 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identity Top 10 | NHI-02 | Restricted shells reduce abuse paths for overprivileged non-human identities. |
| NIST CSF 2.0 | PR.AA-01 | Authentication should not imply unrestricted session capability for privileged access. |
| NIST Zero Trust (SP 800-207) | SC-3 | Zero Trust expects continuous limitation of what an authenticated session can reach. |
| NIST SP 800-63 | AAL2 | Assurance levels cover authentication strength, not interactive command authority. |
| CSA MAESTRO | Agentic workflows need constrained execution surfaces to limit autonomous misuse. |
Pair access approval with session limits so valid identities cannot exceed intended actions.