Bug 1171779 - pkexec forwards too few environment variables => GTK theme not being used under GNOME
Summary: pkexec forwards too few environment variables => GTK theme not being used und...
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: polkit
Version: 27
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jan Rybar
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-12-08 15:13 UTC by Luke Macken
Modified: 2018-11-30 22:21 UTC (History)
11 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-11-30 22:21:39 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
FreeDesktop.org 96713 0 None None None 2016-06-29 10:37:29 UTC

Description Luke Macken 2014-12-08 15:13:51 UTC
Description of problem:

The liveusb-creator uses PyQt4, which is supposed to use the GTK style when run on GNOME, but it currently looks like this:

http://lewk.org/img/liveusb-creator-3.13.png


Version-Release number of selected component (if applicable):
qt-4.8.6-18.fc21.x86_64
PyQt4-4.11.3-1.fc21.x86_64

Comment 1 Rex Dieter 2014-12-08 15:54:54 UTC
Kevin clued me in on irc:

src/gui/kernel/qapplication_x11.cpp contains checks:

            if (!qgetenv("KDE_FULL_SESSION").isEmpty()) {
                X11->desktopEnvironment = DE_KDE;
                X11->desktopVersion = qgetenv("KDE_SESSION_VERSION").toInt();
                break;
            }

            if (qgetenv("DESKTOP_SESSION") == "gnome") {
                X11->desktopEnvironment = DE_GNOME;
                break;
            }

            // GNOME_DESKTOP_SESSION_ID is deprecated for some reason, but still check it
            if (!qgetenv("GNOME_DESKTOP_SESSION_ID").isEmpty()) {
                X11->desktopEnvironment = DE_GNOME;
                break;
            }

So looks like this may be a consequence of running liveusb-creator fully through pkexec , and loosing the user environment.

And also from irc:
<lmacken> rdieter: not a big deal. someday I'll decouple the gui from the backend

^^ getting proper policykit integration should naturally fix this too

Comment 2 Kevin Kofler 2014-12-08 23:26:09 UTC
IMHO, this is a bug in pkexec: It really shouldn't be removing those environment variables for GUI apps. They are needed for proper look&feel integration. I also have this problem with Calamares.

IMHO, the whitelist approach is a very bad idea, a blacklist would probably work better, but at the very least, GUI applications need the following environment variables forwarded:
KDE_FULL_SESSION
KDE_SESSION_VERSION
DESKTOP_SESSION
GNOME_DESKTOP_SESSION_ID
XDG_CURRENT_DESKTOP
QT_STYLE_OVERRIDE
QT_XCB_FORCE_SOFTWARE_OPENGL

There are some more that may make sense to forward, such as KDE_IS_PRELINKED, QT_PLUGIN_PATH, XDG_DATA_DIRS etc., but some of those may be considered security issues. The ones in my list above are perfectly safe though.

Comment 3 Fedora End Of Life 2015-11-04 09:57:09 UTC
This message is a reminder that Fedora 21 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 21. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '21'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 21 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 4 Kevin Kofler 2016-06-29 10:37:29 UTC
The trivial patch is now attached to the upstream bug that Philip Müller from Manjaro filed. Can we PLEASE get this applied? As it stands (i.e., without the patch), pkexec is very broken for Qt apps.

Comment 5 Kevin Kofler 2016-06-29 10:39:28 UTC
(Philip's report also adds QT_QPA_PLATFORMTHEME to the list of needed environment variables, which is correct.)

Comment 6 Rex Dieter 2016-06-29 15:10:34 UTC
Any comment or objections from polkit maintainers?

If not, I'll consider applying the proposed patch next week and issue updates.

Comment 7 Miloslav Trmač 2016-06-29 15:48:16 UTC
(In reply to Rex Dieter from comment #6)
> Any comment or objections from polkit maintainers?
> 
> If not, I'll consider applying the proposed patch next week and issue
> updates.

Considering https://bugs.freedesktop.org/show_bug.cgi?id=96713#c3 , please don’t.

If $KDE_SESSION_VERSION is obviously unsafe, and used just in simple shell scripts, I don’t feel comfortable assuming that the other ones used for plugin loading in several layers deep stack of QApplication code are safe.

Also, I can’t find any documentation for several of the variables, and those documented in QApplication have no documented safety properties.

Comment 8 Rex Dieter 2016-06-29 15:49:59 UTC
Pardon my ignorance, but how is KDE_SESSION_VERSION obviously unsafe?

Comment 9 Miloslav Trmač 2016-06-29 16:25:36 UTC
e.g. with
> KDE_SESSION_VERSION='passwd -- root "abc def"'
running
> xdg-desktop-icon uninstall /dev/null
causes execution of
> kdepasswd -- root '"abc' 'def"-config' --userpath desktop

(See with (bash -x xdg-desktop-icon …), create a ~/bin/kde$something which prints confirmation to /dev/tty and run KDE_SESSIoN_VERSION='$something $other_args'


I don’t know whether this can be weaponized into arbitrary command execution; this should be enough for a demonstration.

Comment 10 Rex Dieter 2016-06-29 16:30:18 UTC
Ah thanks.   I guess I naively assumed/hoped that PATH would be sanitized, which appears to not be the case.

Comment 11 Miloslav Trmač 2016-06-29 16:32:41 UTC
PATH is supposed to be sanitized (set to the standard plus ~destination_user/bin), but when the user is authorized to run $specific_command, running /usr/bin/kde$other_command is also unauthorized.

Comment 12 Kevin Kofler 2016-06-29 18:04:58 UTC
The problem is, Qt needs access to KDE_SESSION_VERSION to know how to adapt to Plasma theming. We are asking for those environment variables for a reason.

Comment 13 Miloslav Trmač 2016-06-29 20:02:02 UTC
(In reply to Kevin Kofler from comment #12)
> The problem is, Qt needs access to KDE_SESSION_VERSION to know how to adapt
> to Plasma theming. We are asking for those environment variables for a
> reason.

Sorry, “I need to pass these values to keep my themes, and I hope that nothing will become insecure” is not an acceptable way to change privilege escalation systems.  (I apologize if you have actually done research on this, it’s just that there is no way to tell, and no way to follow up on that research.  You definitely know more about Qt and KDE than I do.)

See https://bugs.freedesktop.org/show_bug.cgi?id=96713#c7 for a possible way forward.  I’m afraid I can’t spare weeks to make the security argument against the thousands of FOSS packages in general; perhaps we can find ways to simplify to make things obviously correct.

Comment 15 Fedora End Of Life 2016-11-24 11:19:37 UTC
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '23'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 23 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 16 Fedora End Of Life 2017-11-16 18:57:32 UTC
This message is a reminder that Fedora 25 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 25. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '25'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 25 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 17 Ben Cotton 2018-11-27 14:50:18 UTC
This message is a reminder that Fedora 27 is nearing its end of life.
On 2018-Nov-30  Fedora will stop maintaining and issuing updates for
Fedora 27. It is Fedora's policy to close all bug reports from releases
that are no longer maintained. At that time this bug will be closed as
EOL if it remains open with a Fedora  'version' of '27'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 27 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 18 Ben Cotton 2018-11-30 22:21:39 UTC
Fedora 27 changed to end-of-life (EOL) status on 2018-11-30. Fedora 27 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.