From 294cd4d37cde175873181a364d0a22cf49c8a695 Mon Sep 17 00:00:00 2001 From: Igor Zhbanov Date: Sun, 23 Feb 2020 00:25:10 +0300 Subject: [PATCH] [booster] Always drop extra groups for non-privileged apps. Fixes JB#49088 Don't trust to UID/GID received from untrusted invoker request when deciding whether to drop extra groups for non-privileged apps. The application's rights should depend only on the stated application's privileges and not on the caller's process rights. Drop setuid() because the boosters are launched under "nemo" user ID in user session. Signed-off-by: Igor Zhbanov --- src/launcherlib/booster.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/launcherlib/booster.cpp b/src/launcherlib/booster.cpp index 5f23cb1..235f2a0 100644 --- a/src/launcherlib/booster.cpp +++ b/src/launcherlib/booster.cpp @@ -512,18 +512,11 @@ void Booster::setEnvironmentBeforeLaunch() // Going forward, this could be improved to support // a larger range of privileges via ACLs. if (!isPrivileged(m_appData)) { - // The application is not privileged. Drop any user or - // group ID inherited from the booster, and instead set - // the user ID and group ID of the calling process. - - if (geteuid() != m_appData->userId()) { - setuid(m_appData->userId()); - } - - if (getegid() != m_appData->groupId()) { - setresgid(m_appData->groupId(), m_appData->groupId(), - m_appData->groupId()); - } + // The application is not privileged. Drop group ID + // inherited from the booster executable. + gid_t gid = getgid(); + if (setresgid(gid, gid, gid)) + Logger::logError("Booster: can't change the process GID: %m"); } // Make sure that boosted application can dump core. This must be