From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id GLLrNVDPCWRIcAEASxT56A (envelope-from ) for ; Thu, 09 Mar 2023 13:21:36 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id QAilNVDPCWRClgAAauVa8A (envelope-from ) for ; Thu, 09 Mar 2023 13:21:36 +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 8E3238514 for ; Thu, 9 Mar 2023 13:21:35 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="qDWn/3za"; 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=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1678364496; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=mQMI6t3kWPydsvkEh7tbTO6GWFhPKFd+XdsmwBSbCmM=; b=TcKA46Gmj7o7Bbvi/7Gl/CQiQU63U/TIivU0hEVOBFtq3IX3RBeKg8eHjTXFOS/eDnKOPL EnFiV5V81cYk3lbC8ICvoslbqXXinYLuWWC1gaUedZGsNqYwahazG/tBeBbu39CHiJl6Fa Y2pBnM90IVFBVUMoy3XO1PaD9lVRsORzPOSRU94AgMl129tW8ItwsPwwweObKaPVenWmZV Gth6otBQHwSQNfiJbPp8wyTbuRESwmKuq3ILYAyMLatYbrJ4hqiI0xTU7z6DrgpFlant1n Qm8q00OMeTZT8Z1IuZuLsmH3OrD1TxkTGcPbmmATbvsKO7WJALVw9qKl3GosJg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1678364496; a=rsa-sha256; cv=none; b=Eyzqz1uSpqncr54Yz/y+l+lAjzhBsP4CNLjwYn8GxJBSCECO44/u9oz4ozeV+wAr4C14+G IPJDk46ADwkD3fhakb9Dt1aZGzyfpcSFbujKieGyz911anUEtMWo+yZSAQdL/rRWTBkY0e bfQhGqjSbL/+Rpl3oUjl1Tll/eq2hrJkpUhYK41TtK19ddZU2gmgJfKbgj4ZFpoAQw13OR IQRq2LYJ6icYIXU4HdY8v5MrASjl96TSeSimU8tr0HFuuLtOaxCrQ0jilMNLiVgV57cJ+l NLaKNOQg0/wFxWsai/7w5qGI61Zg9Z51/vaiwS5sifpIzQr/Oz7p1c8Fx6/Vlg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b="qDWn/3za"; 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=pass (policy=none) header.from=posteo.net Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1paFGU-00062o-Gu; Thu, 09 Mar 2023 07:20:59 -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 1paFGQ-00062A-Dc for emacs-orgmode@gnu.org; Thu, 09 Mar 2023 07:20:54 -0500 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1paFGN-0005cU-VH for emacs-orgmode@gnu.org; Thu, 09 Mar 2023 07:20:53 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 7890524038C for ; Thu, 9 Mar 2023 13:20:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1678364449; bh=AQYXVmU+8g5TRuDnfZzaSlmcPetdWE1bSq483muh7dY=; h=From:To:Cc:Subject:Date:From; b=qDWn/3zaFzJLep/Kr6DXBB9RjqVS72rQiC2f/Fod5SbNOoQBmRq8U6miuqYHU4ofQ xBtpF9zorUHRdnYLtVRtCwq/3/dX0ZDAziw5olyYCwsIMm8rvOZp19hiCVs1+cxIpt sAOwg4UXtpzSVq6amqkB1DwIb7/5wV0VuMGPUYZt+l0f7+bZI91zcHJEQchT0NpEH6 AEcq0cWwSeU8g9tCVrq21GUh2pyLlXHKPUVXyX9bQrNWZoT5GY97BQhMpenNzjaPmE m+cZbkjXsj1NcXxgX9h+a8rhIGZZfoY/Cim4viLF1Be5nmAthj6ntZamAAirJEgDtt v1IAqt8IuzKpw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4PXSvL2Hd3z9rxd; Thu, 9 Mar 2023 13:20:46 +0100 (CET) From: Ihor Radchenko To: lux Cc: Max Nikulin , emacs-orgmode@gnu.org Subject: Re: [PATCH] Fix ob-latex.el command injection vulnerability. In-Reply-To: References: <87v8jzjj1p.fsf@localhost> <047b7367-c98f-e531-b3e9-bc50b6b098e5@gmail.com> Date: Thu, 09 Mar 2023 12:22:15 +0000 Message-ID: <871qlyqfm0.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: X-Migadu-Scanner: scn0.migadu.com X-Migadu-Queue-Id: 8E3238514 X-Spam-Score: -11.01 X-Migadu-Spam-Score: -11.01 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-Flow: FLOW_IN X-Migadu-Country: US X-TUID: QqfG5p16juZM lux writes: > Hi, this is a new patch, let me briefly explain this patch: Thanks! > 2. `org-babel-latex-convert-pdf' is not safe, simple test: > > (org-babel-latex-convert-pdf ";id;.tex" ";uname;.pdf" "" "") > > So, add `shell-quote-argument' to each external parameter. I am not sure if blindly adding `shell-quote-argument' is safe here. > (defun org-babel-latex-convert-pdf (pdffile out-file im-in-options im-out-options) > "Generate a file from a pdf file using imagemagick." > - (let ((cmd (concat "convert " im-in-options " " pdffile " " > - im-out-options " " out-file))) > + (let ((cmd (concat "convert " (shell-quote-argument im-in-options) " " > + (shell-quote-argument pdffile) " " > + (shell-quote-argument im-out-options) " " > + (shell-quote-argument out-file)))) > (message "Converting pdffile file %s..." cmd) > (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. However, for example, (shell-quote-argument "-enhance -strip") will return "-enhance\\ -strip", which is not what we want. Similar problem with other instances of `shell-command' in Org where header args supply command line arguments. Like in :cmdline. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at