From: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
To: Richard Purdie <richard.purdie@linuxfoundation.org>
Cc: Constantin Musca
<constantinx.musca-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
openembedded-core@lists.openembedded.org
Subject: Re: [PATCH] patch.bbclass: Use one TMPDIR per patching process
Date: Fri, 14 Sep 2012 14:24:27 +0200 [thread overview]
Message-ID: <lyobl8u70k.fsf@ensc-virt.intern.sigma-chemnitz.de> (raw)
In-Reply-To: <1347623450.9456.29.camel@ted> (Richard Purdie's message of "Fri, 14 Sep 2012 12:50:50 +0100")
Richard Purdie <richard.purdie@linuxfoundation.org> writes:
>> > + process_tmpdir = os.path.join('/tmp', str(os.getpid()))
>> > + shutil.rmtree(process_tmpdir)
> Its only being used as a prefix, not as the full directory path name
> so it isn't quite as insecure as it would first appear.
It *is* insecure as it would first appear. 'shutil.rmtree()' does not
traverse the directory in a secure way so that an attacker could:
1. touch /tmp/<2-32767>/a
2. mkdir /tmp/<2-32767>/Z
3. wait for an inotify which triggers on deletion of the 'a' files
4. rmdir /tmp/$dir/Z
5. ln -s /home/<user> /tmp/$dir/Z
When steps 4+5 are executed between
| $ strace python -c 'import shutil; shutil.rmtree("/tmp/2");'
| ...
| lstat("/tmp/2/Z", {st_mode=S_IFDIR|0755, st_size=60, ...}) = 0
| <<<< steps 4+5 here >>>>
| openat(AT_FDCWD, "/tmp/2/Z", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
| getdents(3, /* 3 entries */, 32768) = 72
| ...
| unlink("/tmp/2/Z/foo") = 0
user writable directories will be removed.
There have been established some rules regarding secure tmpfile/dir
generation in the last 10-20 years which should never be violated.
Beside the obvious security issues, build will be aborted when somebody
else creates a /tmp/<number> file and <number> matches the bitbake pid.
Enrico
next prev parent reply other threads:[~2012-09-14 12:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-12 11:58 [PATCH] patch.bbclass: Use one TMPDIR per patching process Constantin Musca
2012-09-14 11:28 ` Enrico Scholz
2012-09-14 11:50 ` Richard Purdie
2012-09-14 12:24 ` Enrico Scholz [this message]
2012-09-14 13:33 ` Richard Purdie
2012-09-14 13:40 ` Enrico Scholz
2012-09-14 16:00 ` Saul Wold
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=lyobl8u70k.fsf@ensc-virt.intern.sigma-chemnitz.de \
--to=enrico.scholz@sigma-chemnitz.de \
--cc=constantinx.musca-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=openembedded-core@lists.openembedded.org \
--cc=richard.purdie@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.