From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id 4HcGOLIJCmRCTAAASxT56A (envelope-from ) for ; Thu, 09 Mar 2023 17:30:42 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 0IsROLIJCmTYCgEA9RJhRA (envelope-from ) for ; Thu, 09 Mar 2023 17:30:42 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 78B7EC262 for ; Thu, 9 Mar 2023 17:30:42 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1paJ9R-0005VJ-SI; Thu, 09 Mar 2023 11:29:57 -0500 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 1paJ9Q-0005V5-AF for emacs-orgmode@gnu.org; Thu, 09 Mar 2023 11:29:56 -0500 Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1paJ9O-0002TJ-LQ for emacs-orgmode@gnu.org; Thu, 09 Mar 2023 11:29:55 -0500 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1paJ9I-0004tb-W0 for emacs-orgmode@gnu.org; Thu, 09 Mar 2023 17:29:48 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org From: Max Nikulin Subject: Re: [PATCH] Fix ob-latex.el command injection vulnerability. Date: Thu, 9 Mar 2023 23:29:41 +0700 Message-ID: References: <87v8jzjj1p.fsf@localhost> <047b7367-c98f-e531-b3e9-bc50b6b098e5@gmail.com> <871qlyqfm0.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Content-Language: en-US In-Reply-To: <871qlyqfm0.fsf@localhost> Received-SPF: pass client-ip=116.202.254.214; envelope-from=geo-emacs-orgmode@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 28 X-Spam_score: 2.8 X-Spam_bar: ++ X-Spam_report: (2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FORGED_MUA_MOZILLA=2.309, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, NICE_REPLY_A=-0.001, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1678379442; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=v+Vn2m5r+MLTDFJZNnGVPYhzoJ8fmLLJqm3Zv3MiM9g=; b=UvyLgx8mMrFekqohQQzsu8Or9PU3FqvFeg0q9y7OlJS3ClIRPEDKWxQQCGGR+pKQS0mx3K dbGHEp7FVwJ2uyq5Nd3bUFOcXdL5/9eRsa9WK1a2E3I+sdT+eWdsue8siG+ZCcs6WOOI6N zapvXhDkn3xHFdr8IC7XDiCRTlrJBgsmhPy/yZ5TLD9c2qiPb+VCVq8IPDICs+jyKKfyAk WaBHNutz9OHpEK9D9alBP4lyHf0I/GzzLWX72xkLuxOXSYb1pUHRgEVGvhjx4oZ3357ewU APVNwKH8G2wjRWW5eLgxP2eVpVMzhTUm5Q3ij3NG5CrihStjtw6Wzed0XUh3Mg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1678379442; a=rsa-sha256; cv=none; b=bm3MNgzuDsb/Z+3t2hBgPIl1rU7yQ8IQYiXf6qPGk9KupMnyc0+1z7ZErFWB9QNrBd2x22 6jLdZoWAUllhPOwgeCAlfDPy8AHFGGcv/dEQFJGvLmE/Lm9GoN7NxCKcmqm9Rbg/D9v4Rd If6klxSd9ePyq6w9ykio7pZl2x1HPajNq9IgDLw59yfvrU6714Td0o3PMsxQkmFhxnKr+U xe2cK2N3BqLzk5uOGVGm5ZBohv0aZpUjgbLmKhAC1FnXt83cpdewuYyzU3o7YHkNE92UZ7 eR9Jf/ef0aRh4qUCKSKRUL/NmhGYUaLQrtVVru2uiXBvMLPjguL6lc/aSLW1lA== Authentication-Results: aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none) X-Migadu-Spam-Score: 4.00 X-Spam-Score: 4.00 X-Migadu-Queue-Id: 78B7EC262 X-Migadu-Scanner: scn1.migadu.com X-TUID: 36EQo8iD2hsu On 09/03/2023 19:22, Ihor Radchenko wrote: > lux writes: >> Hi, this is a new patch, let me briefly explain this patch: Thank you for scratching my itch related to unsafe shell commands in Org Mode. >> 2. `org-babel-latex-convert-pdf' is not safe, simple test: ... > I am not sure if blindly adding `shell-quote-argument' is safe here. I believe, first hunk still can be committed. >> (shell-command cmd))) > > im-in-options and im-out-options, according to > https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.html, > are options passed to ImageMagick. ImageMagick is disaster per se. Ideally `call-process' or `process-file' should be here instead of `shell-command' making `shell-quote-argument' unnecessary. Sorry, it is not clear for me if remote files (e.g. /ssh:...) are supported here. Unfortunately options as a string, not as a list, means compatibility issue. `split-string-and-unquote' may cause new bugs. I have not evaluated it yet, but from discussions on this list I have an impression that some LaTeX packages need to run external commands. I am unsure to which degree it is safe or it may be easily exploited.