Bug 1194205 (CVE-2015-1877) - CVE-2015-1877 xdg-utils: command injection vulnerability due to local variables collision in xdg-open
Summary: CVE-2015-1877 xdg-utils: command injection vulnerability due to local variabl...
Keywords:
Status: CLOSED NOTABUG
Alias: CVE-2015-1877
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL:
Whiteboard:
Depends On: 1194209 1194210 1194211
Blocks: 1194208
TreeView+ depends on / blocked
 
Reported: 2015-02-19 10:43 UTC by Vasyl Kaigorodov
Modified: 2021-02-17 05:37 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-06-08 02:38:56 UTC
Embargoed:


Attachments (Terms of Use)

Description Vasyl Kaigorodov 2015-02-19 10:43:51 UTC
Command injection was reported [1] in xdg-utils running with dash.
Suggested patch:
https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=xdg-open.diff;att=1;bug=777722
Upstream bug report:
https://bugs.freedesktop.org/show_bug.cgi?id=89129

This issue only affects systems with "dash" shell set as default system shell.

[1]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=777722

Comment 2 Vasyl Kaigorodov 2015-02-19 10:47:38 UTC
Created xdg-utils tracking bugs for this issue:

Affects: fedora-all [bug 1194209]

Comment 3 Ján Rusnačko 2015-02-25 10:13:26 UTC
Analysis:

xdg-open is used to open a file or URL in users preferred application. During the process of finding the correct app to run, it recursively searches Desktop file in function search_desktop_file(). This function uses local variable $file to store the path to the searched Desktop file and runs function get_key() on the $file. get_key() searched for 

[Desktop Entry]
Exec=...

in the $file and content of Exec= is later executed.

The problem is that variable name $file is also used earlier in function open_generic() and stores path to the file being opened. Now assuming that system`s shell *does not* reset the content of $file when it is declared as local variable *again*, then the file being opened will be searched as Desktop file. If it contains expected [Desktop Entry] along with Exec=, it leads to arbitrary command execution.

The assumption about reset of local variable contents hold for dash, but not bash:
$ cat testme
testme() {
   x=backfromthedead
   local x
   echo $x
}
testme

$ dash testme 
backfromthedead

$ bash testme 

Also, this does not work if the local variable is initialized:

$ cat testme 
testme() {
   x=backfromthedead
   local x=""
   echo $x
}
testme

$ dash testme 

$ bash testme 

xdg-open as shipped in Fedora and RHEL-7 does initialize $file variable, and uses bash as default /bin/sh.

Comment 4 Ján Rusnačko 2015-02-25 10:15:33 UTC
Statement:

This issue did not affect the versions of xdg-utils as shipped with Red Hat Enterprise Linux 6 and 7.


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