Summary
Ajenti 2.1.36 contains an authentication bypass flaw that exposes a terminal creation API, enabling attackers to execute arbitrary OS commands after gaining access.
By abusing the /api/terminal/create endpoint, a remote attacker can send a crafted payload, such as a netcat reverse shell, to establish remote command execution on the server.
Affected context
This vulnerability affects deployments of Ajenti 2.1.36 where the web management interface is network-accessible and the terminal functionality is enabled.
The risk is most pronounced when Ajenti is reachable from untrusted networks and when the Ajenti service runs with high privileges (e.g., root), as terminal sessions created via the API may inherit those privileges.
Environments that expose Ajenti directly to the internet without additional access controls or network segmentation are particularly susceptible.
Exploit preconditions
- Attack surface: The Ajenti HTTP(S) management interface, specifically the
/api/terminal/createendpoint. - Required access: Ability to reach the Ajenti API over the network and bypass or satisfy its authentication flow (e.g., using weak/compromised credentials or flaws in auth enforcement).
- Trigger point: Sending a crafted request to the terminal creation API that includes shell commands or a reverse shell invocation.
- Why exploitation is possible: The terminal API effectively exposes an OS command execution primitive without sufficient restriction, validation, or isolation, allowing user-controlled input to be executed by the underlying shell.
Why this happens
The core issue is that Ajenti's terminal creation endpoint provides a direct bridge between user-controlled API parameters and the operating system shell.
Instead of treating terminal sessions as highly sensitive operations that must be tightly constrained, the implementation allows arbitrary commands to be executed with the privileges of the Ajenti process.
This matches CWE-78: Improper Neutralization of Special Elements used in an OS Command, where an application constructs or invokes system-level commands based on untrusted input without robust validation, sandboxing, or policy enforcement.
Potential impact
- Remote execution of arbitrary OS commands on the server hosting Ajenti
- Establishment of reverse shells and persistent remote access
- Reading, modifying, or deleting sensitive files and configuration data
- Pivoting to other systems within the same network environment
- Escalation to full system compromise if Ajenti runs with high privileges
- Disruption of services through process termination or resource exhaustion
General mitigation guidance
Effective mitigation focuses on reducing the exposure of powerful admin APIs and hardening how command execution capabilities are exposed:
- Restrict access to the Ajenti interface to trusted administrative networks and use additional access controls such as VPNs or bastion hosts.
- Treat terminal and command execution features as highly sensitive; disable them when not strictly necessary.
- Apply strong authentication and authorization around any endpoint that can spawn shells or run system commands, ensuring only appropriately privileged users can access them.
- Constrain command execution paths using allowlists, non-interactive command wrappers, or restricted shells that prevent arbitrary argument injection.
- Run Ajenti and related services with least-privilege OS accounts and limit their ability to access critical files or system utilities.
- Use network egress controls to prevent unapproved outbound connections, which can limit the practicality of reverse shells.
How teams detect issues like this
Organizations can approach detection of this class of vulnerability and its exploitation through:
- Static analysis and code review:
- Flagging code that directly spawns shells or terminals from web/API endpoints.
- Identifying uses of command execution primitives (e.g.,
subprocess,exec,system) that accept user-derived input without strict constraints. - Reviewing API definitions for endpoints that create terminals, shells, or interactive sessions and ensuring strong authorization checks.
- Runtime monitoring and logging:
- Recording and reviewing access to
/api/terminal/createand similar endpoints, including source IPs, user identities, and parameters. - Monitoring for unusual outbound connections (e.g., netcat to arbitrary IP/ports) that may indicate reverse shell activity.
- Using host-based intrusion detection to alert on suspicious process trees spawned by the Ajenti service.
- Policy and configuration checks:
- Periodic audits that verify terminal/command execution features are disabled or locked down when not needed.
- Automated compliance checks that ensure the management interface is not exposed directly to the internet without compensating controls.
- Automated security scanners and code review tools can help flag high-risk command execution patterns early in the development lifecycle.

