From: Eli Zaretskii <eliz@gnu.org>
To: taylanbayirli@gmail.com (Taylan Ulrich Bayırlı/Kammer)
Cc: 21702@debbugs.gnu.org
Subject: bug#21702: shell-quote-argument semantics and safety
Date: Mon, 19 Oct 2015 10:47:28 +0300 [thread overview]
Message-ID: <83twpnguzz.fsf@gnu.org> (raw)
In-Reply-To: <87h9lnpb0o.fsf@T420.taylan>
> From: taylanbayirli@gmail.com (Taylan Ulrich Bayırlı/Kammer)
> Cc: 21702@debbugs.gnu.org
> Date: Mon, 19 Oct 2015 09:34:15 +0200
>
> > Item 1 was this:
> >
> >> >> The function should clearly document
> >> >>
> >> >> 1) for which shells will the quoting work absolutely, i.e. lead to
> >> >> the given string to appear *verbatim* in an element of the ARGV of
> >> >> the called command,
> >
> > There's nothing about safety here, only about correctness. That is
> > the aspect that I think is now covered, as the doc string now says for
> > which shells one can have correct results.
>
> Usually it's indeed correctness that protects against injection attacks.
> A quoting mechanism that's correct is automatically safe.
And that is the current situation, AFAIU.
> Another way to make it safe would be to error when the given string
> contains characters outside of a limited character set.
What limited set would you suggest that will not make the function
useless in real-life scenarios?
In any case, I think quoting is better than rejecting, as it supports
more use cases.
> Either way, the safeness should be documented clearly, either implicitly
> through a clear documentation of the correctness, or explicitly.
Like I said, this convention should be adopted project-wide. Doing so
only in a few doc strings, let alone one, will only confuse, because
the user will not know whether the lack of such documentation means
the API is safe or unsafe.
> I would propose something along the lines of:
>
> It is guaranteed that ARGUMENT will be parsed as a single token by
> shells X, Y, and Z, as long as it is separated from other text via a
> delimiter in the syntax of the respective shell.
I don't think we want to mention specific shells explicitly, because
maintaining such a list would be a burden. The standard shell of each
OS is well defined and known to the users of the respective systems.
Moreover, Emacs by default uses that shell automatically.
> >> Does that make sense?
> >
> > Maybe it does, but only if we start documenting these aspects
> > project-wide. It makes little sense to me to do that for a single
> > API, and not an important one at that. But that's me.
>
> This is an API which if its implementation is imperfect will result in
> programs prone to code injection attacks when these programs face
> untrusted input sources. Why do you say it's not an important one?
Because there are many much more important ones that can do much more
harm more easily. In particular, a shell command doesn't need to be
quoted to be harmful or malicious.
next prev parent reply other threads:[~2015-10-19 7:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-18 12:36 bug#21702: shell-quote-argument semantics and safety Taylan Ulrich Bayırlı/Kammer
[not found] ` <handler.21702.B.144517177511995.ack@debbugs.gnu.org>
2015-10-18 15:26 ` Taylan Ulrich Bayırlı/Kammer
2015-10-18 17:16 ` Eli Zaretskii
2015-10-18 19:12 ` Taylan Ulrich Bayırlı/Kammer
2015-10-18 19:48 ` Eli Zaretskii
2015-10-19 7:34 ` Taylan Ulrich Bayırlı/Kammer
2015-10-19 7:47 ` Eli Zaretskii [this message]
2015-10-19 9:22 ` Taylan Ulrich Bayırlı/Kammer
2015-10-19 9:32 ` Eli Zaretskii
2015-10-19 9:50 ` Taylan Ulrich Bayırlı/Kammer
2015-10-19 10:19 ` Eli Zaretskii
2015-10-19 10:25 ` Taylan Ulrich Bayırlı/Kammer
2015-10-22 3:49 ` Paul Eggert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83twpnguzz.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=21702@debbugs.gnu.org \
--cc=taylanbayirli@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).