Skip to content

Authenticated command injection in SSH key distribution leads to remote code execution on managed hosts

High
skavanagh published GHSA-mqf3-7x37-c995 Sep 2, 2026

Package

maven io.bastillion:bastillion (Maven)

Affected versions

< 5.2.0

Patched versions

5.2.0

Description

Summary

An authenticated Bastillion user can inject shell metacharacters through SSH key metadata and trigger arbitrary command execution on managed target hosts during key distribution. This is a command injection vulnerability in the key deployment path and can lead to full compromise of managed systems reachable by Bastillion.

Details

The vulnerable flow is:

  1. User-controlled key name (publicKey.keyNm) is accepted from /admin/savePublicKey.ktrl:
  1. keyNm is embedded into generated public-key comment (username@keyname) without shell-safe validation:
  1. That string is concatenated into a remote shell command in SSHUtil.addPubKey():

The command is built as:
echo '<newKeys>' > <authorized_keys_path>; chmod 600 <authorized_keys_path>

Because <newKeys> can contain a single quote (') and shell separators (;), an attacker can break out of the quoted string and execute arbitrary commands.

Default config enables this path:

PoC

Prerequisites:

  • Bastillion running with default key-management settings.
  • Authenticated user with access to /admin/savePublicKey.ktrl and at least one assigned managed host.

Steps:

  1. Log in.
  2. Go to Manage SSH Keys and add a new key.
  3. Set Key Name to:
    demo'; touch /tmp/bastillion_real_proof; #
  4. Submit key creation/saving.
  5. Bastillion distributes keys and executes a command equivalent to:
    echo 'ssh-ed25519 ... alice@demo'; touch /tmp/bastillion_real_proof; #' > .ssh/authorized_keys; chmod 600 .ssh/authorized_keys
  6. On the managed target host, verify:
    ls -l /tmp/bastillion_real_proof

Proof observed in local command-construction harness:

  • Constructed command contained injected ; touch /tmp/bastillion_real_proof;
  • File /tmp/bastillion_real_proof was created successfully.

Impact

This is OS command injection (CWE-78) that allows authenticated users to run arbitrary shell commands on managed remote hosts under the SSH account Bastillion uses for that host. Depending on remote account privileges, this can result in full host compromise, persistence, data theft, or lateral movement.

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
High
User interaction
Required
Scope
Changed
Confidentiality
High
Integrity
High
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:H/I:H/A:H

CVE ID

No known CVE

Weaknesses

Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component. Learn more on MITRE.

Credits