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:
- User-controlled key name (
publicKey.keyNm) is accepted from /admin/savePublicKey.ktrl:
keyNm is embedded into generated public-key comment (username@keyname) without shell-safe validation:
- 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:
- Log in.
- Go to Manage SSH Keys and add a new key.
- Set Key Name to:
demo'; touch /tmp/bastillion_real_proof; #
- Submit key creation/saving.
- 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
- 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.
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:
publicKey.keyNm) is accepted from/admin/savePublicKey.ktrl:keyNmis embedded into generated public-key comment (username@keyname) without shell-safe validation:AuthKeysKtrl.java#L262)
AuthKeysKtrl.java#L327)
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:
keyManagementEnabled=trueforceUserKeyGeneration=truePoC
Prerequisites:
/admin/savePublicKey.ktrland at least one assigned managed host.Steps:
demo'; touch /tmp/bastillion_real_proof; #echo 'ssh-ed25519 ... alice@demo'; touch /tmp/bastillion_real_proof; #' > .ssh/authorized_keys; chmod 600 .ssh/authorized_keysls -l /tmp/bastillion_real_proofProof observed in local command-construction harness:
; touch /tmp/bastillion_real_proof;/tmp/bastillion_real_proofwas 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.