Moodle 1.9.3 Remote Code Execution

Type securityvulns
Reporter Securityvulns
Modified 2008-12-14T00:00:00


Moodle 1.9.3 Remote Code Execution

Name Remote Code Execution in Moodle Systems Affected Moodle 1.9.3 and possibly earlier versions Severity High Impact (CVSSv2) High 7.3/10, vector: (AV:N/AC:L/Au:M/C:P/I:P/A:C) Vendor Advisory Authors Antonio "s4tan" Parata (s4tan AT ush DOT it) Francesco "ascii" Ongaro (ascii AT ush DOT it) Giovanni "evilaliv3" Pellerano (evilaliv3 AT digitalbullets DOT org) Date 20081212


From the Moodle web site: "Moodle is a course management system (CMS) - a free, Open Source software package designed using sound pedagogical principles, to help educators create effective online learning communities".


A Remote Code Execution exists in Moodle 1.9.3.


  • Remote Code Execution (RCE) in texed.php (pathname parameter)

A Remote Code Execution (RCE) vulnerability has been found in filter/tex/texed.php. In order to exploit this vulnerability register_globals must be enabled as the "TeX Notation" filter.

All these conditions reduce the impact of the vulnerability, to remark this fact we have set "multiple authentication" flag in the cvss2 score).

In texed.php we find the following instructions:


$cmd = tex_filter_get_cmd($pathname, $texexp); system($cmd, $status);


Where the function "tex_filter_get_cmd", defined in lib.php, is the following:


function tex_filter_get_cmd($pathname, $texexp) { $texexp = escapeshellarg($texexp); $executable = tex_filter_get_executable(false);

if &#40;&#40;PHP_OS == &quot;WINNT&quot;&#41; || &#40;PHP_OS == &quot;WIN32&quot;&#41; || &#40;PHP_OS ==

"Windows")) { $executable = str_replace(' ', '^ ', $executable); return "$executable ++ -e \"$pathname\" -- $texexp";

} else {
    return &quot;&#92;&quot;$executable&#92;&quot; -e &#92;&quot;$pathname&#92;&quot; -- $texexp&quot;;



As we can see no check is performed on the "$pathname" parameter neither in "texed.php" neither in the "tex_filter_get_cmd" function declared in "lib.php".

Seen this it's possible to exploit this vulnerability to execute arbitrary commands on the target server. The following urls are proof of concept for Linux and Windows:

On Linux:";ls+-l;echo+"

On Windows:"+||+dir+||+echo+

This RCE is "blind". You'll never see the list dir of the example because there is no print of the system command output.


Moodle 1.9.3 and possibly earlier versions are vulnerable.


Proper input validation will fix the vulnerabilities. Actually the vulnerability is fixed in the Dev tree.

Upgrade to latest development version.


Vendor will not release a new version addressing this vulnerability since moodle has several different issues with register globals and the vendor decided to resolve them in a different way for the upcoming versions.

"At present we are working on changes that will prevent installation when register globals on. They should be committed later this week. I suppose we are not going to release 1.9.4 now because register globals issue is a know problem already."


No CVE at this time.


20080121 Bug discovered 20081111 Initial vendor contact (No Response) 20081811 Second vendor contact (No Response) 20081811 Vendor response 20081212 Advisory released (Fix available only in dev tree)


Antonio "s4tan" Parata, Francesco "ascii" Ongaro and Giovanni "evilaliv3" Pellerano are credited with the discovery of this vulnerability.

Antonio "s4tan" Parata web site: mail: s4tan AT ictsc DOT it, s4tan AT ush DOT it

Francesco "ascii" Ongaro web site: mail: ascii AT ush DOT it

Giovanni "evilaliv3" Pellerano mail: evilaliv3 AT digitalbullets DOT it


Copyright (c) 2008 Francesco "ascii" Ongaro

Permission is granted for the redistribution of this alert electronically. It may not be edited in any way without mine express written consent. If you wish to reprint the whole or any part of this alert in any other medium other than electronically, please email me for permission.

Disclaimer: The information in the advisory is believed to be accurate at the time of publishing based on currently available information. Use of the information constitutes acceptance for use in an AS IS condition. There are no warranties with regard to this information. Neither the author nor the publisher accepts any liability for any direct, indirect, or consequential loss or damage arising from use of, or reliance on, this information.