kdesudo+dolphin leads to command execution vulnerability

Bug #163417 reported by John Dong
270
Affects Status Importance Assigned to Milestone
dolphin (Ubuntu)
Invalid
Medium
Martin Böhm
Nominated for Gutsy by John Dong
kdesudo (Ubuntu)
Fix Released
Undecided
Unassigned
Nominated for Gutsy by John Dong

Bug Description

Binary package hint: kdesudo

It is not clear whether or not this defect is in kdesudo or dolphin, but I will mark both and let you guys decide.

STEPS:

(1) In dolphin, create a folder called: "test; konqueror" (without quotes)
(2) Right click it, under Actions, choose run as root

WHAT HAPPENS:
(1) Dolphin opens folder "test" as root
(2) Konqueror, after a few seconds, pops up, running as root

EXPECTED BEHAVIOR:
Dolphin should just pop up navigated to the "test; konqueror" folder as root.

This allows folder names to be crafted in a way that causes an unexpected command to be executed with elevated privileges when the user simply wants to navigate to that folder with elevated privileges.

In IRC, fdoving and I tried various combinations of quoting the %u and kdesu arguments in /usr/share/apps/d3lphin/servicemenus/d3lphin_su.desktop but I found that every attempted workaround could be thwarted by the proper use of ", ', and `.

The basic problem is that kdesu should not be interpreting its arguments as shell code, or dolphin should be shell-escaping its arguments before feeding to kdesu.

Revision history for this message
Matthew Flaschen (matthew-flaschen) wrote :

Since the other bug was marked as a dup of this, I'll note again that you can fix accidental manifestations of this problem (e.g. a folder called New Folder) by quoting the %u in d3lphin_su, but that won't stand up to deliberate attacks.

Revision history for this message
John Dong (jdong) wrote :

Right, as I noted in the original description various escaping of the argument in the .desktop file fixes it for some filenames but still breaks for other file names, and is defintiely open to intentional attacks. The real fix needs to be done in some more solid way...

I am thinking whether or not kdesu should just shell-escape its arguments. Kdesu should also have something similar to the GNU -- option to stop parsing for parameters and assume everything after -- is one large parameter. Is there any real usecase for kdesu taking in bourne shell syntax?

Revision history for this message
Matthew Flaschen (matthew-flaschen) wrote :

I think there is. I think this is a problem with d3lphin, not with kdesu. Kdesu should be able to run arbitrary command-lines, just like sudo can. The problem here is that d3lphin isn't doing proper escaping before passing to kdesu. It should quote the "%u" as well as escaping any instances of ' to \' and " to \".

Revision history for this message
Martin Böhm (martin.bohm) wrote :

The question is: Do we want kdesudo to treat a command like this:

kdesudo "konqueror ;dolphin"

as two commands, or rather treat is as a parameter to the first command, i.e. konqueror? Does the user *really* want to launch dolphin after konqueror, or does he rather want to open the folder called ";dolphin" with Konqueror?

So I wouldn't blame D3lphin yet. I can fix it so that it will prefix the "Run as root" command properly, but the implications of this bug go further than this.

Revision history for this message
Martin Böhm (martin.bohm) wrote :

Thank you for reporting this bug. If you insist that it is a KDE3 Dolphin's fault, please specify the wrong steps that KDE3 Dolphin takes. Thank you.

Changed in dolphin:
assignee: nobody → martin.bohm
importance: Undecided → Medium
status: New → Incomplete
Revision history for this message
Matthew Flaschen (matthew-flaschen) wrote :

I think kdesu needs to operate exactly the same way as sudo. I now see that's not the case yet. Your example shows one of the problems.

Here is the output from sudo and kdesu:

sudo "konqueror; dolphin"
sudo: konqueror; dolphin: command not found

kdesu "konqueror; dolphin"

Launches konqueror, then dolphin after konqueror closes. This is a concrete problem that should be fixed in kdesu. However

kdesu should be made to interpret "konqueror; dolphin" (a quoted string) as a single command, the way sudo does.

Revision history for this message
Anthony Mercatante (tonio) wrote :

kdesudo (1.3-0ubuntu1) hardy; urgency=low

  * New upstream release. Closes LP: #163417

 -- Anthony Mercatante <email address hidden> Mon, 19 Nov 2007 20:36:49 +0100

Changed in kdesudo:
status: New → Fix Released
Revision history for this message
Matthew Flaschen (matthew-flaschen) wrote :

The bug shouldn't be closed, because this is still an issue in Gusty.

Revision history for this message
Guillaume Martres (smarter) wrote :

I don't think this bug should be marked as a security vulnerabulity because kdesudo asks for the admin password, and if you know it you can just use ALT+F2.

Revision history for this message
John Dong (jdong) wrote :

No. It is most certainly a security vulnerability.

(1) Opening a folder as root should NEVER EVER open the wrong folder, then execute a part of the folder name as a command under root.
(2) kdesudo will not prompt the user for a password (and hence allow the user to review the command) if the user has within the past 15 minutes opened something else as root.
(3) We should not assume, even if said dialog comes up, that the user has enough shell-code knowledge to identify an escape.

Revision history for this message
Frode M. Døving (frode) wrote :

And kdesudo is the problem, not dolphin/d3lphin.

Revision history for this message
John Dong (jdong) wrote :

I agree with the above that this is not a dolphin defect

Changed in dolphin:
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public Security information  
Everyone can see this security related information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.