From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Francesco =?UTF-8?Q?Potort=C3=AC?= Newsgroups: gmane.emacs.bugs Subject: bug#59817: [PATCH] Fix etags local command injection vulnerability Date: Tue, 06 Dec 2022 16:05:59 +0100 Organization: The GNU project Message-ID: <87r0xctvvs.fsf@tucano.isti.cnr.it> References: <83r0xf9qsx.fsf@gnu.org> <834jua9ggd.fsf@gnu.org> <83lenk7kuq.fsf@gnu.org> <83bkog7fev.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22445"; mail-complaints-to="usenet@ciao.gmane.io" Cc: lux , 59817@debbugs.gnu.org, stefankangas@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 06 16:07:22 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p2ZXU-0005Yc-UO for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 06 Dec 2022 16:07:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p2ZXE-00046M-LF; Tue, 06 Dec 2022 10:07:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p2ZXC-000464-QW for bug-gnu-emacs@gnu.org; Tue, 06 Dec 2022 10:07:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p2ZXC-00067n-IV for bug-gnu-emacs@gnu.org; Tue, 06 Dec 2022 10:07:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p2ZXB-0004mw-VV for bug-gnu-emacs@gnu.org; Tue, 06 Dec 2022 10:07:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Francesco =?UTF-8?Q?Potort=C3=AC?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 06 Dec 2022 15:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59817 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 59817-submit@debbugs.gnu.org id=B59817.167033916418387 (code B ref 59817); Tue, 06 Dec 2022 15:07:01 +0000 Original-Received: (at 59817) by debbugs.gnu.org; 6 Dec 2022 15:06:04 +0000 Original-Received: from localhost ([127.0.0.1]:43449 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2ZWG-0004mV-Lt for submit@debbugs.gnu.org; Tue, 06 Dec 2022 10:06:04 -0500 Original-Received: from relay3.ehiweb.it ([79.98.45.20]:39149 helo=plesklin7.if1.ehiweb.it) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2ZWD-0004m8-Rb for 59817@debbugs.gnu.org; Tue, 06 Dec 2022 10:06:02 -0500 Original-Received: from tucano.isti.cnr.it (tucano.isti.cnr.it [146.48.81.102]) by plesklin7.if1.ehiweb.it (Postfix) with ESMTPSA id D135810842A; Tue, 6 Dec 2022 16:05:59 +0100 (CET) In-Reply-To: <83bkog7fev.fsf@gnu.org> (eliz@gnu.org) X-fingerprint: 4B02 6187 5C03 D6B1 2E31 7666 09DF 2DC9 BE21 6115 X-PPP-Message-ID: <20221206150559.25596.15791@plesklin7.if1.ehiweb.it> X-PPP-Vhost: potorti.it X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:250117 Archived-At: >I don't understand why you need an extra pair of quotes in the expanded >string. > > $ echo \''hello; world' > 'hello; world > >As you see, the semi-colon was successfully hidden from the shell. > >What am I missing? That only works at the beginning or end of a string. In general, inside a single-quoted string, single quotes are not allowed. So, to include a single quote inside a single-quoted string, you have to: - close the quoted string using ' - put a literal single quote usign \' - reopen the quoted string using ' If you want to avoid checking for the special cases of a stray single string at beginning or end of the original string, you just quote everything qith a single quote at beginning and end, and then substitute each ' with '\''.