Skip to content
Misconfiguration Disclosed report Intermediate

Missing enforcement of SFTP quote syntax can lead to operation on wrong object

The SFTP quote command parser in curl ignores extra parameters, so a command intended for a file with a space in its name is executed on a different file. An attacker could cause operations like chmod to affect unintended objects, leading to information disclosure or data loss.

nyymi Follow

Originally disclosed on HackerOne

  • Disclosed after 39 hours

Summary:

curl supports -Q or --quote (and libcurl CURLOPT_QUOTE) to specify "commands" to execute for ftp and SFTP connections. The SFTP supports commands that perform operations on filesystem objects. When the object path has a filename, the caller is supposed to quote the parameter (example: -Q 'chmod 777 "/tmp/example file"'). However, due to libcurl quote command parser ignoring extra parameters, omitting the quotes (or attempting to use shell quoting) will let the command execute and the operation will be attempted on unintended object.

The curl man page mentions that Filenames may be quoted shell-style to embed spaces or special characters.. This statement is misleading, as shells allow many more ways to quote spaces, for example as \ , something that curl does not support. This may lead to app developer assume that shell quoting rules apply. If some software trusts the documentation and generates quote commands assuming the shell quoting applies, this may lead to situation where operations can be performed on untended objects.

No AI was used in research or generation of this report. Stop the AI slop!

Affected version

curl 8.16.0

Steps To Reproduce:

Have curl built --with-libssh2 (or --with-libssh, but I tested --with-libssh2 )

  1. on target server: echo 1 > /tmp/example; echo 2 >/tmp/"example file"
  2. echo > t; curl -Q 'chmod 777 /tmp/example file' -T t sftp://user@server/tmp/t

As a result /tmp/example is modified to have permissions 777, not /tmp/example file as was intended.

Another example:

  1. on target server: echo 1 > /tmp/example\\; echo 2 >/tmp/"example file"
  2. echo > t; curl -Q 'chmod 777 /tmp/example\ file' -T t sftp://user@server/tmp/t

As a result /tmp/example\ is modified to have permissions 777, not /tmp/example file as was intended.

Remediation

  • Adjust the quote parser in lib/vssh/libssh2.c sftp_quote and lib/vssh/libssh.c myssh_in_SFTP_QUOTE to error out if excess parameters are given to command (indicating the caller has mistakenly attempted to give path with space without correct quoting).
  • Fix the documentation to not claim shell-style quoting.

Impact

Summary:

  • Operations performed on wrong object, with associated security impacts (unintended information disclosure, data loss)

The original report as published on HackerOne, by nyymi. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the SFTP quote command parser does not reject extra parameters, so a path with an unquoted space is split and the command acts on the first part only.

Impact

Operations could be performed on the wrong object, potentially causing unintended information disclosure or data loss.

What the attacker needed

Curl built with libssh2 or libssh; ability to send SFTP quote commands; filename contains a space

The fix

The quote parser should be adjusted to error out when excess parameters are given, and the documentation should not claim shell-style quoting.

How it was found

  1. On the target server, create two files: one named 'example' and one named 'example file'.
  2. Run curl with a quote command that attempts to chmod a path containing a space without proper quoting, uploading a dummy file.
  3. Observe that the file 'example' (not 'example file') has its permissions changed.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

curl lets you send commands to an SFTP server, such as changing file permissions. If a filename contains a space, the command parser mistakenly treats the space as separating arguments and applies the command to the wrong file. This could let someone change permissions or delete a file they did not intend to.

What is Misconfiguration?

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.

More by nyymi

View all

51 more disclosed reports, best first.

More from curl

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.