From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#59817: [PATCH] Fix etags local command injection vulnerability Date: Sun, 4 Dec 2022 08:27:14 -0800 Message-ID: References: <83r0xf9qsx.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32944"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 59817@debbugs.gnu.org To: Eli Zaretskii , lux Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 04 17:28:14 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 1p1rqf-0008OA-Lv for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 04 Dec 2022 17:28:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p1rqV-0001d0-W4; Sun, 04 Dec 2022 11:28: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 1p1rqU-0001ci-La for bug-gnu-emacs@gnu.org; Sun, 04 Dec 2022 11:28: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 1p1rqU-0004WM-9e for bug-gnu-emacs@gnu.org; Sun, 04 Dec 2022 11:28:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p1rqT-0001Xs-Ui for bug-gnu-emacs@gnu.org; Sun, 04 Dec 2022 11:28:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 04 Dec 2022 16:28: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.16701712375928 (code B ref 59817); Sun, 04 Dec 2022 16:28:01 +0000 Original-Received: (at 59817) by debbugs.gnu.org; 4 Dec 2022 16:27:17 +0000 Original-Received: from localhost ([127.0.0.1]:58521 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1rpk-0001XY-PR for submit@debbugs.gnu.org; Sun, 04 Dec 2022 11:27:17 -0500 Original-Received: from mail-oa1-f46.google.com ([209.85.160.46]:44770) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1rpj-0001XB-8g for 59817@debbugs.gnu.org; Sun, 04 Dec 2022 11:27:15 -0500 Original-Received: by mail-oa1-f46.google.com with SMTP id 586e51a60fabf-1447c7aa004so2763343fac.11 for <59817@debbugs.gnu.org>; Sun, 04 Dec 2022 08:27:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=avEisii5RqDZvDfXjCGc0TOOv8lsDFphVmNtzC5Z8zs=; b=TjqjlZsYZDSja3wGD9JGuWNKCWprgJM63kUVIPL9Wp3wMxfavxqYipbLRt0sNDxCLb knpq4EEv89cC0q8Y+bvSSjfeyslltRhX53oC0Ftuyt5qL9XUGjFxpv3ILhu/7YmAunwk vJEsAr39DTZzLBDVVLoFEkISI+5YOmh27Zq8gWSkhrDyiEir95wv5JdTJI6xLVFO5JYR SEQtbKFB/jbPKvvsdN6MLg4NRmA3SYaMtZbc5tbtN7lOnuj/rkU62nDq/j+hIomNuNnO OvsL6w1fWhffDA5d8W9gcpElhNnquVr76ArzDhoAVQWBvyQe4JMb/BZkdX8cYuwSr4UM 7/Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=avEisii5RqDZvDfXjCGc0TOOv8lsDFphVmNtzC5Z8zs=; b=X6LgZZaGp7el/7/GLVQ4VSyMAz6Au5ODUlTEgdyEYrJI9PZO3SgPhdmyaQCseE1Exf bmD1gENNy+5bmZG1pRYUCzsYpYH7u2uNuKEJ4G66SJDnT9MbWEk6hTEwMtWHmcoObMzX qazLIRNpJq9cumyoKmnnmAKnoL2rj72aX0tegO+GbI2N54oL41ajF7NkbQvqEcYVEPZD NJln4ztZW699FoGemxFCl3YZkoi3U8iXrqvlcsaiIunGIOeALHgHiSqvnVuHHH1031Xw Ac6pvo5BoAlvhFw8G6LndclyU7KHjhR0KXDr2mlg79lNfyfjz1ycdN9rhH/aJ6D7D8zO 9bwQ== X-Gm-Message-State: ANoB5pm3xU9IoVjv8ian0Kclzf+GAnxOLIBPI8bYcCVEOC+0S475NuTI RggPu4JB/20n2lG7To5TTrfVSNMU5jAwvccCSQg= X-Google-Smtp-Source: AA0mqf4+QQ/2Ay+yv5ThgcIlRbNXlYYwMPQyY6JiBVhZBOmUeMgvytGSic54YJlgPuazeB6AFezNzl0r7Rs753JYxtY= X-Received: by 2002:a05:6870:4995:b0:143:522a:ebcc with SMTP id ho21-20020a056870499500b00143522aebccmr27672395oab.199.1670171234998; Sun, 04 Dec 2022 08:27:14 -0800 (PST) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sun, 4 Dec 2022 08:27:14 -0800 In-Reply-To: <83r0xf9qsx.fsf@gnu.org> X-Hashcash: 1:20:221204:59817@debbugs.gnu.org::S6u72kjL9feiXkw9:3ALg 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:249951 Archived-At: Eli Zaretskii writes: > Thanks, but no, thanks. This cure is worse than the disease. Let's please > find simpler, more robust solutions. It TMPDIR is a problem, let's use a > file whose name is hard-coded in the etags.c source, or quote the name when > we pass it to the shell. If we suspect someone could disguise shell > commands as file names, let's quote the file names we pass to the shell with > '...' to prevent that. Etc. etc. -- let's use simple solutions that don't > drastically change the code. With single quotes, every single quote character also needs to be quoted so you can't just use a file named "';rm -rf $HOME;'". So you need to substitute every single quote character with something like ' => '"'"' I'm not sure if tricks to escape it will remain, but "man sh" promises: Single Quotes Enclosing characters in single quotes preserves the literal meaning of all the characters (except single quotes, making it impossible to put single-quotes in a single-quoted string). The safest option is to just not call system, of course.