From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Max Nikulin Newsgroups: gmane.emacs.bugs Subject: bug#66390: `man' allows to inject arbitrary shell code Date: Tue, 10 Oct 2023 18:09:43 +0700 Message-ID: <76847bef-83a5-4bbe-8641-9dd82cf377a2@gmail.com> References: <83wmvyzir2.fsf@gnu.org> <585dcaf0-358e-4a9d-84d1-6fd9c2c8aec5@gmail.com> <83v8bizf9r.fsf@gnu.org> <1865abb8-16cd-4570-9a8a-87cf9430583d@gmail.com> <875y3iigua.fsf@gmx.de> <83o7hazap7.fsf@gnu.org> <87mswugyoq.fsf@gmx.de> <83jzryz6op.fsf@gnu.org> <87a5sugwcx.fsf@gmx.de> <83h6n2z3tr.fsf@gnu.org> <831qe5znrz.fsf@gnu.org> <834jizwxm2.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1698"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: 66390@debbugs.gnu.org, michael.albinus@gmx.de To: Eli Zaretskii , lux Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 10 13:11:01 2023 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 1qqAdh-0000KE-1t for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 10 Oct 2023 13:11:01 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qqAdR-0003en-KO; Tue, 10 Oct 2023 07:10:45 -0400 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 1qqAdN-0003cX-Bo for bug-gnu-emacs@gnu.org; Tue, 10 Oct 2023 07:10:41 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qqAdM-0004cp-R3 for bug-gnu-emacs@gnu.org; Tue, 10 Oct 2023 07:10:41 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qqAdh-0002U1-Ln for bug-gnu-emacs@gnu.org; Tue, 10 Oct 2023 07:11:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Max Nikulin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 Oct 2023 11:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66390 X-GNU-PR-Package: emacs Original-Received: via spool by 66390-submit@debbugs.gnu.org id=B66390.16969362149472 (code B ref 66390); Tue, 10 Oct 2023 11:11:01 +0000 Original-Received: (at 66390) by debbugs.gnu.org; 10 Oct 2023 11:10:14 +0000 Original-Received: from localhost ([127.0.0.1]:34105 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qqAcw-0002Sh-06 for submit@debbugs.gnu.org; Tue, 10 Oct 2023 07:10:14 -0400 Original-Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]:50583) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qqAcu-0002SS-30 for 66390@debbugs.gnu.org; Tue, 10 Oct 2023 07:10:12 -0400 Original-Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2c189dabcc3so65547791fa.1 for <66390@debbugs.gnu.org>; Tue, 10 Oct 2023 04:09:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696936185; x=1697540985; darn=debbugs.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=9BCJ6/zTcbn/B18kLa5Sa2/T2AfOae2Pv7jevKujyyY=; b=YUAv38dYOOZRInu4dx+7Tvrqc2m7i3DVkQ6gK58QeMAbthlYj/sv7nEz91YIG2iGuj S3wj3lmbH+iijuyGFCu8E3KtD8soGb4xCML+nX6MlZutAAxdPpGurHA9TNz0uR9oUXIp 4FygrVcaWdYzvZSyUMaeXQKCPqON/hEdgBtaU8EIy57So26LrXuUHR2TePSYGlgRLSsg v6OXBweFAsdEaOG6Q5yIgkpnRFKqtaTA5+0cJih/v2JEHcVYUqNhL8mdhP7+crMQMW+M Dy0Rh7T/yBAFyuQrWx1LGkJVwLPfvG2qpqbl1Nn2U0VbyrI0gW2pYZhhMObHGOO2DsKl s9TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696936185; x=1697540985; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9BCJ6/zTcbn/B18kLa5Sa2/T2AfOae2Pv7jevKujyyY=; b=grVB4/QKxqQT1w0Yixg0jAVs4bI9qDDIOGISyxocjOcdiQvV8LUQaA/AqkXYJSsUkr vPedwpTmNUAnUdGnCbWIqaXhL+844IAJPtlxZ0pGa11U32VPYcrLvPm7B5B8e0pVFcWu pkZeLeVRwj4nZ/rmlYHM3rcOYt9dbiQc3JUpvB9mpDSb24nv8jAvo3jblHNpYlZ1bKaa X3dKQ9TqvmzFhVcScMvscwj2u69AOC1zCywMcuCi0GOpft6GfPoyJF8RxvqjhBs+3RKv MVnAkWvgK+b8gOg0dOMEUoUIYhP4PMnMM6BExa66n7RyTUQ+zxchPbEn5j1s0F10IfFe o9Uw== X-Gm-Message-State: AOJu0YxElx7lpueS0NjKkboWnZRaYqFMH4bpqwTa4UuEbDITxnIWSBO5 C2HzVO1eoVCW5IEnT42vx0A= X-Google-Smtp-Source: AGHT+IFTeIbAhOnN2M9FB6PdD/Q+AjXJevW8GbCm0nOfN5rM/J7NfqdAoAgNqB9leSfxaQYrDkEFmg== X-Received: by 2002:a2e:92c6:0:b0:2bf:e9e8:de23 with SMTP id k6-20020a2e92c6000000b002bfe9e8de23mr13619176ljh.16.1696936184727; Tue, 10 Oct 2023 04:09:44 -0700 (PDT) Original-Received: from [192.168.0.101] (nat-0-0.nsk.sibset.net. [5.44.169.188]) by smtp.googlemail.com with ESMTPSA id k11-20020a2e888b000000b002c00da5c522sm2387803lji.78.2023.10.10.04.09.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Oct 2023 04:09:44 -0700 (PDT) Content-Language: en-US, ru-RU In-Reply-To: <834jizwxm2.fsf@gnu.org> 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:272193 Archived-At: On 09/10/2023 23:48, Eli Zaretskii wrote: > And I ask again: what happens with command (man "[") in this case? "sh" "-c" "man [ 2>/dev/null | sed -e '/^[\1-\32][\1-\32]*$/d' #... so the code in man.el relies on "[" not interpreted as a special character when it is alone. It is not escaped! Perhaps you are confused by the following commit 4ef9cc5a5de 2023-07-26 17:30:21 +0300 Eli Zaretskii: Fix "M-x man RET [ RET" It affects completion, but not M-x man RET [ RET. (And I am surprised that "@" is treated specially for some reason.) > Please believe me: this is not simple. There's more here than meets > the eye. In addition to all kinds of weird characters in man-page > names, you also need to consider SEE ALSO links from one man page to > another, which can cross lines and include dashes and whitespace. > Etc. etc... I had my share of messing with this code, and one thing I > know is that nothing is ever as simple as quoting here. References split across lines should be handled by the code that creates/opens references, not by `man'. `man' should receive cleaned up references. (Cross-references is a case when properly implemented roff parser has advantages over dealing with text formatted for tty.) If you believe that other packages must not call `man' then this function should not have an argument since it is a part of public interface.