Skip to content

DeepSec: SFTP ls path is interpolated into a remote shell command #1573

@chaliy

Description

@chaliy

Source: DeepSec Rust-focused direct pass 20260507013924-5f4812745ba339b2.

Severity: HIGH
Confidence: high
File: crates/bashkit/src/builtins/ssh/cmd.rs:520
Slug: rce

Finding

The SFTP command parser treats the attacker-controlled ls argument as a path, then builds a remote command with format!("ls -la {}", path) and sends it to ssh_client.exec.

Unlike SCP/SFTP put / get paths, this path is not shell-escaped. A path containing shell metacharacters such as command separators or command substitution will be interpreted by the remote shell, bypassing the SFTP command subset and executing arbitrary commands on the allowlisted SSH target with the configured credentials.

Suggested Fix

Shell-escape the ls path before interpolation, or add a dedicated list operation to SshHandler that does not go through a shell command string.

Add a regression test that verifies generated SFTP ls commands quote paths with metacharacters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    rustPull requests that update rust codesecuritySecurity vulnerability or hardeningseverity/highHigh severity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions