From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#59817: [PATCH] Fix etags local command injection vulnerability Date: Tue, 06 Dec 2022 14:55:09 +0200 Message-ID: <83lenk7kuq.fsf@gnu.org> References: <83r0xf9qsx.fsf@gnu.org> <834jua9ggd.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9947"; mail-complaints-to="usenet@ciao.gmane.io" Cc: stefankangas@gmail.com, 59817@debbugs.gnu.org To: lux Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 06 13:56:12 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 1p2XUZ-0002In-91 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 06 Dec 2022 13:56:11 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p2XUS-0007ML-8o; Tue, 06 Dec 2022 07:56: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 1p2XUQ-0007M3-BJ for bug-gnu-emacs@gnu.org; Tue, 06 Dec 2022 07:56: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 1p2XUQ-0006JK-3X for bug-gnu-emacs@gnu.org; Tue, 06 Dec 2022 07:56:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p2XUP-0001GZ-JV for bug-gnu-emacs@gnu.org; Tue, 06 Dec 2022 07:56:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 06 Dec 2022 12:56: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.16703313314860 (code B ref 59817); Tue, 06 Dec 2022 12:56:01 +0000 Original-Received: (at 59817) by debbugs.gnu.org; 6 Dec 2022 12:55:31 +0000 Original-Received: from localhost ([127.0.0.1]:42839 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2XTv-0001GK-Ee for submit@debbugs.gnu.org; Tue, 06 Dec 2022 07:55:31 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:55398) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2XTu-0001GE-Ij for 59817@debbugs.gnu.org; Tue, 06 Dec 2022 07:55:30 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p2XTp-00069I-Bi; Tue, 06 Dec 2022 07:55:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=4eOcloXATyA7nuhzu7hZiYPA95R315xteVO8TVaDwqI=; b=F+N9CdRV0oqh KOp0zrFRs349aUFgnbAY1ihv6XpbZ/Az86iK3EjEeLyfZ2lX6+qVl7PeXe2jTnw2dy7qdG+HDxJNx NMqmsYDHX/y+sBXJnslC6P5uRZpoGB49hxhscBuscEmx9JmGvPY1H/YYQzss+bIakEmR/mRR73H77 kqoqHLY7Fju4nKPKXJ7gBAow3/hjGCmYfnWvQQAQnSdP21bAJHb5GpfrfgFynglgSyMjxHhl09x9G sZDHHta/VfHunIZ/07Fw3FPPC4tvyOPQ5a4but1pJxMwxZ4plXDTzawzTJMBqvFWw7OGeXejdSGj4 qy1iwt50oChkMXNjc/8kbQ==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p2XTo-00029R-Pg; Tue, 06 Dec 2022 07:55:25 -0500 In-Reply-To: (message from lux on Tue, 6 Dec 2022 15:48:10 +0800) 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:250105 Archived-At: > Date: Tue, 6 Dec 2022 15:48:10 +0800 > From: lux > Cc: Stefan Kangas , 59817@debbugs.gnu.org > > @@ -1716,8 +1717,12 @@ process_file_name (char *file, language *lang) > char *cmd1 = concat (compr->command, " \"", real_name); > char *cmd = concat (cmd1, "\" > ", tmp_name); > #else > - char *cmd1 = concat (compr->command, " '", real_name); > - char *cmd = concat (cmd1, "' > ", tmp_name); > + char *new_real_name = escape_shell_arg_string (real_name); > + char *new_tmp_name = escape_shell_arg_string (tmp_name); > + char *cmd1 = concat (compr->command, " ", new_real_name); > + char *cmd = concat (cmd1, " > ", new_tmp_name); > + free (new_real_name); > + free (new_tmp_name); > #endif The "MSDOS || DOS_NT" case also needs a small change: > char *cmd = concat (cmd1, "\" > ", tmp_name); This doesn't quote tmp_name; it should. > +static char* ^^ There should be a space before "*". > + if (*p == '\'') > + { > + new_str[i+1] = '\\'; > + new_str[i+2] = '\''; > + new_str[i+3] = '\''; > + i += 3; I don't understand why you are adding ''\'' and not just \'. Wouldn't the latter work for some reason? Thanks.