From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark Diekhans Newsgroups: gmane.emacs.bugs Subject: bug#6953: 24.0.50; serious security bug in create backup files Date: Thu, 2 Sep 2010 09:33:36 -0700 Message-ID: <19583.53728.357608.629758@bugle.cse.ucsc.edu> References: <19583.19642.954872.847808@bugle.cse.ucsc.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1283445600 5989 80.91.229.12 (2 Sep 2010 16:40:00 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 2 Sep 2010 16:40:00 +0000 (UTC) Cc: 6953@debbugs.gnu.org To: Glenn Morris Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Sep 02 18:39:58 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OrCpQ-0003D5-IA for geb-bug-gnu-emacs@m.gmane.org; Thu, 02 Sep 2010 18:39:56 +0200 Original-Received: from localhost ([127.0.0.1]:52668 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OrCpP-0000Oj-SB for geb-bug-gnu-emacs@m.gmane.org; Thu, 02 Sep 2010 12:39:56 -0400 Original-Received: from [140.186.70.92] (port=58222 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OrCpK-0000O1-IN for bug-gnu-emacs@gnu.org; Thu, 02 Sep 2010 12:39:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OrCpJ-000644-Bo for bug-gnu-emacs@gnu.org; Thu, 02 Sep 2010 12:39:50 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41223) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OrCpJ-00063y-91 for bug-gnu-emacs@gnu.org; Thu, 02 Sep 2010 12:39:49 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1OrChl-0005MO-KP; Thu, 02 Sep 2010 12:32:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mark Diekhans Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 02 Sep 2010 16:32:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6953 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 6953-submit@debbugs.gnu.org id=B6953.128344511620598 (code B ref 6953); Thu, 02 Sep 2010 16:32:01 +0000 Original-Received: (at 6953) by debbugs.gnu.org; 2 Sep 2010 16:31:56 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OrChg-0005MB-DW for submit@debbugs.gnu.org; Thu, 02 Sep 2010 12:31:56 -0400 Original-Received: from services.cse.ucsc.edu ([128.114.48.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OrChd-0005M6-Uc for 6953@debbugs.gnu.org; Thu, 02 Sep 2010 12:31:54 -0400 Original-Received: from bugle.cse.ucsc.edu (bugle.cse.ucsc.edu [128.114.56.11]) by services.cse.ucsc.edu (8.13.6/8.13.6) with ESMTP id o82GXaPQ014095 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 2 Sep 2010 09:33:36 -0700 (PDT) Original-Received: (from markd@localhost) by bugle.cse.ucsc.edu (8.13.8/8.12.10) id o82GXaib025945; Thu, 2 Sep 2010 09:33:36 -0700 In-Reply-To: X-Mailer: VM 8.1.1 under 24.0.50.1 (x86_64-unknown-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Thu, 02 Sep 2010 12:32:01 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:39909 Archived-At: Ah, this is because copy-file (in fileio.c) does fchmod (ofd, st.st_mode & 07777); It seems like copy-file needs an option to disable this. The behavior of backup-buffer-copy where it keeps the existing file would also be a hole. mark Glenn Morris writes: > markd@soe.ucsc.edu wrote: > > > Oh, wait, it doesn't look like there is a problem with your patch, > > only the comment ;-) backup-buffer-copy says: > > > > ;; Create temp files with strict access rights. It's easy to > > ;; loosen them later, whereas it's impossible to close the > > ;; time-window of loose permissions otherwise. > > I don't know what this comment means. There are no "temp files" AFAICS > (unless copy-file creates some internally). I think this comment may > be a leftover from when this code used write-region rather than > copy-file. Indeed the whole mode-changing bit may be as well. C-h f > copy-file says: "This function always sets the file modes of the > output file to match the input file." > > Eg: > > touch ~/1 > chmod 644 ~/1 > (set-default-file-modes ?\700) > (copy-file "~/1" "~/2" t t t) > ls -l ~/2 # -> world readable