Summary
Termix contains an OS command injection vulnerability in the SSH tunnel disconnection workflow, where user-controlled tunnel host fields are embedded in shell command patterns. An authenticated user who can edit a tunnel may cause arbitrary commands to run on the source SSH host with the privileges of the connected SSH account.
Affected context
The vulnerability occurs in Termix deployments that provide authenticated users with the ability to edit SSH tunnel host fields. During tunnel teardown, values such as the endpoint port, source port, endpoint username, and endpoint IP may be incorporated into a shell command without adequate separation from shell syntax. Risk is present when these values can contain shell metacharacters and the disconnect operation executes the resulting command on the source SSH host.
Exploit preconditions
- Attack surface: Authenticated Termix web interface and SSH tunnel management API
- Required access: An authenticated account permitted to edit an SSH tunnel host field
- Trigger point: SSH tunnel disconnection or teardown
- Execution context: Commands run on the source SSH host under the connected SSH account
- Why exploitation is possible: User-controlled values are interpolated into single-quoted
pkill -fcommand patterns, allowing quote termination and additional shell syntax to be interpreted
Why this happens
The underlying bug is command construction through string interpolation. Values originating from editable tunnel configuration are inserted directly into a shell command rather than being passed as isolated arguments through a non-shell process interface or safely encoded for the intended operation. A crafted single quote can terminate the expected pattern and alter command interpretation, which maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command.
Potential impact
- An attacker could execute arbitrary commands on the source SSH host.
- The connected SSH account's files, credentials, and services may be exposed or modified.
- The attacker could alter tunnel configuration or disrupt managed systems.
- Compromise could enable lateral movement if the SSH account has broader network access.
- Data could be destroyed, tampered with, or exfiltrated.
General mitigation guidance
Mitigation generally focuses on removing shell interpretation from process management operations and reducing trust in tunnel configuration fields.
Common defensive patterns include:
- Invoking process-management functions without an intermediate shell.
- Passing dynamic values as discrete, validated arguments rather than interpolated command strings.
- Applying strict allowlists and type validation to ports, usernames, addresses, and tunnel identifiers.
- Rejecting shell metacharacters and unexpected delimiters where the data format does not require them.
- Running SSH connections with dedicated, least-privilege accounts and narrowly scoped permissions.
- Limiting which users can create or modify tunnels and separating tunnel administration from general platform access.
How teams detect issues like this
Detection approaches may include:
- Static analysis rules for shell execution APIs that receive concatenated or interpolated user input.
- Code review checks for template strings, string formatting, or concatenation used to build process commands.
- Tests that submit quote characters and other shell metacharacters to every tunnel configuration field.
- Runtime monitoring for unexpected child processes launched during SSH tunnel teardown.
- Audit policies requiring non-shell process invocation and allowlisted validation for command arguments.
- Automated security review tools can help identify command construction patterns, but findings should be validated against the actual execution path.

