delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/09/16/18:26:21

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <3D865A7D.2010902@etr-usa.com>
Date: Mon, 16 Sep 2002 16:26:05 -0600
From: Warren Young <warren AT etr-usa DOT com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1) Gecko/20020826
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: Cygwin-L <cygwin AT cygwin DOT com>
Subject: Re: Crontab problems
References: <20020914200118 DOT GA1032 AT TOOS> <Pine DOT GSO DOT 4 DOT 44 DOT 0209141950270 DOT 21486-100000 AT slinky DOT cs DOT nyu DOT edu> <20020915110749 DOT GA1804 AT TOOS>

Raphael wrote:
> I cannot see the security 
> issue for Cygwin as I now work arround by editing /var/cron/tabs/<currentuser>
> directly and restarting the service afterwards.

The security problem is a race condition.  Here's the scenario:

1. The crontab program makes a copy of the cron file to a temp file and 
then launches your $EDITOR on that file.

2. Editor reads file in, lets you modify it.  You say 'File | Save'.

3. Editor removes/renames temp file.

4. Security risk here.  (Details below.)

5. Editor creates a new file with the temp file name and writes file 
contents into it.

6. Editor exits, crontab installs new file and exits.

So what can happen at 4?  Here's one possibility which might even have 
a few variations:

1. Malicious program sits watching for crontab to start up, then watches 
the /tmp directory for new files.

2. A new file appears.  Now the malware sits waiting for it to disappear.

3. File disappears, and in the split second that it's gone the malware 
quickly writes out a new file with that name and keeps it open so that 
the $EDITOR can't write new contents into it.

4. Editor tries to open a new file with the temp file name for writing, 
but fails because there's already a file with that name.  User assumes 
that Windows is buggy (good guess, but wrong this time) and exits 
$EDITOR without saving.

5. The file is still open, but if you create the file with the right 
permissions it can still be read.  Crontab notices that the file has a 
new modification time, so it assumes that $EDITOR successfully rewrote 
the file; it reads the file and installs it.

6. At a time chosen by the malware's author, cron runs a program with 
Raphael's authentication token.  Since this is Windows, user Raphael is 
probably an Administrator.  One PC, cracked like an egg.

Since you're already editing the crontab file directly with an 
erase/rename-and-rewrite type of editor, you've opened yourself to this 
kind of security problem already.  I hope this worries you.

There are ways around this problem, at least under Unix type systems and 
probably also on systems running NTFS.  One is for crontab to make a 
directory under /tmp which is readable and writeable only by the user 
that owns the cron file, and to place the temp file into that directory. 
  Then the malware has no way of creating a file in that directory 
unless it already holds your authentication token, in which case there 
is little point to the attack to begin with.  This is a much bigger 
patch than making crontab close the file before handing it off to your 
$EDITOR, though.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019