The vulnerability exists in the apache-airflow-providers-sftp package, specifically within the SFTPHook class. The functions retrieve_directory and retrieve_directory_concurrently are used to download a directory from a remote SFTP server to a local path. The vulnerability arises because these functions construct the destination path for files and directories by using os.path.join with a path component (os.path.relpath(dir_path, remote_full_path)) that is derived from directory entries sent by the remote SFTP server. A malicious or compromised SFTP server can provide directory or file names containing '..' (dot-dot) path traversal sequences. The vulnerable code directly uses these crafted names to build the local path, causing files to be written outside the intended local destination directory. The patch introduces a new helper function, _validate_within_directory, which resolves the real paths of the base directory and the candidate write path, ensuring the candidate path is contained within the base directory before any write operation occurs. This validation is applied in both retrieve_directory and retrieve_directory_concurrently to fix the path traversal vulnerability.