From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jim Porter Newsgroups: gmane.emacs.devel Subject: Re: Structurally fixing command injection bugs Date: Wed, 22 Feb 2023 10:57:24 -0800 Message-ID: References: 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="21646"; mail-complaints-to="usenet@ciao.gmane.io" To: Vasilij Schneidermann , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Feb 22 19:58:12 2023 Return-path: Envelope-to: ged-emacs-devel@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 1pUuJg-0005Rs-Qh for ged-emacs-devel@m.gmane-mx.org; Wed, 22 Feb 2023 19:58:12 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUuJ1-0000pT-0S; Wed, 22 Feb 2023 13:57:32 -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 1pUuIz-0000Zg-GW for emacs-devel@gnu.org; Wed, 22 Feb 2023 13:57:29 -0500 Original-Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUuIx-0006qb-T1 for emacs-devel@gnu.org; Wed, 22 Feb 2023 13:57:29 -0500 Original-Received: by mail-pj1-x1031.google.com with SMTP id cp7-20020a17090afb8700b0023756229427so1143030pjb.1 for ; Wed, 22 Feb 2023 10:57:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=7N0Vuw7RaBTgwNWFfK1ytS6MDV/yyRcLA2F2jv+9aQg=; b=GTBRhasT+RUp1ERBHaNg5rNYcYYLp3qv1xV0wr9L1TZ3N7bUoRDs8EaG4oP2Ajc8qq jKTnuFhmRW3bWLfrzyIdV8stcWNSpM6IUH8w1jU3OLzwlBYlqZ7FbkebNzpeZmSAjQHX B8YtFi6sP8+L9Y9vEa7EArpbFvvBfnbnjMWw9esMzmOmO3RxaLHiRqweKoVVtUtvLosa p3dm9rPf/bAepFejDloDhv39ec4CleDp0w6bhQIYvfbjh2+FM+00v7c8nxn4IzF5NPJ0 tGGADbrB2q1Ed3fc913Az8MeSggXcc1AsnUOatoC4rqj95lWeaDgUTq/05KU36gU3FgB Y1EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7N0Vuw7RaBTgwNWFfK1ytS6MDV/yyRcLA2F2jv+9aQg=; b=hG/AgxHYDD0yRq85Me2lvVA8UQjHodJu+GHT+yEE46GVlAX84lrHz8uU5c81Bf7ytX ctqJiRctqtP8LhDQrc4dcT20xrrLFgRJsN8IC63khnpuuHmMTSbu1lyuGvdowKl4520o koTAGVWI0pgPJQS8WQw6lJpDFSTUMPQ/nXDc19BEeDF17gHFcjlsHHF46w47b++licpc KyCFxUZBTwnnGPDlEvgH2NY/h8Jhq+xwte1o8FZuArMEgUajVDkoNmxImzhKb8Av57G4 WvfnlrA35YpiZHl3Z5zM0wsNpplLTI5wEibFE0EkpOzh/DwLnN5gRITIj//udcFS2Sdb 5etg== X-Gm-Message-State: AO0yUKWZzpjkEiOdesLeAvVt6HdHjzEP+/mz6zthB7oKLUAVDyVv0zcr 5+U+hEPKYPLTeASCYsFiqI8= X-Google-Smtp-Source: AK7set+mO2Pb62UaF3L20BIqyZfA5PGKFxOJz0HnRy91txIouTKWC4VLvPrJaEWLj0Vk+tNf7ikZGw== X-Received: by 2002:a17:902:e80f:b0:19a:9890:eac6 with SMTP id u15-20020a170902e80f00b0019a9890eac6mr11843085plg.24.1677092246029; Wed, 22 Feb 2023 10:57:26 -0800 (PST) Original-Received: from [192.168.1.2] (cpe-76-168-148-233.socal.res.rr.com. [76.168.148.233]) by smtp.googlemail.com with ESMTPSA id ja4-20020a170902efc400b001948ff5cc32sm11564069plb.215.2023.02.22.10.57.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Feb 2023 10:57:25 -0800 (PST) Content-Language: en-US In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=jporterbugs@gmail.com; helo=mail-pj1-x1031.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:303686 Archived-At: On 2/22/2023 2:08 AM, Vasilij Schneidermann wrote: > I see several options for moving forward: [snip] > - Come up with a different replacement working much like > `process-lines`, but returning a string instead (I have no idea what > an appropriate name would be, maybe `command-to-string`?) Where possible, I think this is probably best, but there are likely times where you really want the benefits of a shell. For example, what if the command you want to run involves a pipeline? One option for this would be to enhance 'shell-command-to-string' so that you can pass it arguments that will be correctly escaped when substituted into the final command string. For example: (shell-command-to-string "cat %s | rev" "file with a $weird name.txt") ;; Runs "cat 'file with a $weird name.txt' | rev" (This is similar to what you might do when parameterizing an SQL query or something.)