Skip to content

Security: Command Injection in SSH Storage Backend - #3177

Open
tomaioo wants to merge 1 commit into
kernelci:mainfrom
tomaioo:fix/security/command-injection-in-ssh-storage-backend
Open

Security: Command Injection in SSH Storage Backend#3177
tomaioo wants to merge 1 commit into
kernelci:mainfrom
tomaioo:fix/security/command-injection-in-ssh-storage-backend

Conversation

@tomaioo

@tomaioo tomaioo commented Aug 6, 2026

Copy link
Copy Markdown

Summary

Security: Command Injection in SSH Storage Backend

Problem

Severity: High | File: kernelci/storage/ssh.py:L48

The _upload method in StorageSSH constructs a shell command to create remote directories using f"mkdir -p {dst_dir}". The dst_dir variable is derived from dest_path and file destination names, which are not sanitized. If a malicious path is provided, it can result in arbitrary command execution on the remote SSH server.

Solution

Avoid using exec_command with shell string interpolation for path creation. Use paramiko's SFTP capabilities (e.g., self._scp.sftp_client().mkdir) or properly shell-escape the dst_dir path using shlex.quote().

Changes

  • kernelci/storage/ssh.py (modified)

The `_upload` method in `StorageSSH` constructs a shell command to create remote directories using `f"mkdir -p {dst_dir}"`. The `dst_dir` variable is derived from `dest_path` and file destination names, which are not sanitized. If a malicious path is provided, it can result in arbitrary command execution on the remote SSH server.

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant