Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[security] commands running when doing emerge -S
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Sfynx
n00b
n00b


Joined: 01 Jun 2002
Posts: 50

PostPosted: Sun Nov 02, 2003 4:30 pm    Post subject: [security] commands running when doing emerge -S Reply with quote

When you run a emerge --searchdesc, all commands in all ebuilds before the functions src_unpack and so on get executed (thos environment variable assignments). So when I put a

echo foo>/bar

between those commands in a random ebuild, the file is there after the search.

Isn't this a big security risk when you get a faulty portage tree in some way? These commands are ran as root... I alread had an issue where a .keep file was placed in my apache documentroot after doing only a search.

edit: emerge --searchdesc, not emerge search
_________________
I'm the great Cornholio!
Are you threatening me?


Last edited by Sfynx on Mon Nov 03, 2003 6:15 pm; edited 2 times in total
Back to top
View user's profile Send private message
Zoltan
Guru
Guru


Joined: 27 Aug 2003
Posts: 394
Location: Moscow, Russia

PostPosted: Sun Nov 02, 2003 6:59 pm    Post subject: Reply with quote

You don't have to search as root, this is allowed to be done as ordinary users, but I think this is still a security hole...
_________________
Light travels faster than sound. That's why some people appear bright before you hear them speak.
Back to top
View user's profile Send private message
slartibartfasz
Veteran
Veteran


Joined: 29 Oct 2002
Posts: 1462
Location: Vienna, Austria

PostPosted: Mon Nov 03, 2003 6:47 am    Post subject: Reply with quote

i think you are right - emerge should not execute statements without any security check or escaping - i'll verify this and report it at bugs.gentoo.org

[EDIT] i could not verify this with -s, there is however a possibility to do what u describe when installing a ebuild which was modified in this way. this even works when the ebuild belongs to another user than root.

[EDIT] submitted a bug report:
https://bugs.gentoo.org/show_bug.cgi?id=32603
_________________
To an engineer the glass is neither half full, nor half empty - it is just twice as big as it needs to be.
Back to top
View user's profile Send private message
Sfynx
n00b
n00b


Joined: 01 Jun 2002
Posts: 50

PostPosted: Mon Nov 03, 2003 6:12 pm    Post subject: Reply with quote

Sorry, my fault. It does happen when doing a deep search (-S), not a normal search (-s). Verified that. When I first verified this issue, I did a -S also, but I usually do -s searches... had to be more awake I guess ;)

so... can we be sure that the ebuilds we get from a rsync are always clean of malicious stuff? what if a rsync box gets compromised? also noted that in the bug report.
_________________
I'm the great Cornholio!
Are you threatening me?
Back to top
View user's profile Send private message
slartibartfasz
Veteran
Veteran


Joined: 29 Oct 2002
Posts: 1462
Location: Vienna, Austria

PostPosted: Mon Nov 03, 2003 7:04 pm    Post subject: Reply with quote

i tried the deep search also - didnt work for me - can u post a sample please?

i am not very concerned about the packages from server, they are quite safe, i think the local handling should be improved, that would catch the eventuall bad ebuild from the server as well as exploitation attempts from local users.
_________________
To an engineer the glass is neither half full, nor half empty - it is just twice as big as it needs to be.
Back to top
View user's profile Send private message
Sfynx
n00b
n00b


Joined: 01 Jun 2002
Posts: 50

PostPosted: Mon Nov 03, 2003 7:28 pm    Post subject: Reply with quote

did this:

Code:
emerge sync


inserted into /usr/portage/net-www/kita/kita-0.6.1.ebuild (some ebuild I even not have installed, not having KDE ;)):

Code:

IUSE=""

echo fooo>/bar

PVMAJOR="`echo ${PV} | cut -d'.' -f1`"
PVMINOR="`echo ${PV} | cut -d'.' -f2`"


and did this:

Code:


root@sfynx / # emerge -S fjhjfhjfh
Searching...
[ Results for search key : fjhjfhjfh ]
[ Applications found : 0 ]


root@sfynx / # ls
bar  bin  boot  chroot  dev  etc  home  lib  mnt  opt  proc  root  sbin  service  tmp  usr  var
root@sfynx / # cat bar
fooo
root@sfynx / #

_________________
I'm the great Cornholio!
Are you threatening me?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum