Issues traversing a sftp server when files or folders contain the character "]"

Bug #1483751 reported by Shane O'Sullivan
This bug affects 1 person
Affects Status Importance Assigned to Milestone
portable OpenSSH
openssh (Ubuntu)

Bug Description

I am unsure if the bug is with openssh sftp client or within openssh-sftp-server

When traversing an sftp server, I encounter issues for files and, in particular, directories containing the character "]". Tab completion does not escape the character in sftp shell, however, in bash it will escape the character for tab completion. If I "cd" into a directory that contains the character I cannot get any files with in that directory and I have to rename the directory outside of the sftp shell to remove the character in order to be able to correctly get files.


sftp> cd Movie\ \[1080p]/
sftp> ls
sftp> get Movie.1080p.mp4
File "/home/hitsuji/movies/Movie [1080p]/Movie.1080p.mp4" not found.

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: openssh-client 1:6.6p1-2ubuntu2
ProcVersionSignature: Ubuntu 3.16.0-45.60~14.04.1-generic 3.16.7-ckt14
Uname: Linux 3.16.0-45-generic x86_64
ApportVersion: 2.14.1-0ubuntu3.11
Architecture: amd64
CurrentDesktop: Unity
Date: Tue Aug 11 14:36:00 2015
InstallationDate: Installed on 2015-05-01 (101 days ago)
InstallationMedia: Ubuntu 14.04.2 LTS "Trusty Tahr" - Release amd64 (20150218.1)
 ssh-askpass N/A
 libpam-ssh N/A
 keychain N/A
 ssh-askpass-gnome 1:6.6p1-2ubuntu2
SSHClientVersion: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2, OpenSSL 1.0.1f 6 Jan 2014
SourcePackage: openssh
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Shane O'Sullivan (hitsuji) wrote :
description: updated
Revision history for this message
Luke Faraone (lfaraone) wrote :

Can confirm:

sftp> cd Foo\ \[bar\]
sftp> ls
sftp> get hello.txt
File "/home/lfaraone/Foo [bar]/hello.txt" not found.

Changed in openssh (Ubuntu):
importance: Undecided → Low
status: New → Triaged
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. I appreciate the quality of this bug report and I'm sure it'll be helpful to others experiencing the same issue.

This is even slightly worse IMHO as it does stripped mapping.
If on a server you have

$ ll \[a\]/ a
total 8
drwxrwxr-x 2 ubuntu ubuntu 4096 Sep 9 09:51 ./
drwxr-xr-x 9 ubuntu ubuntu 4096 Sep 9 09:51 ../
-rw-rw-r-- 1 ubuntu ubuntu 0 Sep 9 09:51 foo

total 8
drwxrwxr-x 2 ubuntu ubuntu 4096 Sep 9 09:51 ./
drwxr-xr-x 9 ubuntu ubuntu 4096 Sep 9 09:51 ../
-rw-rw-r-- 1 ubuntu ubuntu 0 Sep 9 09:51 foo

And you are in there with sftp and try to get the file from [a] then you will get the "other one".

sftp> pwd
Remote working directory: /home/ubuntu/[a]
sftp> ls
sftp> get foo
Fetching /home/ubuntu/a/foo to foo

Never the less this sounds like an upstream bug/feature-request to me request I'd think.
Well and it sit around without anyone noticing for years :-/
But today is my bug triage duty and I at least want to guide you to the right place :-)

I tried this up to (including) the last version of 8.0p1.
But as much as this seems wrong, this isn't (IMHO) the kind of issue that Ubuntu would develop on its own and keep a delta. After all name/path handling often is security relevant and important for scripts (you'd not want different hosts to behave differently).

The best route to getting it fixed in Ubuntu in this case would be to file an upstream bug if you're able to do that. Otherwise, I'm not sure what we can do directly in Ubuntu to fix the problem.

If you do end up filing an upstream bug, please link to it from here. Thanks!

Revision history for this message
Andreas Hasenack (ahasenack) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.