The python unpickling function can execute arbitrary code given a carefully crafted pickle. This characteristic is by design: http://www.python.org/doc/current/lib/pickle-sec.html The file /var/cache/edb/mtimedb is writable by the group "portage", and it contains a pickle. Therefore anyone in the "portage" group can modify this file, and execute arbitrary code inside the next process that unpickles this file - possibly by root.
Fixed in CVS for 2.0.48 You really should be trusting any users you allow access to portage though.