__________________________________________________________ The U.S. Department of Energy Computer Incident Advisory Capability ___ __ __ _ ___ / | /_\ / \___ __|__ / \ \___ __________________________________________________________ INFORMATION BULLETIN TikiWiki Vulnerability [TikiWiki Christmas Security Alert] January 3, 2005 15:00 GMT Number P-084 ______________________________________________________________________________ PROBLEM: A vulnerability was found in the uploading of image files in TikiWiki. PLATFORM: TikiWiki 1.79, 1.8.5, and 1.9dr4 DAMAGE: There is no check on the uploaded images in the wiki edit page. A malicious user may then upload any PHP script and call it directly in the TikiWiki file tree, from img/wiki_up/directory. SOLUTION: Apply the available updates. ______________________________________________________________________________ VULNERABILITY The risk is Low. A remote attacker may execute arbitrary code ASSESSMENT: as the user running the web server. ______________________________________________________________________________ LINKS: CIAC BULLETIN: http://www.ciac.org/ciac/bulletins/p-084.shtml ORIGINAL BULLETIN: http://tikiwiki.org/tiki-print_article.php?articleId=97 ______________________________________________________________________________ [***** Start TikiWiki Christmas Security Alert *****] Christmas Security Alert : php injection -------------------------------------------------------------------------------- The security flaw There was no check on the uploaded images in the wiki edit page. Then a malicious user with permission to upload image could upload any php script and call it directly in the tikiwiki file tree, from img/wiki_up/ directory. Actually the flaw is quite trivial, stupid, and obvious. It's rather amazing that nobody fixed it before. -------------------------------------------------------------------------------- The security cure Repair your tiki without delay ! Check your tikiwiki sanity Search for files with extensions .php, .php3, .php4 or .phtml in your img/wiki_up (or img/wiki_up/$tikidomain/ in case of multitiki). You can use the following onelines to find them out (works with multitikis too) ~np~ find img/wiki_up -type f -name "*.php" find img/wiki_up -type f -name "*.php3" find img/wiki_up -type f -name "*.php4" find img/wiki_up -type f -name "*.phtml"~/np~ Check your apache logs To find out if someone used that flaw to inject unwanted php file, you can grep your logs (if you can use grep). ~np~ grep 'img/wiki_up/[^"]*.ph\(p\(3\|4\)\?\|tml\) ' var/log/apache/yourtiki.access.log~/np~ or if your logs are rotated and if you can use zgrep ~np~ zgrep 'img/wiki_up/[^"]*.ph\(p\(3\|4\)\?\|tml\) ' var/log/apache/yourtiki.access.log*~/np~ Apply a fix The fastest emergency fix is to disable the "Pictures" feature in the wiki admin panel (/tiki-admin.php?page=wiki). The alternative inhibition of pictures upload on wiki pages is to limit the feature by setting the tiki_p_upload_picture permission in the groups admin panel. But for a real fix, and to still be able to include pictures on wiki pages, you need to upgrade or patch the tiki-editpage.php file : CVS users : Just update your version, the fix is in all branches from 1.7 to 1.10 cvs -q update -dP Other users : Add the following line in tiki-editpage.php ~np~ if (preg_match('/\.(gif|png|jpe?g)$/i',$picname))~/np~ just before the line containing ~np~ move_uploaded_file( ...~/np~ with version 1.7.x, on line 106 with version 1.8.x, on line 138 with version 1.9rcx, on line 173 and 181 with version 1.10, on line 172 The sysadmin way Alternatively (or in more) to the file upgrade/patch, you can inhibit the parsing of php files in the img/ dir. If you use apache, but don't have access to the configuration file, create a .htaccess in img/wiki_up/ containing ~np~ order deny,allow deny from all ~/np~ if it doesn't work, ask your admin to activate the .htaccess power with ~np~ AllowOverride Limit~/np~ in the Directory directive of your tikiwiki tree. Note that if you use a multi-tiki setup, you'll need to add that .htaccess in each img/wiki_up/$tikidomain subdirectory. If you can change your apache conf because you admin it, add ~np~ order deny,allow deny from all ~/np~ where you need to adapt the path for the directory to match with where is located your img/ dir. Both methods above just block the access to php files in img/ directory, but you may also want to inhibit .pl, .vb and other extensions if your global configuration enables those extensions to be parsed by another preprocessor. Read more on http://httpd.apache.org/docs-project/ -------------------------------------------------------------------------------- New releases with a fix In each released branch a new version is available, namely 1.7.9, 1.8.5 and 1.9dr4. If you didn't apply one of the solutions listed above : you should upgrade as soon as possible. Download here! Remember that you always can alert the tikiwiki security group by sending a mail to security at tikiwiki.org. -------------------------------------------------------------------------------- mose, for the Tikiwiki Security Bunch-of-people [***** End TikiWiki Christmas Security Alert *****] _______________________________________________________________________________ CIAC wishes to acknowledge the contributions of TikiWiki for the information contained in this bulletin. _______________________________________________________________________________ CIAC, the Computer Incident Advisory Capability, is the computer security incident response team for the U.S. Department of Energy (DOE) and the emergency backup response team for the National Institutes of Health (NIH). CIAC is located at the Lawrence Livermore National Laboratory in Livermore, California. CIAC is also a founding member of FIRST, the Forum of Incident Response and Security Teams, a global organization established to foster cooperation and coordination among computer security teams worldwide. CIAC services are available to DOE, DOE contractors, and the NIH. CIAC can be contacted at: Voice: +1 925-422-8193 (7x24) FAX: +1 925-423-8002 STU-III: +1 925-423-2604 E-mail: ciac@ciac.org Previous CIAC notices, anti-virus software, and other information are available from the CIAC Computer Security Archive. World Wide Web: http://www.ciac.org/ Anonymous FTP: ftp.ciac.org PLEASE NOTE: Many users outside of the DOE, ESnet, and NIH computing communities receive CIAC bulletins. If you are not part of these communities, please contact your agency's response team to report incidents. Your agency's team will coordinate with CIAC. The Forum of Incident Response and Security Teams (FIRST) is a world-wide organization. A list of FIRST member organizations and their constituencies can be obtained via WWW at http://www.first.org/. This document was prepared as an account of work sponsored by an agency of the United States Government. Neither the United States Government nor the University of California nor any of their employees, makes any warranty, express or implied, or assumes any legal liability or responsibility for the accuracy, completeness, or usefulness of any information, apparatus, product, or process disclosed, or represents that its use would not infringe privately owned rights. Reference herein to any specific commercial products, process, or service by trade name, trademark, manufacturer, or otherwise, does not necessarily constitute or imply its endorsement, recommendation or favoring by the United States Government or the University of California. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or the University of California, and shall not be used for advertising or product endorsement purposes. LAST 10 CIAC BULLETINS ISSUED (Previous bulletins available from CIAC) P-074: “newgrp(1)” Local Privilege Escalation p-075: "libkadm5srv" Heap Buffer Overflow P-076: "nfs-utils" Package Vulnerabilities P-077: "paginit" Command Vulnerability P-078: Diag script Vulnerability P-079: "chcod" Command Vulnerability P-080: "lsvpd" Untrusted Path Vulnerability P-081: Linux Kernel Vulnerabilities P-082: 'tiff' Insufficient Input Validation P-083: Netscape Directory Server on HP-UX LDAP Vulnerability