Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 47033 - security issues with prelink tempfile creation in /tmp
Summary: security issues with prelink tempfile creation in /tmp
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All All
: Highest normal (vote)
Assignee: Gentoo Security
URL:
Whiteboard: A3 [noglsa] jaervosz
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-06 22:13 UTC by SpanKY
Modified: 2005-01-29 02:07 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description SpanKY gentoo-dev 2004-04-06 22:13:26 UTC
after the sandbox code was updated solar pointed out another issue ... the /tmp/portage-prelink.tmp.portage_lockfile is created in very much the same manor in portage.py with no sanity checks

unlike the sandboxpids file though, i dont see any reason for this file to be created in /tmp ... nor do i see a reason for static naming ... ive pointed out (iirc) in other bugs (or at least on irc) that parallel emerges can break because they stomp each other in a race condition over this file

solution i think is to utilize some interface in python (i'm not a python mast0r) similar to tmpfile() and to build the file in somewhere that only portage/root would/should have access to it ... perhaps ${PORTAGE_TMPDIR}/lockfiles/<random name> ... i think that would solve all the aforementioned issues if the dir was say root:portage 660
Comment 1 solar (RETIRED) gentoo-dev 2004-04-07 08:49:40 UTC
I think the mode for any such subdir would be 770(-rwxrwx---) vs 660(-rw-rw----)
without the ug+x on the dir I don't think we would be able to read inside of it.
Comment 2 Nicholas Jones (RETIRED) gentoo-dev 2004-04-07 09:47:55 UTC
Portage uses a lockfile for that file, so it won't race itself.

This file is also only used for md5 checks... I suppose you could
race portage for it... The end result would be not deleting files.
This isn't quite the same concern as sandboxes truncation issue,
but it could be an annoyance as a local user could add to system
stale files.

Nothing gets executed and it's a pure copy...
Nothing overly insecure about it.

I suppose you could defeat the md5 check and the lockfile if you
really applied yourself to it, but this only applies if you
support prelinking on that system...

On a side note... As a user, you could probably cause portage to
sit in a blocked state by acquiring an exclusive lock first. :-/


Comment 3 solar (RETIRED) gentoo-dev 2004-04-08 14:07:20 UTC
Nick, 
Do you think we should move the lockfile handling to ${PORTAGE_TMPDIR}/lockfiles/ as SpanKY suggested as a saftey precaution?

I'v also also seeing an excessive amount of odd voodoo going on with that file..
Note I don't have any parts of prelink on my system installed or in FEATURES.
I'm guessing this is not expected behavior.

root# strace -o ./woof -eopen -f emerge portage

user$ grep open\(\"/tmp woof | uniq 
3161  open("/tmp/portage-prelink.tmp.portage_lockfile", O_WRONLY|O_CREAT|O_LARGEFILE, 0660) = 3
3161  open("/tmp/portage-prelink.tmp.portage_lockfile", O_WRONLY|O_CREAT|O_LARGEFILE, 0660) = 7

user$ grep open\(\"/tmp/portage-prelink.tmp.portage_lockfile ./woof | wc -l
119
Comment 4 Brian Harring (RETIRED) gentoo-dev 2004-08-22 05:15:58 UTC
Actually, that's expected behaviour.  attempts locking for the checks iirc.
Still an issue?  the prelink-chksum fooling around w/ files takes place in /var/lib/portage last I looked.
Comment 5 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2004-12-06 09:38:33 UTC
Reassigning to security. 

dev-portage any progress on this one?
Comment 6 Jason Stubbs (RETIRED) gentoo-dev 2005-01-26 22:20:30 UTC
This is fixed as ferringb noted. All prelink temp files are now created in /var/lib/portage which has root:portage (2770) permissions.
Comment 7 solar (RETIRED) gentoo-dev 2005-01-27 07:57:15 UTC
This has been fixed for so long now that I would think this should just be closed without a GLSA.
Comment 8 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2005-01-27 09:24:23 UTC
Security please comment on need for GLSA on this one.
Comment 9 Thierry Carrez (RETIRED) gentoo-dev 2005-01-27 11:49:43 UTC
I agree with solar. If the fixed version is very old, better not issue a GLSA about this.
Comment 10 Thierry Carrez (RETIRED) gentoo-dev 2005-01-29 02:07:41 UTC
Two NO votes -> closing, Reopen if you wanted to vote YES